Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members | Related Pages

SQLDBC::SQLDBC_PreparedStatement Class Reference

Inheritance diagram for SQLDBC::SQLDBC_PreparedStatement:

SQLDBC::SQLDBC_Statement SQLDBC::SQLDBC_ConnectionItem List of all members.

Detailed Description

A class for preparing and executing SQL statements.

A prepared SQL statement can be parsed and contain input and output parameters. Parameters are marked with a '?' or ':<name>' tag. All DML commands can be parsed. DDL commands can be parsed, too. However, it is not recommended to do so. Prepared SQL statements increase the performance since they are parsed only once and executed several times. Applications only need to change the content of the bound parameters and execute the command again.

All prepared SQL statements are stored in an internally managed ParseInfo Cache . The ParseInfo Cache shares this information with different prepared SQL statements within the same connection.

The SQL statement may contain ASCII or UCS2 characters and must not zero-terminated. The execute() member function converts it to the adequate code set considering the code of the database. Therefore it is possible to write portable code for UNICODE and non-UNICODE databases.

Note:
To increase the performance, applications must use UCS2 statements for UNICODE databases only.
Example:
Preparation and execution of an SQL statement.
   SQLDBC_PreparedStatement *stmt = conn->createPreparedStatement();
   SQLDBC_Retcode rc = stmt->prepare("SELECT * FROM DUAL");
   if (rc != SQLDBC_OK) {
Handle error ...
   }
   rc = stmt->execute();
   if (rc != SQLDBC_OK) {
Handle error ...
   }
   

Parameters can be bound to the statement column-wise or row-wise. The default binding type is column-wise. To use row-wise binding, applications must use the method setBindingType() with the size in bytes of the date structure to be bound.

Example:
Binding parameters column-wise and insert some data into a table using mass insert.
    int keys[] = { 1, 2, <...> };

    char *names[] = { "Congress",
                      "Long Island",
                      <...>
    };

    char *zips[] = { "20005",
                     "11788",
                     <...>
    };

    char *addresses[] = { "155 Beechwood Str.",
                          "1499 Grove Street",
                          <...>
    };

    SQLDBC_PreparedStatement *prepstmt = connection()->createPreparedStatement();

    SQLDBC_Length key_ind[15];
    SQLDBC_Length name_ind[15];
    SQLDBC_Length zip_ind[15];
    SQLDBC_Length address_ind[15];

    memset (key_ind, 0, sizeof(key_ind));
    memset (name_ind, 0, sizeof(name_ind));
    memset (name_ind, 0, sizeof(name_ind));
    memset (zip_ind, 0, sizeof(zip_ind));
    memset (address_ind, 0, sizeof(address_ind));

    prepstmt->prepare("insert into hotel.hotel (hno, name, zip, address) values (?, ?, ?, ?)");
    prepstmt->setBatchSize(15);
    prepstmt->bindParameter (1, SQLDBC_HOSTTYPE_INT4, &keys[0], &key_ind[0], sizeof(SQLDBC_Int4));
    prepstmt->bindParameterAddr(2, SQLDBC_HOSTTYPE_ASCII, &names[0], &name_ind[0], 13);
    prepstmt->bindParameterAddr(3, SQLDBC_HOSTTYPE_ASCII, &zips[0], &zip_ind[0], 5);
    prepstmt->bindParameterAddr(4, SQLDBC_HOSTTYPE_ASCII, &addresses[0], &address_ind[0], 19);

    int i;
    for (i = 0; i < 15; i++) {
      key_ind[i]      =  (SQLDBC_Length) sizeof(SQLDBC_Int4);
      name_ind[i]     =  (SQLDBC_Length) strlen((const char *) names[i]);
      zip_ind[i]      =  (SQLDBC_Length) strlen((const char *) zips[i]);
      address_ind[i]  =  (SQLDBC_Length) strlen((const char *) addresses[i]);
    }
    prepstmt->execute ();
   

