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

SQL Anywhere 11.0.1 (Français) » SQL Anywhere Server - Programming » SQL Anywhere Data Access APIs » SQL Anywhere External Function API » External function prototypes


an_extfn_value structure

Used to access parameter data from the calling SQL environment.

typedef struct an_extfn_value {
    void *           data;
    a_sql_uint32     piece_len;
    union {
        a_sql_uint32 total_len;
        a_sql_uint32 remain_len;
    } len;
    a_sql_data_type  type;
} an_extfn_value;
  • data   A pointer to the data for this parameter.

  • piece_len   The length of this segment of the parameter. This is less than or equal to total_len.

  • total_len   The total length of the parameter. For strings, this represents the length of the string and does not include a null terminator. This property is set after a call to the get_value callback function. This property is no longer valid after a call to the get_piece callback function.

  • remain_len   When the parameter is obtained in segments, this is the length of the part that has not yet been obtained. This property is set after each call to the get_piece callback function.

  • type   Indicates the type of the parameter. This is one of the Embedded SQL data types such as DT_INT, DT_FIXCHAR, or DT_BINARY. See Embedded SQL data types.


Suppose that your external function interface was described using the following SQL statement.

EXTERNAL NAME 'mystring@c:\\project\\mystring.dll';

The following code fragment shows how to access the properties for objects of type an_extfn_value. In the example, the input parameter 1 (instr) to this function (mystring) is expected to be a SQL LONGVARCHAR string.

an_extfn_value      arg;

result = extapi->get_value( arg_handle, 1, &arg );
if( result == 0 || == NULL )
    return; // no parameter or parameter is NULL

if( arg.type != DT_LONGVARCHAR )
    return; // unexpected type of parameter

cmd = (char *)malloc( arg.len.total_len + 1 );
offset = 0;
for( ; result != 0; )
     if( == NULL ) break;
     memcpy( &cmd[offset],, arg.piece_len );
     offset += arg.piece_len;
     cmd[offset] = '\0';
     if( arg.piece_len == 0 ) break;
     result = extapi->get_piece( arg_handle, 1, &arg, offset );
See also