HP 3000 Manuals

Programming with Dynamic Parameters [ ALLBASE/SQL Advanced Application Programming Guide ] MPE/iX 5.0 Documentation


ALLBASE/SQL Advanced Application Programming Guide

Programming with Dynamic Parameters 

Depending on the purpose of your application, there is a broad spectrum
of scenarios in which dynamic parameters could be useful.  You might know
almost all the elements of a statement at coding time, including the
statement type and what dynamic parameters are required.  At the opposite
extreme, a program might be required to handle a completely unknown SQL
statement containing dynamic parameters.  Generally speaking, the less
you know about a dynamic statement at coding time, the more coding you
must do to verify the statement's content at run time.

The two basic methods of assigning dynamic parameter values involve use
of either host variables or ALLBASE/SQL data structures and a data
buffer.  To use host variables, you must at least know the exact format
of your SQL statement, although you need not know the specific data
values of dynamic parameters.  To use data structures and a data buffer,
you do not need to know the exact format of your SQL statement.

          Table 4-2.  Dynamic Parameter Functionality by Programming Language 

-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|       Language        |   Dynamic Parameter   |   Dynamic Parameter   |  Dynamic Parameters   |
|                       |    Data Assignment    |    Data Assignment    |   in a BULK INSERT    |
|                       |  via Host Variables   |   via a Data Buffer   |       Statement       |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|           C           |          yes          |          yes          |          yes          |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|         COBOL         |          yes          |          no           |    yes (with host     |
|                       |                       |                       |      variables)       |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|        FORTRAN        |          yes          |          no           |          no           |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------
|                       |                       |                       |                       |
|        Pascal         |          yes          |          yes          |          yes          |
|                       |                       |                       |                       |
-------------------------------------------------------------------------------------------------

Host variables are available for C, COBOL, FORTRAN, and Pascal
applications.  Data buffers are available for C and Pascal applications
only.  In addition, dynamic parameters within a BULK INSERT statement
require special syntax and are discussed separately.  BULK INSERT
functionality is available for C, COBOL, and Pascal applications.  The
following subsections discuss each basic coding method:

   *   Using Host Variables to Process Dynamic Parameters.
   *   Using Data Structures and a Data Buffer to Process Dynamic
       Parameters
   *   Using a BULK INSERT Statement with Dynamic Parameters.

Using Host Variables to Process Dynamic Parameters 

When you know at coding time the data type and format of each dynamic
parameter in a dynamic statement, you have the choice of using either a
host variable or a data buffer to provide dynamic parameter input at run
time.  This section details the use of host variables with non-bulk
statements.  (The next section discusses the data buffer technique.)  The
functionality described in this section is available for C, COBOL,
FORTRAN, and Pascal programs.

Suppose you are coding an interactive user application.  It involves
mapping a user's menu choice to a partially known statement, then
prompting for and accepting dynamic parameter values for data whose
format is known at coding time.  The following pseudocode illustrates
this scenario.

     :
     Accept a variable indicating which of a set of statements the user has chosen. 

     Prepare the dynamic command for this statement: 

      PREPARE CMD FROM 'UPDATE PurchDB.Parts SET SalesPrice = ? WHERE PartNumber = ?;' 

     Prompt the user for values for the SalesPrice and PartNumber columns. 

     Execute the dynamic command using host variables to provide dynamic parameter
     values: 

      EXECUTE CMD USING :SalesPrice, :PartNumber; 

     You could now loop back to prompt the user for additional values for SalesPrice 
     and PartNumber.  Note that the dynamic command does not have to be prepared again. 

Using Data Structures and a Data Buffer to Process Dynamic Parameters 

If at coding time you don't know the data types of all dynamic parameters
in the prepared statement, you must use two ALLBASE/SQL data structures
and a data buffer to obtain the default data types and pass dynamic
parameter input to the database.  These data structures are the same as
those used for dynamic output processing:

   *   sqlda_type data structure.
   *   sqlfmts_type data structure.
   *   data buffer.

The following discussion points out how to use these structures for input
data.  Here the term input data means dynamic parameter data, and output 
data means select list data.  When a prepared statement is described for
both input and output data, you must define one set of data structures
for input data and another set for output data.  Refer to the chapter
"Using Dynamic Operations" in the ALLBASE/SQL C Application Programming 
Guide or the ALLBASE/SQL Pascal Application Programming Guide for a
detailed description and example of how to use dynamic data structures
for output.

