NonStop SQL/MP Reference Manual

Table Of Contents
NonStop SQL/MP Reference Manual142115
F-6
File Attributes
EXEC SQL CLOSE CURSOR1 END-EXEC.
The following steps demonstrate a dynamic SQL FETCH. The code uses FETCH
with USING DESCRIPTOR to return information on SELECT columns of which
there is no previous knowledge. (The example uses the SQL statement terminator
for C, Pascal, and TAL programs.)
1. Declare an SQLDA to hold input parameters and name the area SDAI;
NAMESINPUT is the names buffer. The values 5 and 39 are arbitrary values
chosen for the size of the SQLDA and the names buffer. Your program can use
different values or allocate memory dynamically.
EXEC SQL INCLUDE SQLDA (SDAI, 5, NAMESINPUT, 39);
2. Declare an SQLDA to hold output variables (SELECT columns) and name it
SDAO; NAMESOUTPUT is the names buffer:
EXEC SQL INCLUDE SQLDA (SDAO, 5, NAMESOUTPUT, 39);
3. Read an SQL statement input from the terminal and store it in variable H1.
4. Prepare the input as S1:
EXEC SQL PREPARE S1 FROM :H1;
5. Fill in the SQLDA and names buffer with the descriptions of the parameter
values (input parameters) in the SQL statement:
EXEC SQL DESCRIBE INPUT S1 INTO :SDAI
NAMES INTO :NAMESINPUT;
6. Fill in the SQLDA and names buffer with the descriptions of the SELECT
columns (output variables) in the SQL statement:
EXEC SQL DESCRIBE S1 INTO :SDAO NAMES INTO :NAMESOUTPUT;
7. Declare a cursor, C1, for the statement S1. Open the cursor using the parameter
values that were input and stored in :SDAI:
EXEC SQL DECLARE C1 CURSOR FOR S1;
EXEC SQL OPEN C1 USING DESCRIPTOR :SDAI;
8. Retrieve the column values stored in :SDAO:
EXEC SQL FETCH C1 USING DESCRIPTOR :SDAO;
File Attributes
File attributes describe the physical characteristics of a file or an SQL object, such as a
table or an index, that is stored in a file. The values you select for a file's attributes can
affect the storage and security for the object and the performance of applications that use
the object.
File attributes are set when a file is created. If you do not specify attribute values in the
statement that creates an SQL object (such as CREATE TABLE or CREATE INDEX),