?
Solved

Help me to solve this functions in Oracle and how to use it?

Posted on 2005-05-12
4
Medium Priority
?
224 Views
Last Modified: 2012-05-05
I have this package of functions in Oracle database
and i want to use them in Delphi

How to record consumtion? with StoredProc?
I see here Java :/

CREATE OR REPLACE PACKAGE BODY consumption IS
      FUNCTION recordConsumption
      (
            casinoId       number      ,
            clientId       string      ,
            sessionDate       date      ,
            slipId             number      ,
            articleCode       string      ,
            quantity       number      ,
            pointsNumber       string      ,
            pointsType       string      ,
            amount             string      ,
            complementaryAmount string,
            free             string      ,
            authorId       string      ,
            schema             string
      ) RETURN number AS
      language java name 'mc.mis.database.storedprocedure.consumption.OraConsumption.recordConsumption(
            int                  ,
            java.lang.String      ,
            java.sql.Date            ,
            int                  ,
            java.lang.String      ,
            int                  ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String) return int';

      FUNCTION cancelConsumption
      (
            casinoId       number      ,
            clientId       string      ,
            datHeu             date      ,
            articleCode       string      ,
            dettyppts       string      ,
            free             string      ,
            vouncher       string      ,
            codCanUsr       string      ,
            canCmt             string      ,
            schema             string
      ) RETURN number AS
      language java name 'mc.mis.database.storedprocedure.consumption.OraConsumption.cancelConsumption(
            int                  ,
            java.lang.String      ,
            java.sql.Timestamp      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String      ,
            java.lang.String) return int';

      FUNCTION getLifePoints(casinoId number, clientId string, schema string) RETURN ResultSet IS
            rs ResultSet;
            sqlQuery String(2048);
            BEGIN
                  -- search by casino and client
                  IF casinoId = -1 THEN
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_VIE) NBR_PT_VIE';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CLI = :a';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using clientId;
                  ELSE
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_VIE) NBR_PT_VIE';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CASINO = :a';
                        sqlQuery := sqlQuery || ' AND ID_CLI = :b';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using casinoId, clientId;
                  END IF;
                  RETURN rs;
            END;

      FUNCTION getReedemPoints(casinoId number, clientId string, schema string) RETURN ResultSet IS
            rs ResultSet;
            sqlQuery String(2048);
            BEGIN
                  -- search by casino and client
                  IF casinoId = -1 THEN
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_ACH) NBR_PT_ACH';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CLI = :a';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using clientId;
                  ELSE
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_ACH) NBR_PT_ACH';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CASINO = :a';
                        sqlQuery := sqlQuery || ' AND ID_CLI = :b';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using casinoId, clientId;
                  END IF;
                  RETURN rs;
            END;

      FUNCTION getAllPoints(casinoId number, clientId string, schema string) RETURN ResultSet IS
            rs ResultSet;
            sqlQuery String(2048);
            BEGIN
                  -- search by casino and client
                  IF casinoId = -1 and clientId = 'ALL' THEN
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_VIE) NBR_PT_VIE, SUM(NBR_PT_ACH) NBR_PT_ACH';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery;
                  ELSIF casinoId = -1 THEN
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_VIE) NBR_PT_VIE, SUM(NBR_PT_ACH) NBR_PT_ACH';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CLI = :a';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using clientId;
                  ELSIF clientId = 'ALL' THEN
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_VIE) NBR_PT_VIE, SUM(NBR_PT_ACH) NBR_PT_ACH';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CASINO = :a';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using casinoId;
                  ELSE
                        sqlQuery := 'SELECT ID_TYPPTS, SUM(NBR_PT_VIE) NBR_PT_VIE, SUM(NBR_PT_ACH) NBR_PT_ACH';
                        sqlQuery := sqlQuery || ' FROM GALAXIS.PTKPTS';
                        sqlQuery := sqlQuery || ' WHERE ID_CASINO = :a';
                        sqlQuery := sqlQuery || ' AND ID_CLI = :b';
                        sqlQuery := sqlQuery || ' group by ID_TYPPTS';
                        open rs for sqlQuery using casinoId, clientId;
                  END IF;
                  RETURN rs;
            END;


END Consumption;
/
0
Comment
Question by:selas
  • 2
  • 2
4 Comments
 
LVL 27

Expert Comment

by:kretzschmar
ID: 13986728
>I see here Java :/
don't worry, this is handled with the oracle-server
(usual the pl/sql function calls a java-library)

as long as the result is an ordinary type a TStoredProc should be no problem,
about the resultset see your other question

use
consumption.FunctionName
in your TStoredProc

u can also use a tquery like
select consumption.FunctionName from dual
to get the results

meikl ;-)
0
 

Author Comment

by:selas
ID: 13988623
how to find out where it records consumpion in database?

language java name 'mc.mis.database.storedprocedure.consumption.OraConsumption.recordConsumption?
0
 
LVL 27

Accepted Solution

by:
kretzschmar earned 1500 total points
ID: 13988774
you don't need to locate where the java function is,
this does the server for you (its somewhere in the oracle server enviroment).
if you need to know it, you have to ask the admin.

you only have to call the oracle package function

meikl ;-)
0
 

Author Comment

by:selas
ID: 13994334
how to call recordConsumption function with Delphi?
can you explain me
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses
Course of the Month13 days, 18 hours left to enroll

807 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question