5: Multiple Resultsets
<< Click to Display Table of Contents >> 5: Multiple Resultsets |
![]() ![]() ![]() |
In the following sample the command object returns mulitple result sets:
FUNCTION Start
LOCAL oRs AS AdoRecordSet
LOCAL oConn AS AdoConnection
LOCAL oCmd AS AdoCOmmand
oConn := OpenConnection()
oCmd := AdoCommand{}
oCmd:ActiveConnection := oConn
oCmd:CommandText := "Select emp_id, lname, fname from employee;" + ; "
Select pub_id, pub_name from Publishers"
oCmd:CommandType := AdCmdText
oRs := oCmd:Execute(NIL, NIL,NIL)
? "Simple stored procedure with 2 result sets"
? "First resultset"
?
ShowResults(oRs)
oRs := oRs:NextRecordset(NIL)
IF oRs != NULL_OBJECT
? "Second resultset"
?
ShowResults(oRs)
ELSE
? "No second resultset"
ENDIF
wait
FUNCTION ShowResults(oRs AS AdoRecordSet) AS VOID PASCAL
LOCAL i AS DWORD
LOCAL nRec AS DWORD
DO WHILE ! oRs:EOF .and. ++nRec < 10
FOR i := 1 TO oRs:Fields:Count
?? oRs:FieldGet(i),""
NEXT
?
oRs:MoveNext()
ENDDO