Example:
Binding parameters row-wise and insert some data into a table using mass insert.
    typedef struct {
      SQLDBC_Int4     key;
      char           *name;
      char           *zip;
      char           *address;
      SQLDBC_Length   key_ind;
      SQLDBC_Length   name_ind;
      SQLDBC_Length   zip_ind;
      SQLDBC_Length   address_ind;
    } row;

    row rows[] = { { 1, "Congress", "20005", "155 Beechwood Str.", 0, 0, 0 },
                   { 2, "Long Island", "11788", "1499 Grove Street", 0, 0, 0 },
                   <...>
    };

    SQLDBC_PreparedStatement *prepstmt = connection()->createPreparedStatement();

    prepstmt->prepare("insert into hotel.hotel (hno, name, zip, address) values (?, ?, ?, ?)");
    prepstmt->setBindingType(sizeof(row));
    prepstmt->setBatchSize(15);
    prepstmt->bindParameter (1, SQLDBC_HOSTTYPE_INT4, &rows[0].key, &rows[0].key_ind, sizeof(SQLDBC_Int4));
    prepstmt->bindParameterAddr(2, SQLDBC_HOSTTYPE_ASCII, &rows[0].name   , &rows[0].name_ind   , rows[0].name_ind    );
    prepstmt->bindParameterAddr(3, SQLDBC_HOSTTYPE_ASCII, &rows[0].zip    , &rows[0].zip_ind    , rows[0].zip_ind     );
    prepstmt->bindParameterAddr(4, SQLDBC_HOSTTYPE_ASCII, &rows[0].address, &rows[0].address_ind, rows[0].address_ind );

    int i;
    for (i = 0; i < 15; i++) {
      rows[i].key_ind      =  (SQLDBC_Length) sizeof(SQLDBC_Int4);
      rows[i].name_ind     =  (SQLDBC_Length) strlen((const char *) rows[i].name);
      rows[i].zip_ind      =  (SQLDBC_Length) strlen((const char *) rows[i].zip);
      rows[i].address_ind  =  (SQLDBC_Length) strlen((const char *) rows[i].address);
    }
    prepstmt->execute ();
   

Hints:
Todo:
binding parameter by name

Definition at line 2607 of file SQLDBC.h.

Public Types

Public Member Functions

Protected Member Functions


Member Enumeration Documentation

enum SQLDBC::SQLDBC_Statement::ConcurrencyType [inherited]
 

Enumerator:
CONCUR_UPDATABLE  The result can be updated (FOR UPDATE).
CONCUR_READ_ONLY  The result cannot be updated.

Definition at line 2276 of file SQLDBC.h.

enum SQLDBC::SQLDBC_Statement::HoldabilityType [inherited]
 

Enumerator:
CURSOR_HOLD_OVER_COMMIT  The result persists after a COMMIT command.
CURSOR_CLOSE_ON_COMMIT  The result is closed on COMMIT.

Definition at line 2297 of file SQLDBC.h.

enum SQLDBC::SQLDBC_Statement::ResultSetType [inherited]
 

Enumerator:
FORWARD_ONLY  The result set can be scrolled forward only.
SCROLL_SENSITIVE  The content of the result set may change.
SCROLL_INSENSITIVE  The content of the result set cannot not change (FOR REUSE).

Definition at line 2233 of file SQLDBC.h.


Member Function Documentation

const SQLDBC_Retcode SQLDBC::SQLDBC_Statement::addBatch const char *  sql  )  [inherited]
 

Adds a statement to the batch.

The must be end with a zero-terminator and in ASCII code.

Parameters:
sql The statement to be added
Returns:
SQLDBC_OK on success

const SQLDBC_Retcode SQLDBC::SQLDBC_Statement::addBatch const char *  sql,
SQLDBC_StringEncoding  encoding
[inherited]
 

Adds a statement to the batch.

The must be end with a zero-terminator.

Parameters:
sql The statement to be added
encoding Encoding of the statement
Returns:
SQLDBC_OK on success

const SQLDBC_Retcode SQLDBC::SQLDBC_Statement::addBatch const char *  sql,
SQLDBC_Length  sqlLength,
SQLDBC_StringEncoding  encoding
[inherited]
 

Adds a statement to the batch.

Statements for batched execution must not return result sets.

Parameters:
sql The statement to be added
sqlLength Length in Bytes of the statement
encoding Encoding of the statement
Returns:
SQLDBC_OK on success
See also:
addBatch()

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::bindParameter const SQLDBC_UInt2  Index,
const SQLDBC_HostType  Type,
void *  paramAddr,
SQLDBC_Length LengthIndicator,
const SQLDBC_Length  Size,
const SQLDBC_Bool  Terminate = SQLDBC_TRUE
 

Binds a user supplied memory buffer to an input and/or output parameter of an SQL statement.

A parameter is a '?' or ':<name>' placeholder in an SQL statement. Applications should use SQLDBC_ParameterMetadata to retrieve information about the type and length of the parameters in an SQL statement.

