• Places
    • Home
    • Graphs
    • Prefixes
  • Admin
    • Users
    • Settings
    • Plugins
    • Statistics
  • Repository
    • Load local file
    • Load from HTTP
    • Load from library
    • Remove triples
    • Clear repository
    • RDF quality heuristics
  • Query
    • YASGUI SPARQL Editor
    • Simple Form
    • SWISH Prolog shell
  • Help
    • Documentation
    • Tutorial
    • Roadmap
    • HTTP Services
  • Login

2.3.4 Fetching data from multiple result sets
AllApplicationManualNameSummaryHelp

  • Documentation
    • Reference manual
    • Packages
      • SWI-Prolog ODBC Interface
        • The ODBC layer
          • Running SQL queries
            • Fetching data from multiple result sets
              • odbc_next_result_set/1
Availability::- use_module(library(odbc)).(can be autoloaded)
odbc_next_result_set(+Statement)
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)
        ).

ClioPatria (version V3.1.1-40-g9d9e003)