Result - Maple Programming Help

Home : Support : Online Help : Connectivity : Database Package : Result : Database/Result/ToMaple

Result

 ToMaple
 convert a result module into a Maple object

 Calling Sequence result:-ToMaple( opt )

Parameters

 result - Result module opt - (optional) equation of the form output=boolean

Description

 • ToMaple converts result into a Maple representation.
 • Which type ToMaple converts result into is determined by its optional parameter.
 output = table, Array, or browser
 – For output=table, ToMaple returns the data as a two-dimensional Maple table.  The table is indexed first by the row number and second by the column name.  In the case that the result contains columns with the same name, the repeated column names will have their column index appended to their name, separated by a space.
 – For output=Array, ToMaple returns the data as a two-dimensional Array.
 – For output=browser, a Maplet application starts to display the data.
 The default value is output=table.
 • ToMaple moves only the row cursor toward the last row in the table. Therefore if the row cursor is not on the first (or before first) row, some rows in the result will not be converted.  To make sure that all the rows of result are included, position the row cursor at the first row by calling First.
 • Some care must be taken when calling ToMaple with a Result module containing large elements or a very large number of elements.  It may require a large amount of memory to store the data.

Examples

Create a Result.

 > $\mathrm{driver}≔\mathrm{Database}[\mathrm{LoadDriver}]\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,number FROM animals WHERE id BETWEEN 3 AND 7"\right):$

By default it converts to a table.

 > $\mathrm{res}:-\mathrm{ToMaple}\left(\right)$
 ${\mathrm{table}}{}\left(\left[\left({2}{,}{"name"}\right){=}{"rat"}{,}\left({5}{,}{"number"}\right){=}{5}{,}\left({3}{,}{"number"}\right){=}{3}{,}\left({3}{,}{"name"}\right){=}{"horse"}{,}\left({1}{,}{"number"}\right){=}{10}{,}\left({5}{,}{"name"}\right){=}{"lizard"}{,}\left({1}{,}{"name"}\right){=}{"cat"}{,}\left({4}{,}{"number"}\right){=}{1}{,}\left({2}{,}{"number"}\right){=}{50}{,}\left({4}{,}{"name"}\right){=}{"snake"}\right]\right)$ (1)

Move the cursor to the beginning of the result table.

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

Now convert to an Array.

 > $\mathrm{res}:-\mathrm{ToMaple}\left(\mathrm{output}='\mathrm{Array}'\right)$
 $\left[\begin{array}{cc}{"cat"}& {10}\\ {"rat"}& {50}\\ {"horse"}& {3}\\ {"snake"}& {1}\\ {"lizard"}& {5}\end{array}\right]$ (3)

This time, move to the third row.

 > $\mathrm{res}:-\mathrm{GotoRow}\left(3\right)$
 ${\mathrm{true}}$ (4)

Convert the remainder of the table to an Array.

 > $\mathrm{res}:-\mathrm{ToMaple}\left(\mathrm{output}='\mathrm{Array}'\right)$
 $\left[\begin{array}{cc}{"horse"}& {3}\\ {"snake"}& {1}\\ {"lizard"}& {5}\end{array}\right]$ (5)