Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Programming » Embedded SQL » How to send and retrieve long values using embedded SQL

 

Sending LONG data using static SQL

Send LONG values to the database using static SQL from an embedded SQL application.

Prerequisites

There are no prerequisites for this task.

 Task
  1. Declare a host variable of type DECL_LONGVARCHAR, DECL_LONGNVARCHAR, or DECL_LONGBINARY, as appropriate.

  2. If you are sending NULL, set the indicator variable to a negative value.

  3. Set the stored_len field of the host variable structure to the number of bytes of data in the array field.

  4. Send the data by opening the cursor or executing the statement.

Results

The embedded SQL application is ready to send LONG values to the database.

Example

The following code fragment illustrates the mechanics of sending a LONG VARCHAR using static embedded SQL. It is not intended to be a practical application.



#define DATA_LEN 12800
EXEC SQL BEGIN DECLARE SECTION;
// SQLPP initializes longdata.array_len
DECL_LONGVARCHAR(128000) longdata;
EXEC SQL END DECLARE SECTION;

void set_test_var()
{
  // init longdata for sending data
  memset( longdata.array, 'a', DATA_LEN );
  longdata.stored_len = DATA_LEN;

  printf( "Setting test_var to %d a's\n", DATA_LEN );
  EXEC SQL SET test_var = :longdata;
}

 See also