Parameters:
Index [in] Index of the parameter, starting with 1
Type [in] Host type of the parameter
paramAddr [in] A pointer to a buffer for the parameter's data
LengthIndicator [in|out] Pointer to parameter length or indicator.
  • Input parameter:
    For non-integral (character and binary data) input parameters, The LengthIndicator argument must specify the length of the parameter data in bytes, or the indicator value SQLDBC_NULL_DATA to assign a NULL value to a column. The parameter length may also be given by the special length SQLDBC_NTS or by passing a NULL pointer argument when the buffer points to a zero-terminated character string. If the Size argument is not zero SQLDBC computes the number bytes by searching the terminator character in first Size bytes. If the value of Size is zero SQLDBC searches an unlimited number of bytes for the occurrences of a termination character to determine the length.
  • Output parameter:
    For output parameters, LengthIndicator stores the column length or the indicator value SQLDBC_NULL_DATA if the column contains the NULL value. For character data it contains on success the number of bytes copied to the buffer, except the number of bytes necessary for the zero-terminator, if the Terminate flag was set. If the source string exceeds the Size value SQLDBC_DATA_TRUNC will be returned and LengthIndicator is set to the number of bytes (except the terminator bytes) needed to copy without truncation.
Size [in] Byte length of the parameter
Terminate [in] Specifies that the output buffer must be finished with a C-style zero-terminator. The Terminate flag works only for the non-integral character hostvar types (SQLDBC_HOSTTYPE_ASCII, SQLDBC_HOSTTYPE_UCS2 or SQLDBC_HOSTTYPE_UTF8).
Returns:
SQLDBC_OK always
See also:
clearParameter

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::bindParameterAddr const SQLDBC_UInt2  Index,
const SQLDBC_HostType  Type,
void *  paramAddr,
SQLDBC_Length LengthIndicator,
const SQLDBC_Length  Size,
const SQLDBC_Bool  Terminate = SQLDBC_TRUE
 

Binds an input and/or output parameter by address.

Binding by adress is useful when the application uses buffers that are allocated as an array of pointers (C function calloc)

A parameter is a '?' or ':<name>' placeholder in an SQL statement. Applications should use SQLDBC_ParameterMetadata to retrieve information about the type and length of the parameters in a SQL statement.

Parameters:
Index [in] Index of the parameter, starting with 1.
Type [in] Host type of the parameter
paramAddr [in] Pointer to a pointer for the parameter's data.
LengthIndicator [in|out] Pointer to parameter length or indicator.
  • Input parameter:
    For non-integral (character and binary data) input parameters, The LengthIndicator argument must specify the length of the parameter data in bytes, or the indicator value SQLDBC_NULL_DATA to assign a NULL value to a column. The parameter length may also be given by the special length SQLDBC_NTS or by passing a NULL pointer argument when the buffer points to a zero-terminated character string. If the Size argument is not zero SQLDBC computes the number bytes by searching the terminator character in first Size bytes. If the value of Size is zero SQLDBC searches an unlimited number of bytes for the occurrences of a termination character to determine the length.
  • Output parameter:
    For output parameters, LengthIndicator stores the column length or the indicator value SQLDBC_NULL_DATA if the column contains the NULL value. For character data it contains on success the number of bytes copied to the buffer, except the number of bytes necessary for the zero-terminator, if the Terminate flag was set. If the source string exceeds the Size value SQLDBC_DATA_TRUNC will be returned and LengthIndicator is set to the number of bytes (except the terminator bytes) needed to copy without truncation.
Size [in] Byte length of the parameter
Terminate [in] Specifies that the output buffer must be finished with a C-style zero-terminator. The Terminate flag works only for the non-integral character hostvar types (SQLDBC_HOSTTYPE_ASCII, SQLDBC_HOSTTYPE_UCS2 or SQLDBC_HOSTTYPE_UTF8).
Returns:
SQLDBC_OK always
See also:
clearParameter

void SQLDBC::SQLDBC_Statement::clearBatch  )  [inherited]
 

Clears the array of batched statements.

void SQLDBC::SQLDBC_ConnectionItem::clearError  )  [inherited]
 

Deletes the error has been stored.

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::clearParameters  ) 
 

Clears the information about parameters.

All information about parameters that have been bound before using either the bindParameter or the bindParameterAddr method is cleared.

Returns:
SQLDBC_OK on success, SQLDBC_NOT_OK if the statement is currently executing a statement having data at execute parameters.
See also:
bindParameter

void SQLDBC::SQLDBC_Statement::clearResultSet  )  [protected, inherited]
 

void SQLDBC::SQLDBC_ConnectionItem::clearWarnings  )  [inherited]
 

