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 |
<span>object</span>.<span>function</span> |
You can call database procedures in Sybase, 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 |
FUNCTION <span>rtndatatype</span> <span>functionname</span> ( { { REF } <span>datatype1</span> <span>arg1</span>,...,<br> { REF } <span>datatypen</span> <span>argn</span> } ) RPCFUNC { ALIAS FOR "<span>spname</span>" } |
|
1 |
SUBROUTINE <span>functionname</span> ( { { REF } <span>datatype1</span> <span>arg1</span> , ..., <br> { REF } <span>datatypen</span> <span>argn</span> } ) RPCFUNC { ALIAS FOR "<span>spname</span>" } |
|
Argument |
Description |
|---|---|
|
FUNCTION or SUBROUTINE |
A keyword specifying the type of call, |
|
rtndatatype |
In a FUNCTION declaration, |
|
functionname |
The name of the database procedure as |
|
REF |
Specifies that you are passing by reference When you pass a string by reference, all memory management is |
|
datatype arg |
The datatype and name of the arguments |
|
RPCFUNC |
A keyword indicating that this declaration |
|
ALIAS FOR “spname” (optional) |
Keywords followed by a string naming |
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 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 |
double val = 20000 |
|
1 |
double rv |
|
1 |
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 |
int myresult |
|
1 |
myresult = SQLCA.spm8(myresult) |
|
1 |
IF SQLCA.sqlcode <> 0 THEN |
|
1 |
messagebox("Error", SQLCA.sqlerrtext) |
|
1 |
END IF |