Succeeds if there is another result set, and positions the cursor at the
first row of the new result set. If there are no more result sets, the
predicate fails.
fetch(Options) :-
odbc_prepare(test,
'select (testval) from test; select (anotherval)
from some_other_table',
[],
Statement,
[ fetch(fetch)
]),
odbc_execute(Statement, []),
fetch(Statement, Options).
fetch(Statement, Options) :-
odbc_fetch(Statement, Row, Options),
( Row == end_of_file
-> ( odbc_next_result_set(Statement)
-> writeln(next_result_set),
fetch(Statement, Options)
; true
)
; writeln(Row),
fetch(Statement, Options)
).