Using the SQLDA for Input.   

To use an SQLDA structure for input, you prepare the dynamic command,
then use the INPUT option with the DESCRIBE statement:

     DESCRIBE INPUT DynamicCommand INTO SQLDA

In place of SQLDA, you could name any data structure of type sqlda_type.

When the DESCRIBE statement executes, whether for input data or output
data, the values in a given format array must be consistent with the
values in its related data buffer.  Refer to Table 4-6  and Table 4-7
 for a detailed description of the format array.

One difference between the use of
the SQLDA for input data versus output data involves the Sqln and Sqld
fields.  Sqln is set by your program prior to issuing the DESCRIBE
statement and represents the maximum number of 48 byte format array
records allowed by the program.  When using the DESCRIBE OUTPUT
specification, you tell ALLBASE/SQL to load each format record with
information for each select list item in the currently prepared statement
(if it is a query).  Using the DESCRIBE INPUT specification indicates
that you want ALLBASE/SQL to load each format array record with
information for each dynamic parameter in the currently prepared
statement.  Therefore, following execution of the DESCRIBE statement,
Sqld represents either the number of select list items output or the
number of dynamic parameters input.

When you describe dynamic parameters for input, the Sqlindlen field in
the format array always equals two, even if it relates to a table column
that does not allow nulls.  Therefore, you must allow two bytes for this
field in the corresponding input data buffer.  By contrast, when you
describe output for a column that was defined as not null, the Sqlindlen
field is set to 0 to indicate no bytes are allocated in the corresponding
data buffer for information relating to null values.


