Programming Guide



COLUMN_NAMES

Map column names into Prolifics variables using a SQL SELECT statement

Synopsis

DBMS [ WITH CURSOR cursor ] COLUMN_NAMES [ prolVar [, prolVar ... ] ]

Arguments

prolVar
Name of Prolifics variable to contain the column name.

WITH CURSOR cursor
Name of declared SELECT cursor. If the clause is not used, Prolifics uses the default SELECT cursor.

Description

DBMS COLUMN_NAMES fetches the column names, not the column data, into Prolifics variables when a SQL SELECT statement is executed.

The correspondence between the Prolifics variable and the column is positional. The first Prolifics variable named in the DBMS COLUMN_NAMES command will contain the name of the first column listed in the SQL SELECT statement. If the number of Prolifics variables is greater than the number of columns, the remaining Prolifics variables are ignored. If the number of columns is greater than the number of Prolifics variables, the remaining columns are ignored.

If the SQL SELECT statement includes data which is not a column, like an aggregate function, then the value written to the Prolifics variable is whatever is returned from the database engine.

A Prolifics 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 last DBMS 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.

Example

// 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 cursor
DBMS COLUMN_NAMES id_title, copy_title, status_title
DBMS SQL SELECT title_id, copy_num, status \
FROM tapes
DBMS COLUMN_NAMES