SQL_EXEC_PROC handleIdent_Int, retCodeIdent_Int, stringExpr BIND _locVar1, _locVar2, ... SQL_EXEC_PROC handleIdent_Int, retCodeIdent_Int, stringExpr BIND _locVarRowIdent SQL_EXEC_PROC handleIdent_Int, retCodeIdent_Int, stringExpr BIND _locVarRecordIdent |
| handleIdent_Int | in | Identifier of the Int type - unique number (handle) of a connection to database. |
| retCodeIdent_Int | out | Identifier of the Int type - return code. |
| strExpr | in | Expression of the Text type - SQL procedure or function. |
| _locVar1, _locVar2, ... | in/out | Local variables. |
| _locVarRowIdent | in/out | Reference to a row of local variable of the Record type. |
| _locVarRecordIdent | in/out | Identifier of local variable of the Record type. |
"{ call TEST_PROC(IN ?, INOUT?, OUT?) }"
"TEST_PROC(IN :par1, INOUT :par2, OUT :par3)"
|
1. ODBC version of the process D2000 DBManager
Example: Creating stored procedures in SQL Anywhere:
/* par1 is input/output parameter, par2 is input one and par3 is output parameter */
create procedure TEST_PROC(@par1 varchar(10) output, @par2 integer,@par3 integer output)
as
declare @vysl integer
begin
select @par=@par+'XYZ'
select @par3=2*@par2
end
/* example of function with two parameters (Sybase supports just input function parameters) */
create function TEST_FUNC(in @par1 real,in @par2 integer)
returns real as
begin
return(@par1*@par2)
end
Calls from script:
BEGIN
INT _myInt
INT _iRetCode
INT _iHandle
TEXT _myText
REAL _myReal
INT _myInt1
INT _myInt2
_myText := "ABC"
_myInt1 := 10
SQL_CONNECT MyDB, _iHandle, _iRetCode
; procedure call
SQL_EXEC_PROC _iHandle, _iRetCode, "{ call TEST_PROC(?,?,?) }" BIND _myText, _myInt1, _myInt2
;_value of myText is "ABCXYZ" and value of _myInt2 is 20 (2 * 10)
; call of procedure with a constant
SQL_EXEC_PROC _iHandle, _iRetCode, "{ call TEST_PROC(?,3,?) }" BIND _myText, _myInt1
; value of _myText is "ABCXYZXYZ" and value of _myInt2 is 6 (2 * 3)
; function call
SQL_EXEC_PROC _iHandle, _iRetCode, "{ ? = call TEST_FUNC(?,?) }" BIND _myReal, _myInt1, _myInt2
; value of _myReal is 60 (10 * 6)
; call of function with a constant
SQL_EXEC_PROC _iHandle, _iRetCode, "{ ? = call TEST_FUNC(?,3.3) }" BIND _myReal, _myInt1
; value of _myReal is 33 (10 * 3.3) |
2. OCI version of the process D2000 DBManager
Example: creating stored procedures in Oracle 9i:
/* par1 is input/output parameter, par2 is input and par3 is output parameter */
CREATE OR REPLACE PROCEDURE "MYUSER"."TEST_PROC" (
par1 in out varchar,par2 integer, par3 out integer
)
as
begin
par1 := par1 || 'XYZ';
par3 := 2 * par2;
end;
/* par1,par2 are input parameters, succ is output one */
CREATE OR REPLACE FUNCTION "MYUSER"."TEST_FUNC" (
par1 in float, par2 in float, succ out integer
)
return float
as
begin
if par2 = 0.0 then
succ := 0;
return 0;
else
succ := 1;
return par1/par2;
end if;
end;
Calls from script:
BEGIN INT _myInt INT _iRetCode INT _iHandle TEXT _myText REAL _myReal INT _myInt1 INT _myInt2 INT _Succ _myText := "ABC" _myInt1 := 10 SQL_CONNECT MyDB, _iHandle, _iRetCode ; procedure call SQL_EXEC_PROC _iHandle, _iRetCode, "TEST_PROC(:p1,:p2,:p3)" BIND _myText, _myInt1, _myInt2 ;value of _myText is "ABCXYZ" and value of _myInt2 is 20 (2 * 10) ; function call SQL_EXEC_PROC _iHandle, _iRetCode, ":ret := TEST_FUNC(:par1,:par2,:par3)" BIND _myReal, _myInt1, _myInt2, _Succ ; value of _myReal is 0.5 (10 / 20) and value of _Succ is 1 |