Result - Maple Programming Help

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

Result

 GetType
 get the SQL type of a column

 Calling Sequence result:-GetType( index )

Parameters

 result - Result module index - integer or string; the column for which the type is returned

Description

 • GetType returns the SQL type of the column indicated by index.
 • If index is an integer, it is used to index into the current Result module's table.  If index is a string, it is the name of the column.
 • The type returned by GetType can be used in an explicit cast to make Maple perform a particular type conversion.  For more information, see conversions.

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 FROM animals"\right):$$\mathrm{res}:-\mathrm{GetType}\left(1\right)$
 ${\mathrm{INTEGER}}$ (1)
 > $\mathrm{res}:-\mathrm{GetType}\left(2\right)$
 ${\mathrm{VARCHAR}}$ (2)
 > $\mathrm{res}:-\mathrm{GetType}\left(3\right)$
 ${\mathrm{INTEGER}}$ (3)
 > $\mathrm{res}:-\mathrm{GetType}\left(4\right)$
 ${\mathrm{DOUBLE}}$ (4)
 > $\mathrm{res}:-\mathrm{GetType}\left("id"\right)$
 ${\mathrm{INTEGER}}$ (5)
 > $\mathrm{res}:-\mathrm{GetType}\left("name"\right)$
 ${\mathrm{VARCHAR}}$ (6)
 > $\mathrm{res}:-\mathrm{GetType}\left("number"\right)$
 ${\mathrm{INTEGER}}$ (7)
 > $\mathrm{res}:-\mathrm{GetType}\left("mass"\right)$
 ${\mathrm{DOUBLE}}$ (8)