GET DATA
Valid in: ESQL
The GET DATA statement reads a segment of a long varchar, long nvarchar, or long byte column from a table to an embedded SQL program.
The GET DATA statement is used in data handler routines. For details about data handler routines, see the chapter “Working with Embedded SQL” and the Embedded SQL Companion Guide.
The GET DATA statement has the following format:
EXEC SQL GET DATA(:col_value = SEGMENT
[, :length_value = SEGMENTLENGTH]
[, :dataend_value = DATAEND])
[WITH MAXLENGTH = maxlength_value;]
col_value
Specifies the variable to which the value from the column is assigned. The maximum length of a long varchar, long nvarchar, or long byte column is 2 GB.
length_value
(Optional) Signed 4-byte integer to which the length of the data segment is assigned when the segment is read. If the MAXLENGTH parameter is specified, the value returned in the SEGMENTLENGTH variable, when the last segment is read, is less than MAXLENGTH . If the MAXLENGTH parameter is omitted, the value returned in the SEGMENTLENGTH variable is either the length of the segment variable or the number of remaining bytes, whichever is smaller.
dataend_value
(Optional) Signed 4-byte integer returns 1 if the segment is the last segment, 0 if the segment is not the last.
maxlength_value
(Optional) Signed 4-byte integer specifying the number of bytes to be returned. This value must not exceed the length of the SEGMENT variable. Maxlength_value can be specified using a literal or a host language variable.
The host language variables for col_value, length_value, dataend_value and maxlength_value must be declared in a BEGIN DECLARE SECTION/END DECLARE SECTION block to the ESQL preprocessor.
If a data handler routine attempts to exit without issuing an ENDDATA statement, the DBMS Server issues a runtime error.
Permissions
This statement is available to all users.
Related Statements
PUT DATA
Last modified date: 08/29/2024