Programming Guide |
Map column names into Panther variables using a
SELECT
statement
DBMS [WITH CURSORcursor
] COLUMN_NAMES [pantherVar
[,pantherVar
...] ]
pantherVar
- Name of Panther variable to contain the column name.
WITH CURSOR
cursor
- Name of declared
SELECT
cursor. If the clause is not used, Panther uses the defaultSELECT
cursor.
DBMS
COLUMN_NAMES
fetches the column names, not the column data, into Panther variables when aSELECT
statement is executed.The correspondence between the Panther variable and the column is positional. The first Panther variable named in the
DBMS
COLUMN_NAMES
command will contain the name of the first column listed in theSELECT
statement. If the number of Panther variables is greater than the number of columns, the remaining Panther variables are ignored. If the number of columns is greater than the number of Panther variables, the remaining columns are ignored.If the
SELECT
statement includes data which is not a column, like an aggregate function, then the value written to the Panther variable is whatever is returned from the database engine.A Panther variable can be a widget or JPL variable. If the variable is an array or multi-occurrence widget, the column name appears in the first occurrence unless a particular occurrence is specified.
Only one
DBMS
COLUMN_NAMES
statement is allowed for each cursor. The lastDBMS
COLUMN_NAMES
statement called is the one currently in effect.Column name aliasing for a cursor is turned off by executing the
DBMS
COLUMN_NAMES
command with no arguments. Closing a cursor also turns it off. If a cursor is redeclared without being closed, the cursor keeps the aliases.
// Assign column name aliases for a declared cursor.
// The column names are written to id_title, copy_title
// and status_title.
// The data is written is title_id, copy_num and status.DBMS DECLARE x CURSOR FOR \
SELECT title_id, copy_num, status FROM tapes
DBMS WITH CURSOR x COLUMN_NAMES \
id_title, copy_title, status_title
DBMS WITH CURSOR x EXECUTE
DBMS WITH CURSOR x COLUMN_NAMES// Assign column name aliases for the default cursorDBMS COLUMN_NAMES id_title, copy_title, status_title
DBMS QUERY SELECT title_id, copy_num, status \
FROM tapes
DBMS COLUMN_NAMES