Index / Glossary
A | B | C | D | E | F | G | H | I | J | K | L | M
--- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | ---
N | O | P | Q | R | S | T | U | V | W | X | Y | Z

C |  | Column
| A column is another name for field in a SQL table. It has a data type (Integer, Char, Money etc) and a name by which it is addressed. You specify the name of a column in a query (either DELETE, UPDATE, SELECT or INSERT)
D |  | data source
| A data source defines all informationen needed by ODBC to connect to a database. This includes the name of the driver to use (Postgres, mySQL etc.), the name of the user, his password, the server name on which the database resides and of course the name of the database. There are a lot more options available.
| Data Types
| The following table show some ODBC data types and how the relate to standard C data types:
Type identifier | ODBC typedef | C typedef
--- | --- | ---
SQL_C_CHAR | SQLCHAR * | unsigned char *
SQL_C_SSHORT | SQLSMALLINT | short int
SQL_C_USHORT | SQLUSMALLINT | unsigned short int
SQL_C_SLONG | SQLINTEGER | long int
SQL_C_FLOAT | SQLREAL | float
SQL_C_DOUBLE | SQLDOUBLE, SQLFLOAT | double
SQL_C_BINARY | SQLCHAR * | unsigned char
SQL_C_TYPE_DATE | SQL_DATE_STRUCT | struct tagDATE_STRUCT { SQLSMALLINT year; SQLUSMALLINT month; SQLUSMALLINT day; } DATE_STRUCT;
SQL_C_TYPE_TIME | SQL_TIME_STRUCT | struct tagTIME_STRUCT { SQLUSMALLINT hour; SQLUSMALLINT minute; SQLUSMALLINT second; } TIME_STRUCT;
You will need the type identifier in calls to SQLBindCol.
O |  | odbc.ini
| `/etc/odbc.ini` is the configuration file for system data sources. It contains information which will be needed when connecting to a database. It is modified by a graphical utility ODBCConfig.
R |  | Row
| A row is a set of columns in a query. For example in our table there are two users. Each user makes up a row in the table or in the result of our query.
S |  | SQLAllocHandle
| allocates needed handles. `
    SQLRETURN
    SQLAllocHandle(SQLSMALLINT  HandleType,
                   SQLHANDLE    InputHandle,
                   SQLHANDLE   *OutputHandlePtr);
` #### Arguments ##### HandleType Defines the type of handle to be allocated by `SQLAllocHandle`. There are four possible values: `SQL_HANDLE_ENV SQL_HANDLE_DBC SQL_HANDLE_STMT SQL_HANDLE_DESC` ##### InputHandle This is the input handle in whose context the new handle will be allocated. If `HandleType` is `SQL_HANDLE_ENV`, this is `SQL_NULL_HANDLE`. For a handle of type `SQL_HANDLE_DBC`, this has to be an environment handle, and if it is `SQL_HANDLE_STMT` or `SQL_HANDLE_DESC`, it must be a connection handle. ##### OutputHandlePtr Pointer to a buffer in which to return the allocated handle. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,` or `SQL_ERROR`.
| SQLBindCol
| binds a variable to a column in the result. `
    SQLRETURN
    SQLBindCol(SQLHSTMT      StatementHandle,
               SQLUSMALLINT  ColumnNumber,
               SQLSMALLINT   TargetType,
               SQLPOINTER    TargetValuePtr,
               SQLINTEGER    BufferLength,
               SQLINTEGER   *StrLen_or_IndPtr);
` #### Arguments ##### StatementHandle `StatementHandle` must have been allocated by `SQLAllocHandle` and will hold all information and the result set of the statement. ##### ColumnNumber Number of the column in the result set. Starts with 1. ##### TargetType Type identifier of the data type ##### TargetValuePtr The pointer to the variable in which the data will be stored. ##### BufferLength The size of the buffer `TargetValuePtr` points at in bytes. ##### StrLen_or_IndPtr When data is fetched, returns either The length of the data available to return SQL_NO_TOTAL SQL_NULL_DATA #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR` or `SQL_INVALID_HANDLE`.
| SQLConnect
| connects to a datasource `
    SQLRETURN SQLConnect(SQLHDBC     ConnectionHandle,
                         SQLCHAR    *ServerName,
                         SQLSMALLINT NameLength1,
                         SQLCHAR    *UserName,
                         SQLSMALLINT NameLength2,
                         SQLCHAR    *Authentication,
                         SQLSMALLINT NameLength3);
` #### Arguments ##### ConnectionHandle `ConnectionHandle` must have been allocated by `SQLAllocHandle` and will hold all information about the connection. ##### ServerName Name of the database server ##### NameLength1 The length of `ServerName` or `SQL_NTS` ##### UserName The name of the user who connects to the database. ##### NameLength2 The length of `UserName` or `SQL_NTS` ##### Authentication Password of the user ##### NameLength3 The length of `Authentication` or `SQL_NTS` #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR` or `SQL_INVALID_HANDLE`.
| SQLDataSources
| fetches avaible datasource names either user, system or both. `
    SQLRETURN
    SQLDataSources(SQLHENV      EnvironmentHandle,
                   SQLUSMALLINT Direction,
                   SQLCHAR     *ServerName,
                   SQLSMALLINT  BufferLength1,
                   SQLSMALLINT *NameLength1Ptr,
                   SQLCHAR     *Description,
                   SQLSMALLINT  BufferLength2,
                   SQLSMALLINT *NameLength2Ptr);
` #### Arguments ##### EnvironmentHandle `EnvironmentHandle` must have been allocated by `SQLAllocHandle`. ##### Direction Which DSN we are looking for. May be on of:
`SQL_FETCH_FIRST` | Sets up `SQLDataSources()` to lookup the first of all available datasources (either user or systemwide).
`SQL_FETCH_FIRST_USER` | Sets up `SQLDataSources()` to lookup the first of the available user datasources.
`SQL_FETCH_FIRST_SYSTEM` | Sets up `SQLDataSources()` to lookup the first of the available system datasources.
`SQL_FETCH_NEXT` | Fetches the next datasource. Depending on `SQL_FETCH_FIRST_USER`, `SQL_FETCH_FIRST_SYSTEM` or `SQL_FETCH_FIRST` this may only be a user datasource, only a system datasource or one of either.
##### ServerName The name of the datasource is returned herein. ##### BufferLength1 Defines how many chars Servername may contain at most. ##### NameLength1Ptr The pointer to the variable in which the actual length of the datasource name is stored. If NameLength1Ptr is greater than BufferLength1, then the DSN in ServerName is truncated to fit. ##### BufferLength The size of the buffer `TargetValuePtr` points at in bytes. ##### Description The description supplied with the datasource, giving more information on the datasource in human readable form. ##### BufferLength2 Defines how many chars Description may contain at most. ##### NameLength2Ptr The pointer to the variable in which the actual length of the description is stored. If NameLength2Ptr is greater than BufferLength2, then the description in Description is truncated to fit. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR`, `SQL_NO_DATA>` or `SQL_INVALID_HANDLE`.
| SQLExecDirect
| Executes a SQL statement `
    SQLRETURN SQLExecDirect(SQLHSTMT    StatementHandle,
                            SQLCHAR    *StatementText,
                            SQLINTEGER  TextLength);
` #### Arguments ##### StatementHandle `StatementHandle` must have been allocated by `SQLAllocHandle` and will hold all information and the result set of the statement. ##### StatementText The SQL statement to be executed ##### TextLength The length of `StatementText` or `SQL_NTS` #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR` or `SQL_INVALID_HANDLE`.
| SQLDisconnect
| disconnects the specified connection `
    SQLRETURN SQLDisconnect(SQLHDBC     ConnectionHandle);
` #### Arguments ##### ConnectionHandle The handle of the connection to be closed. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,` or `SQL_ERROR`.
| SQLFetch
| Fetches the next row of the result set. `
    SQLRETURN SQLFetch(SQLHDBC     StatementHandle);
` #### Arguments ##### StatementHandle The handle of the statement to be closed fromwhich the data should be fetched. #### Returns `SQL_SUCCESS, SQL_NO_DATA, SQL_STILL_EXECUTING, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,` or `SQL_ERROR`.
| SQLFreeHandle
| frees allocated handles. `
    SQLRETURN SQLFreeHandle(SQLSMALLINT  HandleType,
                            SQLHANDLE    InputHandle);
` #### Arguments ##### HandleType Defines the type of handle to be freed. There are four possible values: `SQL_HANDLE_ENV SQL_HANDLE_DBC SQL_HANDLE_STMT SQL_HANDLE_DESC` ##### InputHandle The handle to be freed. Should match the type stated by `HandleType` #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_INVALID_HANDLE,` or `SQL_ERROR`.
| SQLNumResultCols
| returns the number of columns in the result set. `
    SQLRETURN SQLNumResultCols(SQLHSTMT     StatementHandle,
                               SQLSMALLINT *ColumnCountPtr);
` #### Arguments ##### StatementHandle `StatementHandle` must have been allocated by `SQLAllocHandle` and holds all information and the result set of the statement. ##### ColumnCountPtr A pointer to a variable to hold the result value. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_INVALID_HANDLE,` or `SQL_ERROR`.
| SQLRowCount
| returns the number of rows affected by INSERT, UPDATE or DELETE. Many drivers (but not all) return the number of rows returned by the last executed SELECT statement too. `
    SQLRETURN SQLSQLRowCount(SQLHSTMT     StatementHandle,
                             SQLSMALLINT *RowCountPtr);
` #### Arguments ##### StatementHandle `StatementHandle` must have been allocated by `SQLAllocHandle` and holds all information and the result set of the statement. ##### RowCountPtr A pointer to a variable to hold the result value. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_STILL_EXECUTING, SQL_INVALID_HANDLE,` or `SQL_ERROR`.
| SQLSetConnectAttr
| modifies attributes of connections. `
    SQLRETURN SQLSetConnectAttr(SQLHDBC    ConnectionHandle,
                                SQLINTEGER Attribute,
                                SQLPOINTER ValuePtr,
                                SQLINTEGER StringLength);
` #### Arguments ##### ConnectionHandle `ConnectionHandle` must have been allocated by `SQLAllocHandle` and defines the connection which will be modified. ##### Attribute which attribute to set ##### ValuePtr Pointer to the value for `Attribute`. Depending on `Attribute`, `ValuePtr` will be a 32-bit integer value or a pointer to a null-terminated string. ##### StringLength If `ValuePtr` points to a character string or a binary buffer, this argument should be the length of `*ValuePtr`. Otherwise, for `ValuePtr` of type integer `StringLength` is ignored. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR` or `SQL_INVALID_HANDLE`.
| SQLSetEnvAttr
| sets attributes of environments. `
    SQLRETURN  SQLSetEnvAttr(SQLHENV    EnvironmentHandle,
                             SQLINTEGER Attribute,
                             SQLPOINTER ValuePtr,
                             SQLINTEGER StringLength);
` #### Arguments ##### EnvironmentHandle `EnvironmentHandle` must have been allocated by `SQLAllocHandle` ##### Attribute which attribute to set ##### ValuePtr Pointer to the value for `Attribute`. Depending on `Attribute`, `ValuePtr` will be a 32-bit integer value or a pointer to a null-terminated string. ##### StringLength If `ValuePtr` points to a character string or a binary buffer, this argument should be the length of `*ValuePtr`. Otherwise, for `ValuePtr` of type integer `StringLength` is ignored. #### Returns `SQL_SUCCESS, SQL_SUCCESS_WITH_INFO, SQL_ERROR` or `SQL_INVALID_HANDLE`.