Connection - Maple Programming Help

Home : Support : Online Help : Connectivity : Database Package : Connection : Database/Connection/GetColumns

Connection

 GetColumns
 get a list of columns from the database

 Calling Sequence connection:-GetColumns( opts )

Parameters

 connection - Connection module opts - (optional) equation(s) of the form option=value where option is one of catalog, schema, table, column, or output

Description

 • GetColumns returns an Array in which each row contains one column from the database connected to using connection.  A column in the Array is data associated with the column.  The output option controls the columns and their order in the returned Array.
 • The opts argument can contain one or more of the following equations.
 output = list containing one or more of the literal symbols: name, catalog, schema, table, and type
 The output option specifies the columns of information to return and their order. By default, only the name is returned. Some databases do not support all these fields.
 - name returns the name of the column.
 - catalog returns the name of the catalog that contains the table.
 - schema returns the name of the schema used in the table.
 - table returns the name of the table that contains the column.
 - type returns the SQL type of the column.
 catalog = string
 Return only columns from the specified catalog. To return columns from tables not in a catalog, specify the empty string ("").  By default, no restrictions are applied.
 schema = string
 Return only columns from databases in which the schema matches the specified pattern. The pattern can consist of any valid schema name characters and the special characters % and _. A % matches any string and an _ matches any character. To match a literal _ or %, you must prepend the escape character \.  For example, to match a _, use \_. To return columns from databases that do not use a schema, specify the empty string ("").  By default, no restrictions are applied.
 table = string
 Return only columns for which the table matches the specified pattern. The pattern can consist of any valid table name characters and the special characters % and _. A % matches any string and an _ matches any character. To match a literal _ or %, you must prepend the escape character \.  For example, to match a _, use \_. By default, no restrictions are applied.
 column = string
 Return only columns for which the name matches the specified pattern. The pattern can consist of any valid table name characters and the special characters % and _. A % matches any string and an _ matches any character. To match a literal _ or %, you must prepend the escape character \.  For example, to match a _, use \_. By default, no restrictions are applied.

Examples

 > $\mathrm{driver}≔\mathrm{Database}[\mathrm{LoadDriver}]\left(\right):$
 > $\mathrm{conn}≔\mathrm{driver}:-\mathrm{OpenConnection}\left(\mathrm{url},\mathrm{name},\mathrm{pass}\right):$
 > $\mathrm{conn}:-\mathrm{GetColumns}\left('\mathrm{output}'=\left['\mathrm{table}','\mathrm{name}'\right]\right)$
 $\left[\begin{array}{cc}{"Table1"}& {"size"}\\ {"Table1"}& {"number"}\\ {"Table2"}& {"mass"}\\ {"Table2"}& {"density"}\\ {"Table3"}& {"distance"}\end{array}\right]$ (1)
 > $\mathrm{conn}:-\mathrm{GetColumns}\left('\mathrm{table}'="Table1",'\mathrm{output}'=\left['\mathrm{name}'\right]\right)$
 $\left[\begin{array}{c}{"size"}\\ {"number"}\end{array}\right]$ (2)
 > $\mathrm{conn}:-\mathrm{GetColumns}\left('\mathrm{column}'="%a%",'\mathrm{output}'=\left['\mathrm{name}','\mathrm{table}','\mathrm{type}'\right]\right)$
 $\left[\begin{array}{ccc}{"mass"}& {"Table1"}& {"DOUBLE"}\\ {"distance"}& {"Table3"}& {"DOUBLE"}\end{array}\right]$ (3)