 First - Maple Help

Result

 First
 move the cursor to the first row Calling Sequence result:-First( opts ) Parameters

 result - Result module 'opts - (optional) equation of the form before=boolean Description

 • First moves the row cursor maintained within result to the first row of the table.
 • First accepts one optional argument.
 before = boolean
 If before is true, then the row cursor is moved to the row before the first row containing data, that is, the same location as when a Result module is created.
 • First returns true if the new row indicated by the cursor is a row containing data.  When called with before=true, First always returns false. Examples

Create a Result.

 > $\mathrm{driver}≔\mathrm{Database}\left[\mathrm{LoadDriver}\right]\left(\right):$
 > $\mathrm{conn}≔\mathrm{driver}:-\mathrm{OpenConnection}\left(\mathrm{url},\mathrm{name},\mathrm{pass}\right):$$\mathrm{res}≔\mathrm{conn}:-\mathrm{ExecuteQuery}\left("SELECT name FROM animals"\right):$

Move the row cursor.

 > $\mathbf{while}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathrm{res}:-\mathrm{Next}\left(\right)\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\phantom{\rule[-0.0ex]{2.0em}{0.0ex}}\mathrm{res}:-\mathrm{GetData}\left(1\right)\phantom{\rule[-0.0ex]{0.0em}{0.0ex}}\mathbf{end}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{do}:$

Now call First.

 > $\mathrm{res}:-\mathrm{First}\left(\right)$
 ${\mathrm{true}}$ (1)

First returned true so it is valid to read data from this row.

 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"fish"}$ (2)
 > $\mathrm{res}:-\mathrm{First}\left(\mathrm{before}=\mathrm{true}\right)$
 ${\mathrm{false}}$ (3)
 > $\mathrm{res}:-\mathrm{Next}\left(\right)$
 ${\mathrm{true}}$ (4)
 > $\mathrm{res}:-\mathrm{GetData}\left(1\right)$
 ${"fish"}$ (5)