Retrieving data from a client

A writetext stream retrieved from a client application is handled as bulk data by the Server Option application.

An application processes incoming text or image data in two steps:

  1. The TDINFTXT function retrieves a description of the text or image data and places the description in a CS_IODESC structure. The TDINFTXT function call returns information including the total length of incoming data. This length enables the Server Option application to determine whether the data should be retrieved in one unit or in sections. The Server Option application also determines the size of the buffer that must be allocated to store the incoming data. TDINFTXT is invoked with the ACTION parameter set to TDS_GET. The DATATYPE field of the CS_IODESC structure must be provided by the Server Option application before TDINFTXT is invoked. See “TDINFTXT” for details on this function.

  2. The TDGETTXT function retrieves the incoming text and image data from the client application in the specified section size and stores the data in the specified buffer. See “TDGETTXT” for details on the TDGETTXT function.

NoteA call to TDINFTXT must always precede a call to TDGETTXT. The TDGETTXT routine must be called until all text has been read from the client.

Table 7 illustrates the sequence of API function calls for retrieving text or image bulk data from the client.

Table 7: API function call sequence for data retrieval

Function

Action performed

TDSQLLEN

Determines the length of the incoming writetext string

TDSRCVSQL

Retrieves a writetext string. The TDSRCVSQL function call receives a writetext bulk command, which indicates that text or image bulk data follows. The writetext bulk command occurs in the following format:

writetext bulk <object_name> <text_pointer> timestamp = <time_stamp> [with log | without log]

The parameters of the writetext bulk command are as follows:

  • <object_name> is the name of the object name to which data is to be sent.

  • <text_pointer> is a text pointer.

  • <time_stamp> indicates the value of the timestamp parameter.

  • The text with log or without log is not used by the Server Option.

For example:

writetext bulk SYBASE.au_txt.TXT 0xa1a0bbd014a6d005060e016a20400100 timestamp = 0x0000000000000000 with log

The manner in which the writetext bulk parameters are used depends on the Server Option application and on the destination of the incoming text and image data.

TDSNDDON

Notifies the sender that the SQL string has been received. Use the connection option of TDS_ENDREPLY to change the communication state from send to receive.

TDINFTXT (using TDS_GET)

Returns the length of the entire text or image data stream. The Server Option translates incoming data based on the value of the DATATYPE field in the CS_IODESC structure.

TDGETTXT

Retrieves a section of the text or image data stream. TDGETTXT is invoked in a loop until all incoming data is retrieved.

TDSNDDON

Notifies the sender that all data has been received.