Retrieving LONG Data Using Dynamic SQL

Retrieve a LONG VARCHAR, LONG NVARCHAR, or LONG BINARY value using dynamic SQL.

Prerequisites

There are no prerequisites for this task.

Task
  1. Set the sqltype field to DT_LONGVARCHAR, DT_LONGNVARCHAR, or DT_LONGBINARY as appropriate.
  2. Set the sqldata field to point to the LONGVARCHAR, LONGNVARCHAR, or LONGBINARY host variable structure.

    You can use the LONGVARCHARSIZE(n), LONGNVARCHARSIZE(n), or LONGBINARYSIZE(n) macro to determine the total number of bytes to allocate to hold n bytes of data in the array field.

  3. Set the array_len field of the host variable structure to the number of bytes allocated for the array field.
  4. Retrieve the data using FETCH, GET DATA, or EXECUTE INTO. SAP Sybase IQ sets the following information:
    • * sqlind – This sqlda field is negative if the value is NULL, 0 if there is no truncation, and is the positive untruncated length in bytes up to a maximum of 32767.
    • stored_len – The number of bytes stored in the array. Always less than or equal to array_len and untrunc_len.
    • untrunc_len – 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.

The LONG data is retrieved using dynamic SQL.