Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

how to call spored procedures with output parameters

2 views
Skip to first unread message

Adam Polech

unread,
Feb 21, 2001, 9:06:27 AM2/21/01
to
Hi all.
I use PB7 and ASA 6.0.
My stored procedure is folowing:
/////////////////
create procedure
dba.AD_DodajDokHan(@idt integer,@data_w date,@idh integer output)
as
begin
insert into dokumenthandlowy(id_typu,data_wystawienia)
values(@idt,@data_w)
select @idh=@@identity
end
//////////////
Table dokumenthandlowy has a autoincrement column.
I try to call this procedure from PB script :
/////////////
long l_idtypu,l_idh
date data_w
l_idtypu=1
l_idh=0
data_w=today()
DECLARE dodajdok PROCEDURE FOR dba.AD_DodajDokHan
@idt = :l_idtypu,
@data_w = :data_w,
OUTPUT @idh = :l_idh;
EXECUTE dodajdok;
////////////
Value of l_idh variable is 0. Why?
Have I to do something specialy more?

Any tips would be appreciate.

Adam.

steve_katz_[teamsybase]

unread,
Feb 22, 2001, 8:44:49 AM2/22/01
to
Whenever a stored proc has output and/or a return value and no result set,
the easiest way to get the output and/or return value is to declare an RPC
on an object of type transaction.

The return value is the return value of the RPC call. The output
parameters must be declared in the RPC as being passed by reference. If
any of the output parameters are strings, you must preallocate space for
them equal to the longest length the output parm could be.

You could do it via embedded SQL keeping in mind that the return value and
all output parms are returned in a second result set. So, after executing
the sp and fetching until SQLCode = 100 (if there is no result set, this
should be the return value after the sp execution), then issue one more
fetch to get the return value and output parms in that order.

HTH,

steve

0 new messages