CAUTION ALLBASE/SQL reads the data buffer based on its related format array. When you have described input, be sure the data you load into the data buffer corresponds to the information in its related format array.
Using the Data Buffer for Input. When you are describing data for input, it is your program's responsibility to load the data buffer with input values for each dynamic parameter based on information in the related format array. (This is unlike describing data for output, where ALLBASE/SQL loads the specified data buffer when data is fetched.) Following is a list of possible coding steps: 1. Define any host variables to be used to pass a command string to ALLBASE/SQL via the PREPARE and DESCRIBE statements. 2. Define any necessary sqlda_type structures (also called descriptor areas) for holding information about a given command string. Sqlda_type structures are used to communicate information regarding a specific SQL statement between this program and the database to which it is connected. Information is transferred when the DESCRIBE statement executes and when the FETCH statement executes. Remember that the INCLUDE SQLDA statement generates one sqlda_type data structure named sqlda. So, if you need more than one such structure, you must code a declaration for each. If you know nothing about an SQL statement until run time, define an sqlda_type structure for output to determine if the statement is a query or not. If it is a query, ALLBASE/SQL loads the related sqlformat_type structure with the format of the query result (one 48 byte element per select list item). You must also define an sqlda_type structure for input in case the statement contains dynamic parameters. In this case, ALLBASE/SQL loads the related sqlformat_type structure with the format of the dynamic parameters (one 48 byte element per dynamic parameter). 3. Define an sqlformat_type structure (also called a format array) for each required data buffer. Information is transferred to the format array when the DESCRIBE statement executes. 4. Define any necessary data buffers. Each data buffer must correspond to an sqlda_type structure and an sqlformat_type structure. If the statement is a query, your program needs a data buffer to hold the query results generated by the FETCH statement. If the statement contains dynamic parameters, your program needs a data buffer into which it loads the values of those dynamic parameters. The dynamic parameter values are transmitted to the database by means of an OPEN or an EXECUTE statement. 5. Use the PREPARE statement to preprocess the dynamic statement. 6. Set the appropriate sqlda_type fields. See Table 4-4 and Table 4-5 . Remember, when you describe input for a non-bulk statement (a statement that processes just one row), sqlnrow must always be equal to one prior to issuing the OPEN or EXECUTE statement. 7. Use the DESCRIBE statement (with the optional OUTPUT specification) to determine the statement type and its format if it is a query. Information goes to the specified sqlda_type and sqlformat_type data structures. You must use DESCRIBE OUTPUT if, at coding time, the composition of your prepared statement is completely unknown or if you know it is a query but you do not know its exact format and content. 8. Use the DESCRIBE statement with the INPUT specification to determine the number of dynamic parameters in the prepared statement and the default data type and format of each. Your application obtains this information via the specified sqlda_type and sqlformat_type data structures. (The "Using Default Data Types with Dynamic Parameters" section later in this chapter contains detailed information about default data types and default data formats for dynamic parameters.) 9. Load the input data buffer with dynamic parameter values based on information provided by the DESCRIBE INPUT statement. 10. If the prepared statement is a query, use a DECLARE statement to associate it with a cursor. Use an OPEN statement to put qualifying rows of the query into the data buffer you have defined for output. Specify the USING DESCRIPTOR clause of the OPEN statement to pass in dynamic parameter values. In a loop, use a FETCH USING DESCRIPTOR statement to process each row. 11. Close the cursor and commit work. 12. If the prepared statement is not a query, use the EXECUTE statement with the USING clause to pass in dynamic parameter values. Table 4-3. ALLBASE/SQL Data Type Byte Alignment ------------------------------------------------------------------------------------------------- | | | | | | Format Array | Data Type | Series 700 and 800 | Series 300 and 400 | | sqltype Field | | Byte Alignment | Byte Alignment | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 0 | INTEGER | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 0 | SMALLINT | 2 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 1 | BINARY | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 2 | CHAR | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 3 | VARCHAR | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 4 | DOUBLE PRECISION | 8 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 4 | FLOAT (4 bytes) | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 4 | FLOAT (8 bytes) | 8 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 4 | REAL | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 5 | DECIMAL | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 5 | NUMERIC | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 6 | TID | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 10 | DATE | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 11 | TIME | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 12 | DATETIME | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 13 | INTERVAL | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 14 | VARBINARY | 4 | 2 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 15 | LONG BINARY | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- | | | | | | 16 | LONG VARBINARY | 1 | 1 | | | | | | ------------------------------------------------------------------------------------------------- [REV BEG] Table 4-4. Setting SQLDA Fields for Output and for Input in C ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | Field | Field | C | You Set | You Set | You Set | ALLBASE/ | ALLBASE/ | | Name | Description | Data | Before | Before | Before | SQL | SQL Sets | | | | Type | DESCRIBE | OPEN or | FETCH or | Sets at | at FETCH | | | | | or ADVANCE | EXECUTE | EXECUTE | DESCRIBE | or | | | | | | USING | USING | or ADVANCE | EXECUTE | | | | | | INPUT | OUTPUT | | USING | | | | | | | | | OUTPUT | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqldaid | reserved | char[8]| | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlmproc | number of | short | | | | IOR | | | | multiple row | | | | | | | | | result sets | | | | | | | | | inside a | | | | | | | | | procedure | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqloparm | number of output | short | | | | O | | | | dynamic | | | | | | | | | parameters in a | | | | | | | | | dynamically | | | | | | | | | prepared EXECUTE | | | | | | | | | PROCEDURE | | | | | | | | | statement | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqln | number of format | int | IOR | | | | | | | array elements | | | | | | | | | (for output, one | | | | | | | | | record per select | | | | | | | | | list item to a | | | | | | | | | maximum of 1024; | | | | | | | | | for input, one | | | | | | | | | record per | | | | | | | | | dynamic parameter | | | | | | | | | to a maximum of | | | | | | | | | 255) | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqld | for output, | int | | | | IOR | | | | number of columns | | | | | | | | | in query result | | | | | | | | | (0 if non-query | | | | | | | | | or EXECUTE | | | | | | | | | PROCEDURE); for | | | | | | | | | input, number of | | | | | | | | | input dynamic | | | | | | | | | parameters in the | | | | | | | | | prepared | | | | | | | | | statement | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlfmtarr | address of format | int | IOR | | | IOR 2 | | | | array | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlnrow | number of rows in | int | | I1 | O1 | | | | | the data buffer 1 | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlrrow | number of rows | int | | | | | O | | | put into the data | | | | | | | | | buffer | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlrowlen | number of bytes | int | | | | IOR | | | | in each row | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlbuflen | number of bytes | int | | I | O | | | | | in the data | | | | | | | | | buffer | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlrowbuf | address of data | int | | I | O | | | | | buffer | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ | | | I Used for input. | | | | O Used for output. | | | | R Used for DESCRIBE RESULT and ADVANCE. | | | | 1 When you describe for output, use sqlnrow to specify the number of rows to fetch | | into the data buffer. When you describe for input, use sqlnrow to specify the | | number of rows you have loaded into the data buffer (Always set to one for a | | non-bulk statement.). | | | | 2 Data is loaded into the format array when a DESCRIBE or ADVANCE statement executes. | | | ------------------------------------------------------------------------------------------ Table 4-5. Setting SQLDA Fields for Output and for Input in Pascal ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | Field | Field | C | You Set | You Set | You Set | ALLBASE/ | ALLBASE/ | | Name | Description | Data | Before | Before | Before | SQL | SQL Sets | | | | Type | DESCRIBE | OPEN or | FETCH or | Sets at | at FETCH | | | | | or ADVANCE | EXECUTE | EXECUTE | DESCRIBE | or | | | | | | USING | USING | or ADVANCE | EXECUTE | | | | | | INPUT | OUTPUT | | USING | | | | | | | | | OUTPUT | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqldaid | reserved | char[8]| | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlmproc | number of | short | | | | IOR | | | | multiple row | | | | | | | | | result sets | | | | | | | | | inside a | | | | | | | | | procedure | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqloparm | number of output | smallint | | | O | | | | dynamic | | | | | | | | | parameters in a | | | | | | | | | dynamically | | | | | | | | | prepared EXECUTE | | | | | | | | | PROCEDURE | | | | | | | | | statement | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqln | number of format | integer| IOR | | | | | | | array elements | | | | | | | | | (for output, one | | | | | | | | | record per select | | | | | | | | | list item to a | | | | | | | | | maximum of 1024; | | | | | | | | | for input, one | | | | | | | | | record per | | | | | | | | | dynamic parameter | | | | | | | | | to a maximum of | | | | | | | | | 255) | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqld | for output, | integer| | | | IOR | | | | number of columns | | | | | | | | | in query result | | | | | | | | | (0 if non-query | | | | | | | | | or EXECUTE | | | | | | | | | PROCEDURE); for | | | | | | | | | input, number of | | | | | | | | | input dynamic | | | | | | | | | parameters in the | | | | | | | | | prepared | | | | | | | | | statement | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlfmtarr | address of format | integer| IOR | | | IOR 2 | | | | array | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlnrow | number of rows in | integer| | I1 | O1 | | | | | the data buffer 1 | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlrrow | number of rows | integer| | | | | O | | | put into the data | | | | | | | | | buffer | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlrowlen | number of bytes | integer| | | | IOR | | | | in each row | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlbuflen | number of bytes | integer| | I | O | | | | | in the data | | | | | | | | | buffer | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ | | | | | | | | | | sqlrowbuf | address of data | integer| | I | O | | | | | buffer | | | | | | | | | | | | | | | | ------------------------------------------------------------------------------------------------------------ ------------------------------------------------------------------------------------------ | | | I Used for input. | | | | O Used for output. | | | | R Used for DESCRIBE RESULT and ADVANCE. | | | | 1 When you describe for output, use sqlnrow to specify the number of rows to fetch | | into the data buffer. When you describe for input, use sqlnrow to specify the | | number of rows you have loaded into the data buffer (Always set to one for a | | non-bulk statement.). | | | | 2 Data is loaded into the format array when a DESCRIBE or ADVANCE statement executes. | | | ------------------------------------------------------------------------------------------ [REV END] Table 4-6. Fields in a Format Array Record in C ----------------------------------------------------------------------------------------------- | | | | | Field Name | Meaning of Field | C Data Type | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlnty | reserved; always set to 111 | short | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqltype | data type of column: | short | | | | | | | 0 = SMALLINT or INTEGER | | | | 1 = BINARY | | | | 2 = CHAR* | | | | 3 = VARCHAR* | | | | 4 = FLOAT | | | | 5 = DECIMAL | | | | 8 = NATIVE CHAR * | | | | 9 = NATIVE VARCHAR * | | | | 10 = DATE* | | | | 11 = TIME* | | | | 12 = DATETIME* | | | | 13 = INTERVAL* | | | | 14 = VARBINARY | | | | 15 = LONG BINARY | | | | 16 = LONG VARBINARY[REV BEG] | | | | 19 = case insensitive CHAR* | | | | 20 = case insensitive VARCHAR* | | | | 21 = case insensitive NATIVE CHAR* | | | | 22 = case insensitive NATIVE VARCHAR*[REV END] | | | | | | | | * Native CHAR or VARCHAR is what SQLCore uses | | | | internally when a CHAR or VARCHAR column is defined | | | | with a LANG = ColumnLanguageName clause. They possess | | | | the same characteristics as the related types CHAR and | | | | VARCHAR, except that data stored in native columns | | | | will be sorted, compared, or truncated using local | | | | language rules. Native, character, and Date/Time | | | | types are compatible with regular character types. | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlprec | precision of DECIMAL data | short | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlscale | scale of DECIMAL data | short | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqltotallen | byte sum of sqlvallen, sqlindlen, indicator alignment | int | | | bytes, and next data value alignment bytes | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlvallen | number of bytes in data value, including a 4-byte | int | | | prefix containing actual length of VARCHAR data | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlindlen | number of bytes null indicator occupies in the data | int | | | buffer | | | | | | | | for output: | | | | 0 bytes: column defined NOT NULL | | | | 2 bytes: column allows null values | | | | | | | | for input: always 2 bytes | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlvof | byte offset of value from the beginning of a row | int | | | | | ----------------------------------------------------------------------------------------------- Table 4-6. Fields in a Format Array Record in C (cont.) ----------------------------------------------------------------------------------------------- | | | | | Field Name | Meaning of Field | C Data Type | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlnof | byte offset of null indicator from the beginning of a | int | | | row, dependent on the value of sqlindlen | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlname | defined name of column or, for computed expression, | char[20] | | | EXPR | | | | | | ----------------------------------------------------------------------------------------------- Table 4-7. Fields in a Format Array Record in Pascal ----------------------------------------------------------------------------------------------- | | | | | Field Name | Meaning of Field | Pascal Data Type | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlnty | reserved; always set to 111 | SmallInt | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqltype | data type of column: | SmallInt | | | | | | | 0 = SMALLINT or INTEGER | | | | 1 = BINARY | | | | 2 = CHAR* | | | | 3 = VARCHAR* | | | | 4 = FLOAT | | | | 5 = DECIMAL | | | | 8 = NATIVE CHAR * | | | | 9 = NATIVE VARCHAR * | | | | 10 = DATE* | | | | 11 = TIME* | | | | 12 = DATETIME* | | | | 13 = INTERVAL* | | | | 14 = VARBINARY | | | | 15 = LONG BINARY | | | | 16 = LONG VARBINARY[REV BEG] | | | | 19 = case insensitive CHAR* | | | | 20 = case insensitive VARCHAR* | | | | 21 = case insensitive NATIVE CHAR* | | | | 22 = case insensitive NATIVE VARCHAR*[REV END] | | | | | | | | * Native CHAR or VARCHAR is what SQLCore uses | | | | internally when a CHAR or VARCHAR column is defined | | | | with a LANG = ColumnLanguageName clause. They possess | | | | the same characteristics as the related types CHAR and | | | | VARCHAR, except that data stored in native columns | | | | will be sorted, compared, or truncated using local | | | | language rules. Native, character, and Date/Time | | | | types are compatible with regular character types. | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlprec | precision of DECIMAL data | SmallInt | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlscale | scale of DECIMAL data | SmallInt | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqltotallen | byte sum of sqlvallen, sqlindlen, indicator alignment | Integer | | | bytes, and next data value alignment bytes | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlvallen | number of bytes in data value, including a 4-byte | Integer | | | prefix containing actual length of VARCHAR data | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlindlen | number of bytes null indicator occupies in the data | Integer | | | buffer: | | | | | | | | for output: | | | | 0 bytes: column defined NOT NULL | | | | 2 bytes: column allows null values | | | | | | | | for input: always 2 bytes | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlvof | byte offset of value from the beginning of a row | Integer | | | | | ----------------------------------------------------------------------------------------------- Table 4-7. Fields in a Format Array Record in Pascal (cont.) ----------------------------------------------------------------------------------------------- | | | | | Field Name | Meaning of Field | Pascal Data Type | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlnof | byte offset of null indicator from the beginning of a | Integer | | | row, dependent on the value of sqlindlen | | | | | | ----------------------------------------------------------------------------------------------- | | | | | sqlname | defined name of column or, for computed expression, | Packed Array | | | EXPR | [1..20] of char | | | | | -----------------------------------------------------------------------------------------------


MPE/iX 5.0 Documentation