Declaring DBMS stored procedures as remote procedure
calls
Description
In PowerBuilder, you can use dot notation for calling non-result-set
stored procedures as remote procedure calls (RPCs):
|
1 |
object.function |
You can call database procedures in SAP, Oracle, Informix, and other
ODBC databases with stored procedures.
RPCs provide support for Oracle PL/SQL tables and parameters that
are defined as both input and output. You can call overloaded
procedures.
Applies to
Transaction object
Syntax
|
1 2 3 4 |
FUNCTION rtndatatype functionname ( { { REF } datatype1 arg1,..., { REF } datatypen argn } ) RPCFUNC { ALIAS FOR "spname" } SUBROUTINE functionname ( { { REF } datatype1 arg1 , ..., { REF } datatypen argn } ) RPCFUNC { ALIAS FOR "spname" } |
|
Argument |
Description |
|---|---|
|
FUNCTION or SUBROUTINE |
A keyword specifying the type of call, which |
|
rtndatatype |
In a FUNCTION declaration, the datatype of the value |
|
functionname |
The name of the database procedure as you will call |
|
REF |
Specifies that you are passing by reference the When you pass a string by reference, all |
|
datatype arg |
The datatype and name of the arguments for the stored |
|
RPCFUNC |
A keyword indicating that this declaration is for a |
|
ALIAS FOR “spname” (optional) |
Keywords followed by a string naming the procedure in |
Usage
If a function does not return a value (for example, it returns
Void), specify the declaration as a subroutine instead of a
function.
RPC declarations are always associated with a transaction object.
You declare them as local external functions. The Declare Local External
Functions dialog box has a Procedures button (if the connected database
supports stored procedures), which gives you access to a list of stored
procedures in the database.
For more information, see the section called “Using
Transaction objects to call stored procedures” in Application Techniques.
Examples
Example 1
This declaration of the GIVE_RAISE_PROC stored procedure is declared
in the User Object painter for a transaction object (the declaration
appears on one line):
|
1 |
FUNCTION double GIVE_RAISE(ref double SALARY) RPCFUNC ALIAS FOR "GIVE_RAISE_PROC" |
This code calls the function in a script:
|
1 2 3 |
double val = 20000 double rv rv = SQLCA.give_raise(val) |
Example 2
This declaration for the stored procedure SPM8 does not need an
ALIAS FOR phrase, because the PowerBuilder and DBMS names are the
same:
|
1 |
FUNCTION integer SPM8(integer value) RPCFUNC |
This code calls the SPM8 stored procedure:
|
1 2 3 4 5 |
int myresult myresult = SQLCA.spm8(myresult) IF SQLCA.sqlcode <> 0 THEN messagebox("Error", SQLCA.sqlerrtext) END IF |