DBA > Job Interview Questions > Sybase Interview Questions and Answers

How to feed the result set of one stored procedu

More DBA job interview questions and answers at http://dba.fyicenter.com/Interview-Questions/

(Continued from previous question...)

How to feed the result set of one stored procedure into another in Sybase ?

So, the scenario is that you have a stored procedure, AP_A, and you wish to use the result set that it returns in a query.

Create a proxy table for SP_A.

create table proxy_SP_A (
a int,
b int,
c int,
_p1 int null,
_p2 int null
) external procedure
at "SELF.dbname.dbo.SP_A"

Columns a, b, c correspond to the result set of SP_A. Columns _p1, _p2 correspond to the @p1, @p2 parameters of SP_A. "SELF" is an alias put in sysservers to refer back to the local server.

If you only have one row returned the proxy table can be used with the following:
declare @a int, @b int, @c int
select @a = a, @b = b, @c = c from proxy_SP_B
where _p1 = 3 and _p2 = 5

More rows can be handled with a cursor.

(Continued on next question...)

Other Job Interview Questions