Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members   Related Pages  

CPLODBCStatement Class Reference

#include <cpl_odbc.h>

List of all members.

Public Methods

void Clear ()
void Append (const char *)
void Append (int)
void Append (double)
int Appendf (const char *,...)
int ExecuteSQL (const char *=NULL)
int Fetch (int nOrientation=SQL_FETCH_NEXT, int nOffset=0)
int GetColCount ()
const char * GetColName (int iCol)
short GetColType (int iCol)
short GetColSize (int iCol)
short GetColPrecision (int iCol)
short GetColNullable (int iCol)
int GetColId (const char *)
const char * GetColData (int, const char *=NULL)
const char * GetColData (const char *, const char *=NULL)
int GetColumns (const char *pszTable, const char *pszCatalog=NULL, const char *pszSchema=NULL)
void DumpResult (FILE *fp, int bShowSchema=FALSE)

Static Public Methods

const char * GetTypeName (int)


Detailed Description

Abstraction for statement, and resultset.

Includes methods for executing an SQL statement, and for accessing the resultset from that statement. Also provides for executing other ODBC requests that produce results sets such as SQLColumns() and SQLTables() requests.


Member Function Documentation

void CPLODBCStatement::Append double    dfValue
 

Append to internal command.

The passed value is formatted and appended to the internal SQL command text.

Parameters:
dfValue  value to append to the command.

void CPLODBCStatement::Append int    nValue
 

Append to internal command.

The passed value is formatted and appended to the internal SQL command text.

Parameters:
nValue  value to append to the command.

void CPLODBCStatement::Append const char *    pszText
 

Append text to internal command.

The passed text is appended to the internal SQL command text.

Parameters:
pszText  text to append.

int CPLODBCStatement::Appendf const char *    pszFormat,
...   
 

Append to internal command.

The passed format is used to format other arguments and the result is appended to the internal command text. Long results may not be formatted properly, and should be appended with the direct Append() methods.

Parameters:
pszFormat  printf() style format string.
Returns:
FALSE if formatting fails dueto result being too large.

void CPLODBCStatement::Clear  
 

Clear internal command text.

void CPLODBCStatement::DumpResult FILE *    fp,
int    bShowSchema = FALSE
 

Dump resultset to file.

The contents of the current resultset are dumped in a simply formatted form to the provided file. If requested, the schema definition will be written first.

Parameters:
fp  the file to write to. stdout or stderr are acceptable.
bShowSchema  TRUE to force writing schema information for the rowset before the rowset data itself. Default is FALSE.

int CPLODBCStatement::ExecuteSQL const char *    pszStatement = NULL
 

Execute an SQL statement.

This method will execute the passed (or stored) SQL statement, and initialize information about the resultset if there is one. If a NULL statement is passed, the internal stored statement that has been previously set via Append() or Appendf() calls will be used.

Parameters:
pszStatement  the SQL statement to execute, or NULL if the internally saved one should be used.
Returns:
TRUE on success or FALSE if there is an error. Error details can be fetched with OGRODBCSession::GetLastError().

int CPLODBCStatement::Fetch int    nOrientation = SQL_FETCH_NEXT,
int    nOffset = 0
 

Fetch a new record.

Requests the next row in the current resultset using the SQLFetchScroll() call. Note that many ODBC drivers only support the default forward fetching one record at a time. Only SQL_FETCH_NEXT (the default) should be considered reliable on all drivers.

Currently it isn't clear how to determine whether an error or a normal out of data condition has occured if Fetch() fails.

Parameters:
nOrientation  One of SQL_FETCH_NEXT, SQL_FETCH_LAST, SQL_FETCH_PRIOR, SQL_FETCH_ABSOLUTE, or SQL_FETCH_RELATIVE (default is SQL_FETCH_NEXT).
nOffset  the offset (number of records), ignored for some orientations.
Returns:
TRUE if a new row is successfully fetched, or FALSE if not.

int CPLODBCStatement::GetColCount  
 