Deletes the warning stored in the SQLWarning object.

SQLDBC_ErrorHndl& SQLDBC::SQLDBC_ConnectionItem::error  )  [inherited]
 

Returns a reference to the ErrorHndl object.

Note:
Applications should retrieve the content of the SQLDBC_ErrorHndl object immediatly since an new call to any SQLDBC function except the warning() method will empty SQLDBC_ErrorHndl object.
Returns:
An SQLDBC_ErrorHndl object.

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::execute const char *  sql  )  [inherited]
 

Executes an ASCII coded zero-terminated SQL statement.

The SQL statement is executed immediately on sending a DBS request to the database. In case of an error, the SQLDBC_ErrorHndl object (to be queried using error()) of this object is set. If the executed SQL statement is a query, a result set is created. The application can check this using isQuery(), and obtain retrieve the resultset using getResultSet().

Parameters:
sql The zero-terminated ASCII coded SQL statement to be execute.
Returns:
SQLDBC_OK on success, or else SQLDBC_NOT_OK. In this case check the error instance.

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::execute const char *  sql,
const SQLDBC_StringEncoding  encoding
[inherited]
 

Executes an UNICODE/ASCII coded zero-terminated SQL statement.

The SQL statement is executed immediately on sending a DBS request to the database. In case of an error, the SQLDBC_ErrorHndl object (to be queried using error()) of this object is set. If the executed SQL statement is a query, a result set is created. The application can check this using isQuery(), and obtain retrieve the resultset using getResultSet().

Parameters:
sql The zero-terminated SQL statement to be executed. The coding of this string argument depends from the encoding argument.
encoding The character coding of the SQL statement.
Returns:
SQLDBC_OK on success, or else SQLDBC_NOT_OK. In this case check the error instance.

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::execute const char *  sql,
const SQLDBC_Length  sqlLength,
const SQLDBC_StringEncoding  encoding
[inherited]
 

Executes an UNICODE/ASCII coded SQL statement.

The SQL statement is executed immediately on sending a DBS request to the database. In case of an error, the SQLDBC_ErrorHndl object (to be queried using error()) of this object is set. If the executed SQL statement is a query, a result set is created. The application can check this using isQuery(), and obtain retrieve the ResultSet using getResultSet().

Parameters:
sql The SQL statement to be executed. The coding of this string argument depends from the encoding argument.
sqlLength The length in bytes of the of the SQL statement
encoding The character coding of the SQL statement
Returns:
SQLDBC_OK on success, or else SQLDBC_NOT_OK. In this case check the error instance.

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::execute  ) 
 

Executes a prepared SQL statement.

The SQL statement must be prepared beforehand, and the appropriate binding variables must have been set with the bindParameter() member function.

Returns:

const SQLDBC_Retcode SQLDBC::SQLDBC_Statement::executeBatch  )  [inherited]
 

Executes the statements previously input via addBatch().

Returns:
SQLDBC_OK on success, SQLDBC_NOT_OK on error, SQLDBC_NO_DATA_FOUND if there are no SQL statements to execute.

const SQLDBC_UInt4 SQLDBC::SQLDBC_Statement::getBatchSize  )  const [inherited]
 

Returns the size of the row status array.

Returns:
The number of elements of the row status array, which is also the number of array elements that are used for batch execution.

SQLDBC_Connection* SQLDBC::SQLDBC_Statement::getConnection  )  [inherited]
 

Get the SQLDBC connection object that belongs to the statement.

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::getCursorName char *  buffer,
const SQLDBC_StringEncoding  encoding,
const SQLDBC_Length  bufferSize,
SQLDBC_Length bufferLength
const [inherited]
 

Retrieves the cursor name.

The cursor name may be set by:

  • The setCursorName() member function
  • A named query statement
  • A database procedure returning a result table

Parameters:
buffer The buffer into which the zero-terminated cursor name is copied.
encoding Encoding of the buffer where the cursor name is stored.
bufferSize Maximum size of the buffer in bytes.
bufferLength [out] Number of bytes copied to the buffer, except the number of bytes necessary for the zero-terminator. If the source string exceeds the bufferSize. SQLDBC_DATA_TRUNC will be returned and the bufferLength set to the number of bytes (except terminator bytes) needed to copy without truncation.
Returns:
SQLDBC_OK on success, SQLDBC_DATA_TRUNC if the provided buffer wasn't able store the complete name.
See also:
setCursorName

SQLDBC_Int4 SQLDBC::SQLDBC_Statement::getKernelVersion  )  const [inherited]
 

