The method for sending and retrieving LONG VARCHAR, LONG NVARCHAR, and LONG BINARY values in embedded SQL applications is different from that for other data types. The standard SQLDA fields are limited to 32767 bytes of data as the fields holding the length information (sqldata, sqllen, sqlind) are 16-bit values. Changing these values to 32-bit values would break existing applications.
The method of describing LONG VARCHAR, LONG NVARCHAR, and LONG BINARY values is the same as for other data types.
For information about how to retrieve and send values, see Retrieving LONG data, and Sending LONG data.
Separate fields are used to hold the allocated, stored, and untruncated lengths of LONG BINARY, LONG VARCHAR, and LONG NVARCHAR data types. The static SQL data types are defined in sqlca.h as follows:
#define DECL_LONGVARCHAR( size ) \ struct { a_sql_uint32 array_len; \ a_sql_uint32 stored_len; \ a_sql_uint32 untrunc_len; \ char array[size+1];\ } #define DECL_LONGNVARCHAR( size ) \ struct { a_sql_uint32 array_len; \ a_sql_uint32 stored_len; \ a_sql_uint32 untrunc_len; \ char array[size+1];\ } #define DECL_LONGBINARY( size ) \ struct { a_sql_uint32 array_len; \ a_sql_uint32 stored_len; \ a_sql_uint32 untrunc_len; \ char array[size]; \ } |
For dynamic SQL, set the sqltype field to DT_LONGVARCHAR, DT_LONGNVARCHAR, or DT_LONGBINARY as appropriate. The associated LONGVARCHAR, LONGNVARCHAR, and LONGBINARY structures are as follows:
typedef struct LONGVARCHAR { a_sql_uint32 array_len; a_sql_uint32 stored_len; a_sql_uint32 untrunc_len; char array[1]; } LONGVARCHAR, LONGNVARCHAR, LONGBINARY; |
For both static and dynamic SQL structures, the structure members are defined as follows:
array_len (Sending and retrieving.) The number of bytes allocated for the array part of the structure.
stored_len (Sending and retrieving.) The number of bytes stored in the array. Always less than or equal to array_len and untrunc_len.
untrunc_len (Retrieving only.) The number of bytes that would be stored in the array if the value was not truncated. Always greater than or equal to stored_len. If truncation occurs, this value is larger than array_len.
Retrieving LONG data
Sending LONG data
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |