OLE DB
FETCH
To access rows returned in a result set, use the FETCH statement the
same way you use it for cursors. The FETCH statement can be executed after
any successful EXECUTE statement for a procedure that returns a result
set.
Example
|
1 |
FETCH emp_proc INTO :emp_name_var; |
Using FETCH after EXECUTE
Following an EXECUTE statement for a procedure, you can use the
FETCH statement only to access values produced by the SELECT statement
in the database stored procedure.
Since PowerBuilder cannot determine at compile time what result
set will be returned when a database stored procedure executes, you must
code FETCH statements so that the stored procedure exactly matches the
format of the result set during execution. Assume you coded the second
FETCH statement in the example above as:
|
1 |
FETCH emp_proc INTO :var1, :var2, :var3; |
The statement compiles without errors. However, you will get an
execution error indicating that the number of columns in the FETCH
statement does not match the number of columns in the result set.
See also