Gets the kernel version of the connection of the statement.

  • 1 digit major number,
  • 2 digits minor number,
  • 2 digits correction level.
    Returns:
    SQLDBC_Int4 The kernel version, which is a computed major * 10000 + minor * 100 + correction_level. E.g. version 7.4.4 has the version number 70404.

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::getLastInsertedKey SQLDBC_Int4  tag,
SQLDBC_HostType  type,
void *  paramAddr,
SQLDBC_Length lengthIndicator,
SQLDBC_Length  size,
SQLDBC_Bool  terminate = SQLDBC_TRUE
[inherited]
 

Retrieves the key that was inserted by the last insert operation.

Parameters:
tag The tag that describes whether to get the last or the first serial key. One of SQLDBC_FIRST_INSERTED_SERIAL, SQLDBC_LAST_INSERTED_SERIAL.
type The output host type.
paramAddr The parameter address.
lengthIndicator The length or indicator value.
size The size of the output parameter, in bytes.
terminate Whether output strings are terminated. Default is SQLDBC_TRUE.
Returns:
SQLDBC_OK, if the value is returned, SQLDBC_NOT_OK if an error is set, SQLDBC_NO_DATA_FOUND if the statement didn't inserted any key, or didn't report them to the interface.

const SQLDBC_UInt4 SQLDBC::SQLDBC_Statement::getMaxRows  )  const [inherited]
 

Returns the maximum number of rows allowed in a result set.

This value may be set with setMaxRows before the execution of an SQL statement.

Returns:
Maximum number of rows of a result set.
See also:
setMaxRows

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::getObject const SQLDBC_Int4  Index,
const SQLDBC_HostType  Type,
void *  paramAddr,
SQLDBC_Length LengthIndicator,
const SQLDBC_Length  Size,
SQLDBC_Length  StartPos,
const SQLDBC_Bool  Terminate = SQLDBC_TRUE
 

Retrieves and converts the value with an start offset in of the specified output column from a of the current row to a buffer.

The specified column value in the current row of this SQLDBC_PreparedStatement object is converted to the given length and SQLDBC_HostType and written to the output parameter buffer pointed to paramAddr.

It can be called multiple times to retrieve character or binary data in parts. For fixed-length datatypes getObject retrieves the same data multiple times. Mixing variable-length datatypes and fixed-length datatypes may produce unexpected results.

Parameters:
Index Index of the column. The first column is column number 1, the second is column number 2, ...
Type Parameter type of the output buffer.
paramAddr A pointer to the parameters output buffer.
LengthIndicator [out] Pointer to a variable that stores the column length or the indicator value SQLDBC_NULL_DATA if the column contains the NULL value. For character data it contains on success the number of bytes copied to the buffer, except the number of bytes necessary for the zero-terminator, if the Terminate flag was set. If the source string exceeds the Size value SQLDBC_DATA_TRUNC will be returned and LengthIndicator is set to the number of bytes (except the terminator bytes) needed to copy without truncation.
Size [in] Length of the parameter buffer in bytes. The Size argument is only necessary for non-integral data types. For character data the Size argument must be large enough to store the terminator byte(s) if the Terminate flag is set.
StartPos [in] Start position in the column from which on the data should be retrieved. Start position is counted in bytes from 1. Negative StartPos counts from the end of the column.
Terminate [in] Specifies that the output buffer must be finished with a C-style zero-terminator. The Terminate flag works only for the host var type character (ASCII, UCS2 or UTF8). As a default, all character data is zero-terminated.
Returns:
SQLDBC_OK on success SQLDBC_DATA_TRUNC if the output buffer was too small. SQLDBC_NOT_OK if a database access or conversion error occurred. In this case an error is set on this SQLDBC_PreparedStatement object.
See also:
bindColumn

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::getObject const SQLDBC_Int4  Index,
const SQLDBC_HostType  Type,
void *  paramAddr,
SQLDBC_Length LengthIndicator,
const SQLDBC_Length  Size,
const SQLDBC_Bool  Terminate = SQLDBC_TRUE
 

Retrieves and converts the value of the specified output column of the current row to a buffer.

The specified column value in the current row of this SQLDBC_PreparedStatement object is converted to the given length and SQLDBC_HostType and written to the output parameter buffer pointed to paramAddr.

It can be called multiple times to retrieve character or binary data in parts. For fixed-length datatypes getObject retrieves the same data multiple times. Mixing variable-length datatypes and fixed-length datatypes may produce unexpected results.

Parameters:
Index Index of the column. The first column is column number 1, the second is column number 2, ...
Type Parameter type of the output buffer.
paramAddr A pointer to the parameters output buffer.
LengthIndicator [out] Pointer to a variable that stores the column length or the indicator value SQLDBC_NULL_DATA if the column contains the NULL value. For character data it contains on success the number of bytes copied to the buffer, except the number of bytes necessary for the zero-terminator, if the Terminate flag was set. If the source string exceeds the Size value SQLDBC_DATA_TRUNC will be returned and LengthIndicator is set to the number of bytes (except the terminator bytes) needed to copy without truncation.
Size [in] Length of the parameter buffer in bytes. The Size argument is only necessary for non-integral data types. For character data the Size argument must be large enough to store the terminator byte(s) if the Terminate flag is set.
Terminate [in] Specifies that the output buffer must be finished with a C-style zero-terminator. The Terminate flag works only for the host var type character (ASCII, UCS2 or UTF8). As a default, all character data is zero-terminated.
Returns:
SQLDBC_OK on success SQLDBC_DATA_TRUNC if the output buffer was too small. SQLDBC_NOT_OK if a database access or conversion error occurred. In this case an error is set on this SQLDBC_PreparedStatement object.
See also:
bindColumn

SQLDBC_ParameterMetaData* SQLDBC::SQLDBC_PreparedStatement::getParameterMetaData  ) 
 

Retrieves an SQLDBC_ParameterMetaData object that contains information about the parameters used.

Returns:
An SQLDBC_ParameterMetaData object that contains information about the number, types and properties of the SQLDBC_PreparedStatement object's parameters. If the meta data cannot be retrieved, a NULL pointer is returned

SQLDBC_UInt4 SQLDBC::SQLDBC_PreparedStatement::getPreferredBatchSize  ) 
 

Get the optimum size for batch execution.

Applications that can adjust the size of records delivered at batch execution

Returns:
The batch size that is preferred by the database for optimum packet usage. This is 4294967295U if the application should deliver as many rows as it can itself handle.
See also:
getBatchSize

setBatchSize

SQLDBC_ResultSet* SQLDBC::SQLDBC_Statement::getResultSet  )  [inherited]
 

Retrieves a reference to the SQLDBC_ResultSet object.

Returns:
A reference to an SQLDBC_ResultSet object if the statement object has a result set, NULL otherwise.
See also:
isQuery

const ConcurrencyType SQLDBC::SQLDBC_Statement::getResultSetConcurrencyType  )  const [inherited]
 

Retrieves the type of the result set concurrency.

There are two kinds of concurrency:

  • The result set can be updated.
  • The result set is read-only (the default).

Returns:
type of the result set concurrency

SQLDBC_ResultSetMetaData* SQLDBC::SQLDBC_PreparedStatement::getResultSetMetaData  ) 
 

Retrieves an SQLDBC_ResultSetMetaData object that contains information about the columns of the SQLDBC_ResultSet object.

The SQLDBC_ResultSetMetaData contains information about the columns of the SQLDBC_ResultSet object that will be returned when the SQLDBC_PreparedStatement object is executed. Because an SQLDBC_PreparedStatement object is parsed, it is possible to get information about the ResultSet object that will be returned without having to execute the SQL statement. Consequently, it is possible to use this method with an SQLDBC_PreparedStatement object rather than executing it and then calling the getResultSetMetaData() method on the returned SQLDBC_ResultSet object.

Note:
Using this method may be expensive due to the time needed to retrieve the metadata from the underlying database kernel.
Returns:
An SQLDBC_ResultSetMetaData object that describes the columns or NULL if the meta data cannot be retrieved.

const ResultSetType SQLDBC::SQLDBC_Statement::getResultSetType  )  const [inherited]
 

Returns the type of a result set.

If the requested result set type isn't allowed for this SQL statement, the SQLDBC changes it to an allowed one. Check this with getResultSetType() if the execute() member function returns with a warning.

Returns:
FORWARD_ONLY,
SCROLL_SENSITIVE,
SCROLL_INSENSITIVE
See also:
setResultSetType

const SQLDBC_Int4 SQLDBC::SQLDBC_Statement::getRowsAffected  )  const [inherited]
 

Returns the number of rows affected by the executed SQL statement.

This method returns a non-zero value if more than one row was addressed by the SQL statement. If the return value is lower than zero, more than one rows was addressed but the exact number of addressed rows cannot be determined.

Returns:
Number of addressed rows

