NextResult - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

PreparedStatement

 NextResult
 retrieve the next result of a multiple statement execute

 Calling Sequence preparedstat:-NextResult( )

Parameters

 preparedstat - PreparedStatement module

Description

 • NextResult tries to retrieve the next result from preparedstat. If there are no results available, it returns NULL.
 • If a result is available, it will be an integer corresponding to an update statement, or a Result module corresponding to a query statement.
 • To issue a multi-statement SQL string, the Execute command must be used.
 • Some databases may require the processing of the current result be completed before the next result is returned by NextResult.

Examples

 > $\mathrm{driver}≔{\mathrm{Database}}_{\mathrm{LoadDriver}}\left(\right):$
 > $\mathrm{conn}≔\mathrm{driver}:-\mathrm{OpenConnection}\left(\mathrm{url},\mathrm{name},\mathrm{pass}\right):$$\mathrm{pstat}≔\mathrm{conn}:-\mathrm{CreatePreparedStatement}\left("SELECT name FROM animals WHERE id = ?; INSERT INTO animals\left( id, name, number, mass \right) VALUES\left( ?, ?, ?, ? \right); SELECT name FROM animals WHERE id = ?;"\right):$

Execute pstat.

 > $\mathrm{res}≔\mathrm{pstat}:-\mathrm{Execute}\left(1,14,"boar",10,60.67,3\right)$

Check the value.

 > $\mathrm{res}:-\mathrm{Next}\left(\right);$$\mathrm{res}:-\mathrm{GetData}\left("name"\right)$
 ${"fish"}$ (1)

Get the next result.

 > $\mathrm{pstat}:-\mathrm{NextResult}\left(\right)$
 ${1}$ (2)

Now the last result

 > $\mathrm{res}≔\mathrm{pstat}:-\mathrm{NextResult}\left(\right):$$\mathrm{res}:-\mathrm{Next}\left(\right):$$\mathrm{res}:-\mathrm{GetData}\left("name"\right)$
 ${"cat"}$ (3)

Check for more results.

 > $\mathrm{stat}:-\mathrm{NextResult}\left(\right)$

NULL returned, no more results in this PreparedStatement module.