Fetch the resultset column count.

Returns:
the column count, or zero if there is no resultset.

const char * CPLODBCStatement::GetColData const char *    pszColName,
const char *    pszDefault = NULL
 

Fetch column data.

Fetches the data contents of the requested column for the currently loaded row. The result is returned as a string regardless of the column type. NULL is returned if an illegal column is given, or if the actual column is "NULL".

Parameters:
pszColName  the name of the column requested.
pszDefault  the value to return if the column does not exist, or is NULL. Defaults to NULL.
Returns:
pointer to internal column data or NULL on failure.

const char * CPLODBCStatement::GetColData int    iCol,
const char *    pszDefault = NULL
 

Fetch column data.

Fetches the data contents of the requested column for the currently loaded row. The result is returned as a string regardless of the column type. NULL is returned if an illegal column is given, or if the actual column is "NULL".

Parameters:
iCol  the zero based column to fetch.
pszDefault  the value to return if the column does not exist, or is NULL. Defaults to NULL.
Returns:
pointer to internal column data or NULL on failure.

int CPLODBCStatement::GetColId const char *    pszColName
 

Fetch column index.

Gets the column index corresponding with the passed name. The name comparisons are case insensitive.

Parameters:
pszColName  the name to search for.
Returns:
the column index, or -1 if not found.

const char * CPLODBCStatement::GetColName int    iCol
 

Fetch a column name.

Parameters:
iCol  the zero based column index.
Returns:
NULL on failure (out of bounds column), or a pointer to an internal copy of the column name.

short CPLODBCStatement::GetColNullable int    iCol
 

Fetch the column nullability.

Parameters:
iCol  the zero based column index.
Returns:
TRUE if the column may contains or FALSE otherwise.

short CPLODBCStatement::GetColPrecision int    iCol
 

Fetch the column precision.

Parameters:
iCol  the zero based column index.
Returns:
column precision, may be zero or the same as column size for columns to which it does not apply.

short CPLODBCStatement::GetColSize int    iCol
 

Fetch the column width.

Parameters:
iCol  the zero based column index.
Returns:
column width, zero for unknown width columns.

short CPLODBCStatement::GetColType int    iCol
 

Fetch a column type.

The return type code is a an ODBC SQL_ code, one of SQL_UNKNOWN_TYPE, SQL_CHAR, SQL_NUMERIC, SQL_DECIMAL, SQL_INTEGER, SQL_SMALLINT, SQL_FLOAT, SQL_REAL, SQL_DOUBLE, SQL_DATETIME, SQL_VARCHAR, SQL_TYPE_DATE, SQL_TYPE_TIME, SQL_TYPE_TIMESTAMPT.

Parameters:
iCol  the zero based column index.
Returns:
type code or -1 if the column is illegal.

int CPLODBCStatement::GetColumns const char *    pszTable,
const char *    pszCatalog = NULL,
const char *    pszSchema = NULL
 

Fetch column definitions for a table.

The SQLColumn() method is used to fetch the definitions for the columns of a table (or other queriable object such as a view). The column definitions are digested and used to populate the CPLODBCStatement column definitions essentially as if a "SELECT * FROM tablename" had been done; however, no resultset will be available.

Parameters:
pszTable  the name of the table to query information on. This should not be empty.
pszCatalog  the catalog to find the table in, use NULL (the default) if no catalog is available.
pszSchema  the schema to find the table in, use NULL (the default) if no schema is available.
Returns:
TRUE on success or FALSE on failure.

const char * CPLODBCStatement::GetTypeName int    nTypeCode [static]
 

Get name for SQL column type.

Returns a pointer to an internal static string name for the indicate type code (as returned from CPLODBCStatement::GetColType().

Parameters:
nTypeCode  the SQL_ code, such as SQL_CHAR.
Returns:
internal string, "UNKNOWN" if code not recognised.


The documentation for this class was generated from the following files:
Generated on Mon Oct 6 16:31:38 2003 for SDTS_AL by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002