Anasql

Anasql is used to parse a SQL sentence and return in an integer array the number and the types of values that are returned by the SQL sentence.

Syntax

Anasql From DATABASE Sql SENTENCE Using TYPE_ARRAY

The data type value is the one returned by the type function.

Example

# Returns the number of columns of a table and their typeSubprog DESCRIBE_TABLE(TABLE_NAME,COLUMN_COUNT, COLUMN_TYPES)Value Char TABLE_NAME()Variable Integer COLUMN_COUNT, COLUMN_TYPES(1..)# My current database can be known by a general parameter (1=oracle, 2=SQL server)Local Char CURRENT_DATABASECURRENT_DATABASE=num$(1+2*Fmet GACTX.APARAM.AGETVALNUM([V]CST_ALEVFOLD,"","TYPDBA"))Local Integer RETURN_VALUES(0..dim(COLUMN_TYPES)), I# What are the different columns type present in the table given as parameter?Anasql From CURRENT_DATABASE Sql "select * From "+TABLE_NAME Using RETURN_VALUES# Set the return valuesFor I=1 To RETURN_VALUES(0)COLUMN_TYPES(I)=RETURN_VALUES(I)Next ICOLUMN_COUNT=RETURN_VALUES(0)End

See also

Sql, ExecSql, type.