SQL Programming Manual for Pascal
NonStop SQL Statements and Directives
HP NonStop SQL Programming Manual for Pascal—528614-001
3-23
INVOKE Guidelines
•
If no record name is supplied, the compiler adds the _TYPE suffix to the
unqualified table or view name and returns it as a type definition. Your program
must then declare a variable of this type. For example, assume a program gives
the following INVOKE statement for table PARTS:
EXEC SQL INVOKE PARTS;
The compiler generates:
TYPE
PARTS_TYPE = RECORD
PARTNUM : CARDINAL;
PARTDESC : FSTRING(18);
PRICE : INT32; { SCALE IS 2 }
QTY_AVAILABLE : INT32;
END;
Your program must then declare a variable of type PARTS_TYPE:
VAR PARTS_REC : PARTS_TYPE;
Pascal does not support scale factors. When you invoke a column with a scaled type,
the compiler generates a comment that gives the scale of the column being declared.
For example, if PRICE with data type NUMERIC (8,2) is invoked in Pascal, INVOKE
generates the following:
PRICE : INT32; { SCALE IS 2 }
To communicate a scale factor to SQL, use the SETSCALE built-in function, described
in Section 4, NonStop SQL System Procedures.
Examples
The following examples show name and data type correspondence between an SQL
table and a Pascal record description.
In the following example, an INVOKE statement declares table CUSTOMER as TYPE
declaration CUST_TYPE within a Declare Section. This example includes the source
text and the generated output.
Source code in Pascal program:
EXEC SQL BEGIN DECLARE SECTION ;
EXEC SQL INVOKE $VOL1.SALES.CUSTOMER AS CUST_TYPE;
EXEC SQL END DECLARE SECTION ;
Generated record description in Pascal:
{* Record Definition for \SYS1.$VOL1.SALES.CUSTOMER *}
{* Definition current at 13:54:52 - 11/12/91 *}
TYPE
CUST_TYPE = RECORD
CUSTNUM : INT16;
CUSTNAME : FSTRING(18);
STREET : FSTRING(22);