const SQLDBC_Int4* SQLDBC::SQLDBC_Statement::getRowStatus  )  const [inherited]
 

Returns the row status array.

The row status array describes the state of each row. The size of the row status array is increased by each addBatch() function call.

Returns:
A pointer to the first element of the row status array.
See also:
addBatch()

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::getTableName char *  buffer,
const SQLDBC_StringEncoding  encoding,
const SQLDBC_Length  bufferSize,
SQLDBC_Length bufferLength
const [inherited]
 

Retrieves the table name (for SELECT FOR UPDATE commands).

Parameters:
buffer The buffer in which into the table name is copied.
encoding Encoding of the buffer where the table name is stored.
bufferSize Size (in bytes) of the buffer
bufferLength [out] Number of bytes copied to the buffer, except the number of bytes necessary for the zero-terminator. If the source string exceeds the bufferSize value SQLDBC_DATA_TRUNC will be returned and the bufferLength set to the number of bytes (except the terminator bytes) needed to copy the table name without truncation.
Returns:
SQLDBC_OK on success, SQLDBC_DATA_TRUNC if the provided buffer wasn't able to store the complete name.
Deprecated:
This method is deprecated.
Use the methods provided by SQLDBC_ResultSetMetadata to access schema and table name for a result set column.

SQLDBC_Bool SQLDBC::SQLDBC_Statement::isQuery  )  const [inherited]
 

Checks if the SQL statement is a query.

A statement is a query only if it returns a result set. This can be determined only after execution of the statement object.

Note:
This method is overridden by the SQLDBC_PreparedStatement class, which can determine the query property before the statement is executed.
Returns:
SQLDBC_TRUE if the statement does produce a result set, SQLDBC_FALSE if not, or if it cannot be determined.
See also:
getResultSet

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::nextParameter SQLDBC_Int2 paramIndex,
void *&  paramAddr
 

Switches to the next input parameter if the application uses data at execute parameters.

After calling this member function, the paramIndex and the paramAddr parameters are set.

Deprecated:
Use nextParameterByIndex instead.

Parameters:
paramIndex Index of the next parameter.
paramAddr The data pointer that was supplied when binding the parameter, plus any offset that originates from a batch execution sequence (including row-wise binding).
Returns:
See also:
putData

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::nextParameterByIndex SQLDBC_Int2 paramIndex,
void *&  paramAddr
 

Switches to the input parameter if the application uses data at execute parameters,.

After calling this member function, the paramIndex and the paramAddr parameters are set. The paramIndex parameter is used to select the next parameter that is processed. You cannot process parameters that are bound to LOB columns before all parameters that are bound to non-LOB columns have been processed for a row.

Parameters:
paramIndex Index of the next parameter that shall be processed, or 0 if the application has no preferred next parameter.
paramAddr The data pointer that was supplied when binding the parameter, plus any offset that originates from a batch execution sequence (including row-wise binding).
Returns:
See also:
putData

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::prepare const char *  sql  ) 
 

Parses a zero-terminated ASCII coded SQL statement.

Parameters:
sql The zero-terminated string containing the SQL statement to be prepared. The given string must be ASCII coded.

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::prepare const char *  sql,
const SQLDBC_StringEncoding  encoding
 

Parses an ASCII/UNICODE coded zero-terminated SQL statement.

Parameters:
sql The zero-terminated string containing the SQL statement to be prepared. The code of the given string depends from the encoding argument.
encoding The character encoding of the sql argument.

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::prepare const char *  sql,
const SQLDBC_Length  sqlLength,
const SQLDBC_StringEncoding  encoding
 

Parses an ASCII/UNICODE coded SQL statement.

Parameters:
sql SQL statement to be prepared.
sqlLength Length in bytes of the SQL statement.
encoding Character code of the SQL statement.

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::putData void *  paramAddr,
SQLDBC_Length paramLengthIndicator
 

Put data for an input parameter.

Parameters:
paramAddr Pointer to the data which is to be assigned to the SQL parameter. The type of the data must match the type assigned by the bindParameter() member function.
paramLengthIndicator [in] Pointer to parameter length or indicator.
Returns:
See also:
nextParameter

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::setBatchSize SQLDBC_UInt4  rowarraysize  ) 
 

Sets the size of the row array for a batch execute.

Parameters:
rowarraysize [in] Number of rows for batch execution. A value of 1 specifies single row execution.
Returns:
SQLDBC_OK on success, SQLDBC_NOT_OK otherwise.
See also:
getBatchSize

SQLDBC_Retcode SQLDBC::SQLDBC_PreparedStatement::setBindingType SQLDBC_size_t  size  ) 
 

