uaddsql

Flushes the SQL buffer or the I/O buffer, depending on the mode of the connector request.

void uaddsql(uc, buf)

struct uctrl*uc;

unsigned char*buf;

Parameters

  • uc—address of the current control block.
  • buf—pointer to the buffer to be flushed.

Return Values

Not applicable.

Description

In the Open mode 2, 4, 5 and 6 connector request, uaddsql can be used to flush the SQL buffer. This allows create table statements to exceed the size of the SQL buffer. In SQL mode 2, uaddsql can be used to flush the I/O buffer. This allows the SQL query results to exceed the size of the I/O buffer.

uaddsql appends the null-terminated string pointed to by buf to an internal buffer managed by Uniface. uaddsql does not clear buf.

When the Open mode 2, 4, 5 and 6 connector request returns to Uniface, Uniface issues one implicit call to uaddsql.

This example implements the Open mode 2 function, but no error checking is performed. The following functions are called:

Service Functions Called by uaddsql
Service function Meaning
InitBuffer Set the buffer pointer to the Uniface SQL buffer.
ResetBuffer Reset the buffer pointer.
BuildCreateTableStmt Build the statement in the native DDL needed to create the table.
BuildCreateIndexStmt Build the statement in the native DDL needed to create an index.
CountIndices Look at the index number (uidxlst->uidxnr) of the last entry index list (uctrl->uilist) to find the number of indices.
CreateTableWithIndices ( struct uctrl *ControlBlock )
{
unsigned char *SQLBuffer;
int NumberOfIndices;
int Loop;
InitBuffer ( ControlBlock->sqlbuf, SQLBuffer );
BuildCreateTableStmt ( ControlBlock, SQLBuffer );
uaddsql ( ControlBlock, SQLBuffer );
NumberOfIndices = CountIndices ( ControlBlock );
for ( Loop = 1; Loop <= NumberOfIndices; Loop++ )
{
ResetBuffer ( SQLBuffer ); /* Because uaddsql does not */
/* clear the buffer+ */
BuildCreateIndexStmt ( ControlBlock, SQLBuffer, Loop );
uaddsql ( ControlBlock, SQLBuffer );
}
}