-- Copyright © Oracle Corporation 1995. All Rights Reserved. -- This SQL module provides the SQL procedures needed by the -- SQL$TEXT_FIELDS.C program. The module illustrates the three -- different ways that you can specify text fields in the -- data dictionary using the C programming language: -- NULL TERMINATED BYTES, the default -- NULL TERMINATED CHARACTERS -- FIXED (no null) -- ------------------------------------------------------------------------------- -- Header Information Section ------------------------------------------------------------------------------- MODULE SQL_TEXT_FIELDS_C LANGUAGE C AUTHORIZATION SQL_SAMPLE PARAMETER COLONS ------------------------------------------------------------------------------- -- DECLARE Statements Section ------------------------------------------------------------------------------- DECLARE ALIAS FILENAME 'SUPPLIES' DECLARE P_CURSOR CURSOR FOR SELECT * FROM PARTS ------------------------------------------------------------------------------- -- Procedure Section -- In every procedure, declare SQLCODE, a parameter that stores a value -- representing the execution status of SQL statements. ------------------------------------------------------------------------------- PROCEDURE open_p SQLCODE; OPEN P_CURSOR; -- This procedure specifies the data dictionary record PARTS using the -- dictionary path name. Because none of the character interpretation -- options is specified, output for a field defined as TEXT SIZE 6 -- in the dictionary or CHAR (6) in SQL will show the default interpretation, -- NULL TERMINATED BYTES, a field of 6 bytes that contains 5 -- characters followed by a null value. PROCEDURE fetch_p_default SQLCODE :P_REC RECORD FROM 'CDD$DEFAULT.SUPPLIES.RDB$RELATIONS.PARTS' END RECORD; FETCH P_CURSOR INTO :P_REC; -- This procedure specifies the data dictionary record PARTS using the -- dictionary path name. Because the FIXED option is specified, -- output for a field defined as TEXT SIZE 6 in the dictionary or -- CHAR (6) in SQL will be a field of 6 bytes that contains -- 6 characters. There is no null value. PROCEDURE fetch_p_fixed SQLCODE :P_REC RECORD FROM 'CDD$DEFAULT.SUPPLIES.RDB$RELATIONS.PARTS' FIXED END RECORD; FETCH P_CURSOR INTO :P_REC; -- This procedure specifies the data dictionary record PARTS using the -- dictionary path name. Because the NULL TERMINATED BYTES -- option is specified, output for a field defined as TEXT SIZE 6 -- in the dictionary or CHAR (6) in SQL will be a field of 6 bytes -- that contains 5 characters followed by the null value. PROCEDURE fetch_p_ntb SQLCODE :P_REC RECORD FROM 'CDD$DEFAULT.SUPPLIES.RDB$RELATIONS.PARTS' NULL TERMINATED BYTES END RECORD; FETCH P_CURSOR INTO :P_REC; -- This procedure specifies the data dictionary record PARTS using the -- dictionary path name. Because the NULL TERMINATED CHARACTERS -- option is specified, output for a field defined as TEXT SIZE 6 -- in the dictionary or CHAR (6) in SQL will be a field of 7 -- bytes that contains 6 characters followed by the null value. PROCEDURE fetch_p_ntc SQLCODE :P_REC RECORD FROM 'CDD$DEFAULT.SUPPLIES.RDB$RELATIONS.PARTS' NULL TERMINATED CHARACTERS END RECORD; FETCH P_CURSOR INTO :P_REC; PROCEDURE close_p SQLCODE; CLOSE P_CURSOR;