Sets the binding type for parameters.

The value of the parameter offset is normally 0, which implies a column-wise binding. If it is set to a value other than 0, a row-wise binding is applied. So, the address offset of the respective next parameter value is computed differently for column-wise and row-wise binding:

Column-wise Binding
byte length of the parameter
Row-wise Binding
size
Parameters:
size The parameter offset for row-wise binding, if set to 0, column-wise binding is applied.
Returns:
SQLDBC_OK always.
See also:
bindParameterAddr, clearParameters

SQLDBC_Retcode SQLDBC::SQLDBC_Statement::setCommandInfo const char *  buffer,
SQLDBC_Length  bufferLength,
SQLDBC_Int4  lineNumber
[inherited]
 

Sets the command info.

Sets the command info and a line number (for example name of programm and current line number). This will be send to the database kernel as part of a parse order. If the kernel runs in a special diagnose mode these information will be stored in a system table and can be used to profile your application. The column info and line number will be unset after the next execute of a SQL statement at this statement handle.

Parameters:
buffer The command info.
bufferLength Length in bytes of the buffer. In case a zero-terminated string passed on in the buffer argument, you can set the bufferLength to SQLDBC_NTS. Set bufferLength to SQLDBC_NULL_DATA if you want to unset the command info and line number.
lineNumber The line number.
Returns:
SQLDBC_OK on success, SQLDBC_DATA_TRUNC if the provided buffer was too long or SQLDBC_NOT_OK in case of an error.

void SQLDBC::SQLDBC_Statement::setCursorName const char *  buffer,
SQLDBC_Length  bufferLength,
const SQLDBC_StringEncoding  encoding
[inherited]
 

Sets the cursor name.

Setting the cursorname affects only query and database procedure commands. For DDL-, INSERT-, UPDATE- and DELETE- commands setting the cursorname has no effect.

Parameters:
buffer The new cursor name.
bufferLength Length in bytes of the buffer. In case a zero-terminated string passed on in the buffer argument, you can set the bufferLength to SQLDBC_NTS.
encoding Encoding of the cursor name.
Returns:
none
See also:
getCursorName

void SQLDBC::SQLDBC_Statement::setMaxRows SQLDBC_UInt4  rows  )  [inherited]
 

Limits the number of rows of an SQLDBC_ResultSet object.

The number of rows of the result set is truncated if the result of a query statement is larger than this limit. The default setting is 'unlimited' (0). Setting this limit does not affect an already executed SQL statement.

Parameters:
rows [in] Maximum number of rows of a result set
Returns:
none
See also:
getMaxRows

void SQLDBC::SQLDBC_Statement::setResultSetConcurrencyType ConcurrencyType  type  )  [inherited]
 

Sets the type of the result set concurrency.

There are two kinds of concurrency:

  • The result set can be updated.
  • The result set is read-only (the default).

Parameters:
type [in] The result set type. Possible values are:
CONCUR_READ_ONLY (default)
CONCUR_UPDATABLE
Returns:
none

void SQLDBC::SQLDBC_Statement::setResultSetFetchSize SQLDBC_Int2  rows  )  [inherited]
 

Sets the maximum number of be rows that can be fetched at once.

Sets the maximum number of rows to be fetched from a result set. Use this to manipulate the number of rows in the order interface. Use a value > 0 to set the maximum number of rows. Use a value <= 0 to reset this limit to the default value. The default value is 'unlimited' (32767). Setting this value does not affect an already executed SQL statement.

Parameters:
rows [in] Number of Rows to be fetched.
Returns:
none

void SQLDBC::SQLDBC_Statement::setResultSetType ResultSetType  type  )  [inherited]
 

Sets the type of a result set.

A result set is only created by a query command.

There are three kind of result sets:

  • The result set can only be scrolled forward.
  • The result set is scrollable but may change.
  • The result set is scrollable and not change (the default).

Parameters:
type [in] The result set type. Possible values are:
FORWARD_ONLY,
SCROLL_SENSITIVE,
SCROLL_INSENSITIVE (default)
Returns:
none
See also:
getResultSetType

SQLDBC_SQLWarning* SQLDBC::SQLDBC_ConnectionItem::warning  )  [inherited]
 

Returns a reference to an SQLWarning object stored in the SQLDBC_ConnectionItem object.

Note:
Getting the reference to the SQLWarning object will not clear the ErrorHndl object. All other function calls will empty the ErrorHndl object.
Returns:
The SQLWarning object stored in the item.