Home
ODBC Users` Manual - ALTIBASE Customer Support
Contents
1. Prompt the user for the value of the parameter and store it in the memory allocated earlier For simplicity this function does not check the value against the information returned by SQLDescribeParam Instead the driver does this when a statement is executed strcpy char PtrArray il AAAAAAA BufferLenArray i 7 57 ODBC Functions SQLDisconnect SQLDisconnect SQLDisconnect colses a connection and releases the handles for the connection Syntax SQLRETURN SQLDisconnect SQLHDBC dbc Arguments Data Type Argument In Out Description SOLHDBC dbc Input Connection Handle Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description If an application calls SOLDisconnect before releasing the statement handles related to the con nection the connection with the database will be closed When SQL SUCCESS WITH INFO is returned it means that database is successfully disconnected but additional errors or specified implementation program data exist The cases are as follows An error occurred after disconnection When connection is not established due to other problems such as communication failure An application can use the databasec to request another SQLConnect after successfully calling SOLDisconnect To connect another database after calling this function call SOLConnect or SOLDriverConnect ODBC Users Manual
2. Specify a file to put the result values of Select strcpy fileName Terminator2 avi if SQLBindFileToCol stmt 1 fileName amp fileNameLength amp fileOptions 16 amp valueLength SQL SUCCESS execute err dbc stmt SQLBindFileToCol ODBC Users Manual 180 SQLBindFileToCol SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLExecute stmt SQL SUCCESS execute err dbc stmt SQLExecute SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLFetch stmt SOL SUCCESS else printf SQLFetch success n execute err dbc stmt SOLFetch ni Write three LOB s to a file SOLCHAR fileName 3 10 SQLINTEGER fileNameLength 3 SQLUINTEGER fileOptions 3 SOLINTEGER valueLength 3 if SQLSetStmtAttr stmt SOL ATTR ROW ARRAY SIZE SQLPOINTER 3 0 SOL SUCCESS execute err dbc stmt SOLSetStmtAttr SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLSetStmtAttr stmt SQL ATTR ROW BIND TYPE SQL BIND BY COLUMN 0 SOL SUCCESS execute err dbc stmt SOLSetStmtAttr SOLFreeStmt stmt SQL DROP return SQL ERROR strcpy query SELECT i2 FROM T1 WHERE il gt 1 AND il lt 3 if SQLExecDirect stmt query SQL NTS SQL SUCCESS execute err dbc stmt SOLExecDirect SOLFreeStmt stmt SQL DROP return SOL ERROR Specify a file to put the re
3. When the function SOLDisconnect is called all commands related to the connection handle will be terminated This function converts the connection status into allocated connection status Before the command status becomes SO the connection status will become C4 connected connection SoUnallocated S1Allocated S2Prepared S6Infetch IH S NR gt S NR gt S1 24000 S R gt S6 S R gt S6 E gt S1 233 ODBC Error Codes Statement State Transition related Errors SOUnallocated S1Allocated S2Prepared S6Infetch IH HYO10 S NR gt 24000 S R gt S6 E gt SOUnallocated S1Allocated S2Prepared S6Infetch 1H HYO10 HYO10 S gt RD NF E gt if NP gt S1 if P gt S2 SoUnallocated S1Allocated S2Prepared S6Infetch y HYO10 HY010 HY010 IH SO SO SO 1 When the handle type of the first row is SQL HANDLE ENV or SQL HANDLE DBC 2 When the handle type of the second row is SOL HANDLE STMT ODBC User s Manual 234 SOUnallocated S1Allocated S2Prepared S6Infetch 1H E NP gt S1 P gt S2 Statement State Transition related Errors SoUnallocated S1Allocated S2Prepared S6Infetch 1H SO SO SO 1 When fOption of the first row is SOL CLOSE 2 W
4. SQLSMALLINT stringLength Size specified in message text Return Value SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR ODBC Users Manual 104 SOLGetDiagRec Description This retrieves several attributes of diagnostic message Related Function SQLGetDiagField 105 ODBC Functions SQLGetEnvAttr SQLGetEnvAttr This retrieves attribute value of environment handle Syntax SOLRETURN SQLGetEnvAttr SOLHENV env SOLINTEGER attribute SOLPOINTER value SOLINTEGER bufferLength SOLINTEGER stringLength Argument Data Type Argument In Out Description SOLHENV env In Environment Handle SOLINTEGER attribute In This inserts attribute of envionment han dle SOLPOINTER value Out Buffer pointer where attributes are saved SQLINTEGER bufferLength In Size of Attribute Value SQLINTEGER stringLength Out Size specified in the value of attribute Return Value SQL SUCCESS SQL SUCCESS WITH INFO SQL NO DATA SOL INVALID HANDLE SOL ERROR Description This retrieves attribute value of environment handle ODBC Users Manual 106 SQLGetEnvAttr SOLSTATE Description Comments HY000 General Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle HY092 Invalid Attribute or Option The value specified in attribute is not valid one
5. 80 Syntax 80 Arguments 80 Return Values Description 81 Re Ile CN ER Related FUNGON EE 83 EX lios toni 83 Kl e aiii 84 KEE 84 A NR RAN 84 ET 84 Description Rc EE 84 Related REUNEN aii RN HE RHONE RR al ssan z vela Re dokn 84 E lina 84 A EE TIL EES ed 86 PLS Aa AER 86 Lige ie VE 86 Return VES ri cid 86 DN odiada 86 Related FUNGON EE 86 Example 86 SQLFreeHandle 87 Syntax 87 Arguments 87 Return Values 2 87 Description 2 87 Diagnosis 88 Related FUNCTIONS imanen eienn iira EON ATAO R E ENARA at 88 a C nel ee SS 88 EIGNET 89 Syntax sese is sed Mee DAMNA M ie 89 lge ln 89 TE IT 89 Des d Le EE ER DIA le DEE 90 Related e E 90 Su 90 SUAGM A EE 91 LU 91 Return VALU SS creseicassescssczcsaescssdscosxcossecsscgssasaaassocucossaseiasssdcobsetesncnantasda4xesseoessosascoecs ESEESE IEE AENEIS eese EATS ECOSSE aaa SiTe 91 DN Ee ER BE le DC ER Related FUNGON Seea EE DEA 93 EXAMP E EIER Lm 93 SQL Get RE KE 94 RNA 94 ATM E 94 Ret rn A A UTN Rep to du 95 Description er 95 IB le ETE o RO 96 ECIEwTeaaseiegpd e 96 Example see e eege 97 SOLGetDescEleld z e SE Pr EE oe P Re EE e ER EE bee ere e epe 98 NN N
6. Syntax SQLRETURN SQLAllocEnv SOLHENV env Arguments Data Type Argument In Out Description SOLHENV env Output Environment handle pointer Return Values SOL SUCCESS SOL ERROR Description One application can use various environment variables To use resources of the ODBC the program that called SOLAllocEnv must not terminate or get out of the stack Otherwise an application may lose the statement handles and other allocated resources Before calling SOLAllocConnect or other ODBC functions an application must call this function Then the env value will be sent to all functions that require the environment handles as input val ues Related Functions SOLAllocConnect SOLAllocStmt SOLFreeEnv ODBC Users Manual 20 Example See SALTIBASE_HOME sample SQLCLI demo_ex1 cpp Memory allocation for the environment if SQLAllocEnv amp env SOL SUCCESS printf SQLAllocEnv error WMn return SQL ERROR 21 SQLAllocEnv ODBC Functions SQLAllocHandle SQLAllocHandle SQLAllocHandle allocates and initializes the memory for the environment connection and state ment handles Syntax SQLRETURN SQLAllocHandle SOLSMALLINT HandleType SOLHANDLE InputHandle SOLHANDLE OutputHandlePtr Arguments Data Type Arguments In Out Description SOLSMALLINT HandleType Input One of the following handle type is allocated SQL HANDLE ENV SQL HANDLE DBC
7. Attribute Contents SOL ATTR ODBC VERSION SOL OV ODBC3 or SOL OV ODBC2 Applied only in Win32 SOLSTATE Description Comments HYO0OO General error SOLAllocHandle ODBC Users Manual 150 SQLSetStmtAttr SQLSetStmtAttr sets the attribute related to the statement handle SQLSetStmtAttr SQLSetStmtAttrW as a Unicode string supports same execution as SQLSetStmtAttr Syntax SQLRETURN SQLSetStmtAttr SQLHSTMT stmt SQLINTEGER Attribute SQLPOINTER param SQLINTEGER StringLength Arguments Data Type Argument In Out Description SOLHENV stmt Input Statement handle 151 ODBC Functions SQLSetStmtA ttr Data Type Argument In Out Description SOLINTEGER Attribute Input Attribute to set Supported attribute value SQL ATTR CONCURRENCY SQL ATTR CURSOR SCROLLABLE SQL ATTR CURSOR SENSITIVITY SQL ATTR CURSOR TYPE SQL ATTR PARAM BIND TYPE SQL ATTR PARAM STATUS PIR SQL ATTR PARAMS PROCESSED PTR SQL ATTR PARAMS ROW COUNTS PTR SQL ATTR PARAMS SET ROW COUNTS SQL ATTR PARAMSET SIZE SQL ATTR ROW ARRAY SIZE SQL ATTR ROW BIND TYPE SQL ATTR ROW STATUS PTR SOL ATTR ROWS FETCHED PIR ALTIBASE STMT ATTR ATOMIC ARRAY Attribute value which is not currently being supported SOL ATTR APP PARAM DESC SOL ATTR APP ROW DESC SQL ATTR ASYNC ENABLE SOL ATTR ENABLE AUTO IPD SQL ATTR F
8. Change the CLOB of multiple records to Retail at once SOLCHAR buf 6 SOLINTEGER lobInd SQLUBIGINT lobLoc strcpy query UPDATE T1 SET i2 WHERE il gt 1 AND i1 100 if SOLPrepare stmt query SQL NTS SQL SUCCESS execute err dbc stmt SOLPrepare SOLFreeStmt stmt SQL DROP return SQL ERROR If an UPDATE query is executed after a LOB locator parameter is being out bound LOB columns to be updated will be truncated to null automatically if SQLBindParameter stmt 1 SOL PARAM OUTPUT SQL C CLOB LOCATOR SOL CLOB LOCATOR 0 0 amp lobLoc 0 amp lobInd SQL SUCCESS execute err dbc stmt SQLBindParameter SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLExecute stmt SOL SUCCESS execute err dbc stmt SOLExecute SOLFreeStmt stmt SOL DROP return SQL ERROR memcpy buf Retail 6 if SQLPutLob stmt SOL C CLOB LOCATOR lobLoc 0 0 SQL C CHAR buf 6 SOL SUCCESS execute err dbc stmt SOLPutLob SQLFreeStmt stmt SOL DROP return SQL ERROR if SQLFreeLob stmt lobLoc SQL SUCCESS execute err dbc stmt SOLFreeLob SOLFreeStmt stmt SOL DROP return SQL ERROR ODBC Users Manual 200 SQLFreeLob SQLFreeLob SQLFreeLob releases resources that are related to a LOB locator opened during the current transac tion Syntax SOLRETURN SQLFreeLob SOLHSTMT stmt SOLUBIG
9. Preparing Direct Executing SQLPrepared SQLBindParameter SQLExecuted SOQLExecDirect Getting results of SELECT Getting results of statements INSERT UPDATE DELETE statements SQLRowCount SQLNumhResultCols Q SOLDescribeCol SOLColAttribute SQLBindCold SQLFetch PT A A ZA 5 ODBC Introduction Using the ODBC This step is for releasing the handles and meory allocated by an application and finishing an appli cation Diagnosis is to handle the warning or error status occurred in an application There are 2 Levels of disgnosis messages in the ODBC Return Values Description SQL SUCCESS Successful completion of the function SQL SUCCESS WITH INFO Successful execution with warning and other informa tion SOL NO DATA FOUND The function is successful but there is no related data SOL ERROR Failure of the function SOL INVALID HANDLE The function failed due to invalid input handles The diagnosis messages are returned except the case of SOL SUCCESS SOL NO DATA FOUND SQL INVALID HANDLE To check the diagnosis message call SOLGetDiagRec SOLGetDiagField lagnosis iviessages The diagnosis message is a five bytes alphanumeric character string The heading two characters refer to the class and the next three character refer to the sub class The Altibase ODBC diagnosis messages follow the standard of X Open SQL CAE specifications
10. STEP 3 EXECUTE Catalog function or SQLBindParameter 4 4 SOLExecbirect The SOLExecDirect function called to execute an SQL statement In case to execute multiple times for the performance preparation and execution will be made by SOLPrepare and SOLExecute respectively If an SQL statement includes the arguments an application will call SOLBindParameter and bind each argument with an application variable Before the argument is bound SOLPrepare must be executed After binding is made SOLExecute can be executed An application can delay execution of an SOL statement and may call the function that returns the ODBC Users Manual 10 Basic Programming Steps database metadata instead We called those functions as catalog functions The action of an application depends on the execution type of an SOL statements SQL Statement Types Actions SELECT or catalog function Phase 4a Get the results UPDATE DELETE or INSERT Phase 4b Get the number of affected rows Other SOL Statements Phase 3 Build and execute an SQL statement or Phase 5 Commit the transaction een ee Results This phase is the step to fetch the results STEP 4a FETCH RESULTS SOLNumResultCols SQLDescribeCol SQLBindCol SQLFetch SQLGetData If a statements executed in the Step 3 is SELECT or catalog function an application calls SOLNumRe sultCols
11. guments SOLHDBC SOLCHAR SOLSMALLINT SOLCHAR SOLSMALLINT SOLCHAR SOLSMALLINT SQLConnect dbc db dbLength usr usrLength pwd pwdLength Data Type Argument In Out Description SOLHDBC dbc Input Connection Handle SQLCHAR Db Input Host IP SQLSMALLINT dbLength Input The character number of db SOLCHAR usr Input User Identifier SOLSMALLINT usrLength Input The character number of usr SOLCHAR pwd Input Authentication character string pass word SOLSMALLINT pwdLength Input The character number of pwd Return Values SOL SUCCESS SQL SUCCESS WITH INFO SQL INVALID HANDLE SOL ERROR ODBC Users Manual 50 SOL Connect The input length Arguments dbLength usrLength pwdLength can be set to actual length of the related data SOL NTS to indicate that the related data terminated with NULL or a length value that does not include a NULL termination character can be set SOLAllocConnect must be called before this function This function must be called before SOLAllocStmt Informations such as IP address user name and password can be set by SOLSetConnectAttr as an argument string You set the parameters excepting dbc on null or zero in the distributed transaction Reference the SOLSetConnectAttr SOLSTATE Description Comments 08001 Cannot be connected to the server ODBC cannot establish connection with the database 08002
12. SQLExecute SOLERROR SQLFreeConnect SQLFreeEnv SQLFetch SQLFreeStmt SOLPrepare SQLEndTran SQLTransact SQLSetConnectAttr SS include lt stdlib h gt include lt stdio h gt include lt string h gt include lt sqlcli h gt define SQL LEN 1024 define MSG LEN 1024 ODBC User s Manual 204 Sample of Simple Basic Program Hdefine MAXCOLS 100 int db error SOLHENV henv SOLHDBC hdbc SOLHSTMT hstmt int main SOLHENV henv SOLHDBC hdbc SOLHSTMT hstmt1 hstmt2 SOLCHAR server 20 uid 10 pwd 10 port 10 constr 100 guery SOL LEN id 9 name 31 dept 11 age 4 dept no 5 temp 31 tmp SOLINTEGER len SOLINTEGER bindp len SQLSMALLINT colnum SOLRETURN rc Get environment handle rc SQLAllocEnv amp henv VES rec EZ SOL ERROR Get connection handle re SQLAllocConnect henv amp hdbc if moz SOL ERROR Get server name port num uid pwd by user printf Enter Server Name amp Port num server port gets temp db error henv hdbc SOL NULL HSTMT db error henv hdbc SOL NULL HSTMT tmp strtok temp if tmp NULL printf You must specify Server name n SQLFreeConnect hdbc SQLFreeEnv henv exit 0 strcpy server tmp tmp Strtok NULL if tmp NULL printf You don t specify Port Nu
13. Set timeout value to prevent blocking that may occur in select or poll in an unstable net work DATE_FORMAT Date Format The default date format is YYYY MM DD HH MI SS ALTERNATESERVER Specifys the IP addresses and the connection port numbers of the alternative servers to use the connection failover feature For example the format is 192 168 1 2 20300 192 168 1 3 20300 IpcFilePath Client can t connect to server through IPC in Unix because they have different socket paths if having different ALTIBASE HOMES each other You can communicate with Unix domain by using ALTIBASE HOME trc cm ipc and then you can get information of shared memory APP INFO This sets information of program you connect to and you can check this with the following statement select CLIENT APP INFO from vSsession AUTOCOMMIT This denotes to set AUTOCOMMIT mode ON or OFF LONGDATACOMPAT This enables BLOB and CLOB to be types for ODBC when you connect to ODBC with data whose type is BLOB or CLOB YES or No InConnectionString DSN 192 168 1 11 UID SYS PWD MANAGER CONNTYPE 1 NLS_USE KO16KSC5601 PORT_NO 20 202 TIMEOUT 5 CONNECTION_TIMEOUT 10 DATE_FORMAT DD MON YYYY IPCFILEPATH cm You can access to database remotely with sysdba privilege but can t start up database When you try to contact local server with sysdba privilege through TCP IP in the state of no remote access specified in REMOTE_SYSDBA_ENABLE and no loop back 127 0 0 1 lo
14. The ODBC allocates the memory necessary for the command connects the statement handle and returns the handle related to OutputHandle An application sends OutputHandle value to the subsequent callings that require the statement handle 23 ODBC Functions SQLAllocHandle Diagnosis SOLSTATE Description Comments HYO000 General error HY001 Memory allocation error Failed to allocate the memory for the explicit handle HY009 Invalid arguments used OutputHandlePtr is a NULL pointer null pointer Related Functions SQLExecDirect SOLExecute SOLFreeHandle SOLPrepare SQLSetConnectAttr SQLSetEnvAttr SOLSetStmtAttr Example See SALTIBASE_HOME sample SQLCLI demo_meta1 cpp Memory allocation for the environment if SOLAllocHandle SOL HANDLE ENV SQL NULL HENV amp env SQL SUCCESS printf SQLAllocEnv error n return SQL ERROR Memory allocation for the connection if SQLAlLlocHandle SQL HANDLE DBC env printf SQLAllocConnect error n return SQL ERROR ODBC Users Manual 24 amp dbc SQL SUCCESS SQLAllocStmt SQLAllocStmt SQLAllocStmt allocates and initializes the memory for the SQL statements Up to 1024statements are allocated to one connection SQLAllocStmt can be replaced by SOLAllocHandle Syntax SQLRETURN SQLAllocStmt SQLHDBC dbc SQLHSTMT stmt Arguments Data Type Argume
15. decimal digits allowable in this string is given For example DECIMAL 12 5 string can return NUM_PREC_RADIX 10 COLUMN_SIZE 12 and DECIMAL_DIGITS 5 NULLABLE 11 SMALLINT SOL NO NULLS when the column is not NOT NULL allowed NULL or SOL_NULLABLE when NULL is allowed REMARKS 12 VARCHAR Description of the column COLUMN_DEF 13 VARCHAR Default value of the column SOL DATA TYPE 14 SMALLINT SOL data type NOT NULL SOL DATETIME _ 15 SMALLINT Subtype code for the data type NULL is SUB returned for other data types CHAR OCTET LE 16 INTEGER Maximum digits of the character of NGTH binary data type string For other data types NULL will be returned ORDINAL POSITI 17 INTEGER NOT Column order of the table The first col ON NULL umn number is 1 in the table IS NULLABLE 18 VARCHAR NO When the column does not include NULL YES When the column includes NULL SOLSTATE Description Comments 08S01 Communication channel error Communication channel error before the function processing is completed between the ODBC and the database HY000 General error SQLBindCol SQLFetch ODBC Users Manual 48 SOL Columns SOLStatistics SOLTables Example See SALTIBASE_HOME sample SQLCLI demo_meta2 cpp if SQLColumns stmt NULL 0 NULL 0 DEMO META2 SOL NTS NULL 0 SQL SUCCESS execute err dbc stmt SOLColumns SOLFreeStmt
16. SQLBindFileToParam SQLBindFileToParam binds the parameter market used for LOB data type to a file or files When SQLExecute or SQLExecDirect is called data is transferred from the file s to the database man agement system Syntax SOLRETURN SQLBindFileToParam SQLHSTMT stmt SOLSMALLINT par SQLSMALLINT sqlType SOLCHAR fileName SOLINTEGER fileNameLength SOLUINTEGER fileOptions SOLINTEGER maxFileNameLength SOLLEN ind Arguments Data Type Argument In Out Description SOLHSTMT stmt Input A handle for the found results SOLSMALLINT Par Input The order of parameters which begins at 1 SOLSMALLINT sglType Input The SQL data type of a parameter The fol lowing options are available SQL BLOB SQL CLOB SOLCHAR fileName Input Pend A pointer to the buffer that holds a file ing name or an array of filenames Upon SOLExecute or SOLExecDirect there should be a filename stored in this buffer Either of an absolute path recom mended and a relative path is allowed This argument cannot be NULL 183 LOB Interface SQLBindFileToParam Data Type Argument In Out Description SOLINTEGER fileName Input Pend A pointer to the buffer that holds a file Length ing name length or an array of filename lengths Upon SQLExecute or SOLExec Direct there should be a filename length stored in this buffer If this argu ment is NULL a filename is regarded as a null termi
17. printf NULL n else printf 3f n etc else execute err dbc stmt query break ODBC Users Manual 30 SQLCloseCursor This closes cursor and discards the suspended results SQLCloseCursor Syntax SOLRETURN SQLCloseCurosr SOLHSTMT stmt Arguments Data Type Argument In Out Description SOLHSTMT stmt In Command Handle Return Value SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description This closes cursor and discars the suspended results This option has same functionality as using SQL CLOSE option in SOLFreeStmt However 240000 errors occur if cursor is not open in SOLClose Corsor Diagnostics SOLSTATE Description Comments HYO000 General Error HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle 24000 The state of cursor is incorrect No cursor is open in command han dle 3l ODBC Functions SQLCloseCursor Related Function SOLFreeHandle ODBC Users Manual 32 SQLBindParameter SQLBindParameter SQLBindParameter binds the parameter marker of an SQL statement with an application variables The data is transmitted from an application to the database when SOLExecute is called e yntax SOLRETURN SQLBindParameter SQLHSTMT stmt SQLSMALLINT par SQLSMALLINT pType SQLSMALLINT cType SQLSMALLINT sqlType
18. ALTIBASE DATE FORMAT ODBC User s Manual 258 Other Changes SQLPOINTER YYYY MM DD SQL NTS SOLRowCount SOLMoreResults functions There are 2 results of ODBC Number of affected rows Result set ODBC CLI considers multiple results in Altibase 5 In other words you can get them by one execu tion Therefore returned results of SQLRoewCount are different from those of Altibase 4 when you use array binding SQLRowCount gets affected row count in current result SOLMoreResults moves to next result and returns SOL NO DATA if current result is last Example CREATE TABLE T1 I1 INTEGER INSERT INTO T1 VALUES 1 INSERT INTO T1 VALUES 2 repeat 1000 times SELECT FROM T1 T1 SQLINTEGER p1 3 SQLINTEGER p2 3 SOLLEN rowcount OL SOLLEN totalRowcount OL p1 0 10 p2 0 20 p1 1 100 p2 1 200 p1 2 11 p2 2 14 SQLSetStmtAttr stmt SOL ATTR PARAMSET SIZE 3 lt array binding SQLBindParameter stmt 1 pl SQLBindParameter stmt 2 p2 SOLExecDirect stmt SOLCHAR DELETE FROM T1 WHERE I1 AND I1 lt SQL NTS do SQLRowCount stmt amp rowcount printf dWMn rowcount totalRowcount rowcount rc SQLMoreResults stmt while rc SQL NO DATA 259 Upgrade Other Changes printf totalRowcount dMn totalRowCount Execution Results 9 gt This is affected row count of DELET
19. Calling SOL CLOSE SOL UNBIND or SQL RESET PARAMS with SOLFreeStmt does not reset the statement attribute To use a column wise binding set SOL ATTR PARAM BIND TYPE in Arguments Attribute of an application function SOLSetStmtAttr and set SOL PARAM BIND BY COLUMN in param ARRAY SIZE changes only PARAM SIZE at every execution moment PARAM STATUS PTR is the vaule to return if each column will be executed and specifies SOLSMALLINT array If succeeds SQL SUCCESS SQL SUCCESS WITH INFO will be returned and if fails then SOL PARAM UNUSED will be returned respectively For Macro values SOL PARAM SUCCESS is OSOL PARAM ERRORis 5 SOL PARAM SUCCESS WITH INFO is 65QL PARAM UNUSED is 7 SOLSetStmtAttr stmt SQL ATTR PARAM BIND TYPE SOL PARAM BIND BY COLUMN SQLSetStmtAttr stmt SOL ATTR PARAMSET SIZE ARRAY SIZE 0 SQLSetStmtAttr stmt SOL ATTR PARAM STATUS PTR ParamStatu sArray 0 Designates the pointer of the variables to store the number of columns processed by PARAMS PROCESSED PTR The pointer type of SOLINTEGER Then execute SOL BindParameter like before SOLSetStmtAttr stmt SOL ATTR PARAMS PROCESSED PTR amp ParamsProcessed 0 then Executing SQLBindParameter When using the row wise binding define the size of the structure in PARAM Bind Type unlike in the column wise binding SOLSetStmtAttr stmt SQL ATTR PARAM BIND TYPE sizeof struct SQLSetStm tAttr stmt SOL ATTR PARAMSET SIZE ARRA
20. DBC SQLFreeHandle ENY 9 ODBC Introduction Basic Programming Steps Step 1 Connecting to a Database The first step is to connect to the database The following functions are necessary for this step STEP 1 CONNECT SQLAllocHandle SQLSetEnvAttr SQLAllocHandle SQLDriverConnect SQLSetConnectAttr The first operation to access a database is to allocate the environment handle using SOLAllocHandle 0 An application sets the environmental attribute by calling SOLSetEnvAttr Then an application allocates the connection handle by using SOLAllocHandle and calls SOLDriv erConnect to connect to a database After connecting successfully an application can set the connection attributes by using SQLSetCon nectAttr Step 2 Initializing an application Status The second phase is usually to initialize an application as described in the figure below However each application can have different operations STEP 2 INITIALIZE SQLAllocStmt SQLSetStmtAttr An application allocates the statement handle by using SOLAllocStmt Most applications sets the status of application attributes by using SOLSetStmtAttr Step 3 Executing an SQL statements The third phase is to build and execute the SOLSTATEments as shown below The processing types in the phase can be different An application creates or executes an SQL statement based on an SOL statement requested by users
21. OC 00 SQL_C_DOUBLE O CO C OF OC OC OC O f SQL_C_BINARY OLO O SOL C TYPE DATE SOL C TYPE TIME O SOL C TYPE TIMESTAMP O SOL C BYTES O SQL_C_NIBBLE Default conversion Supported conversion 225 Data Types Converting C Data into SQL Data types ODBC User s Manual 226 ODBC Error Codes Appendix C ODBC Error Codes SQLERROR returns SQLSTATE as defined in X Open and SQL Access Group SQL CAE specification 1992 SQLSTATE is a five digit character string This Chapter contains the Altibase ODBC Drive Error refrence ODBC Error Codes SQLSTATE Error Can be returned from 01004 String data right truncated SQLDescribeCol SQLFetch SQLGetData 07006 Restricted data type attribute viola SQLBindParameter tion SQLExecute SQLFetch 07009 Invalid descriptor index SQLBindCol SQLBindParameter SQLColAttribute SQLDescribeCol SQLDescribeParam SQLGetData For SQLSTATE 08001 08002 08003 and 08501 see the next table 227 ODBC Error Codes ODBC Error Codes SQLSTATE Error Can be returned from HY000 General error SQLAllocStmt SQLAllocConnect SQLBindCol SQLBindParameter SQLColAttribute SQLColumns SQLConnect SQLDescribeCol SQLDisconnect SQLDriverConnect SQLEndTran SQLExecDirect SQLExecute SQLFetch SQLFreeHandle SQLFreeStmt SQLGetData SQLNumParams SQLNumResultCols SQLPrepare SQLPrimaryKe
22. ODBC Users Manual 70 SOL SUCCESS SQLExecute SQLExecute SQLExecute submits a prepared statement using the current values of the parameter marker vari ables if any parameter markers exist in the statement Syntax SOLRETURN SQLExecute SOLHSTMT stmt Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle Return Values SQL SUCCESS SQL SUCCESS WITH INFO SQL NO DATA FOUND SOL INVALID HANDLE SQL ERROR Description The parameter marker can be included in a SQL statement string The parameter marker specified by 7 and designates the place of the parameters to be replaced as an application variable when SQLEx ecute is called SOLBindParameter must bind each parameter marker with a corresponding application variable and displays whether the data must be converted for transmission All parame ters must be bound before SQLExecute is called SQLExecute executes a statement prepared by SQLPrepare After the application processes or dis cards the results from a call to SOLExecute the application can call SOLExecute again with new parameter values The command executed by SQLExecDirect cannot be execute again by SOLExecute SOLPrepare must be called first In case SOLExecute executes an UPDATE and DELETE statement that does not affect any row in the database calling SOLExecute will return SOL NO DATA Use SOLRowCount to chec
23. SOL NO DATA When the fact that the database does not support fColType fScope and fNullable arguments is stated SOLSpecialColumns will return the empty result set Name No Data Type Description SCOPE 1 SMALLINT SQL SCOPE SESSION value is fixed to 2 COLUMN NAME 2 VARCHAR Column Name As for the unnamed string ODBC NOT NULL returns the empty character string DATA TYPE 3 SMALLINT SQL data type NOT NULL TYPE NAME 4 VARCHAR Character string representing the name of the NOT NULL data type corresponding to DATA TYPE COLUMN SIZE 5 INTEGER Column Size NULL will be returned when the string size is not proper 159 ODBC Functions SQLSpecialColumns Name No Data Type Description BUFFER_LENGTH 6 INTEGER The maximum byte storing the data DECIMAL_DIGITS 7 SMALLINT The NULL will return the data type that cannot apply the decimal points of the column and the decimal points PSEUDO_COLUM 8 SMALLINT Maximum digits of the character of binary data N type string For other data types NULL will be returned SQLSTATE Description Comments 08S01 Communication line failure Communication channel failure before the function processing is completed between the ODBC and the database HY009 Use an invalid pointer null pointer szTableName is a NULL pointer SQLBindCol SQLColumns SOLFetch SOLPrimaryKeys See SALTIBASE_HOME sample SQL
24. SOLGetData stmt 9 SOL C SSHORT amp Searchable 0 NULL SOLGetData stmt 14 SOL C SSHORT amp MinScale 0 amp cbMinScale SOLGetData stmt 15 SOL C SSHORT amp MaxScale 0 amp cbMaxScale SOLGetData stmt 16 SOL C SSHORT amp SQLDataType 0 amp cbSQLDataType SOLGetData stmt 18 SOL C SLONG amp NumPrecRadix 0 amp cbNumPrecRadix printf 20s 10d 10d 10d t szTypeName if DataType Searchable SQL PRED NONE ColumnSize SQLDataType printf SQL PRED NONE n else if Searchable SQL PRED CHAR printf SQL PRED CHAR n Searchable else if SQL PRED BASIC printf SQL PRED BASIC ODBC Users Manual 116 SQLGetTypelInfo else if Searchable SQL SEARCHABLE printf SOL SEARCHABLE n Jh 117 ODBC Functions SQLMoreResult SQLMoreResult SQL MoreResult returns whether there is more result Syntax SOLRETURN SQLMoreResults SOLHSTMT stmt Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Instruction Handle Result Values SOL SUCCESS SOL NO DATA FOUND Description When a statement is fetched to obtain its result the corresponding cursor is located at the first record of the result set Depending on an application when its result set is used a further check is performed to see if there is more result left If there are more result values left SOL SUCCESS is returned and i
25. SOLSMALLINT cNameLength Input The character number of cName SOLCHAR sName Input Procedure Schema Name SQLSMALLINT sNameLength Input Length of character string of sName SQLCHAR pName Input Procedure name Cannot be a NULL pointer pName must not contain the string search patterns SQLSMALLINT pNameLength Input Character string of pName SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR 137 ODBC Functions SQLProcedures SOLProcedures displays the list of all procedures in the required range A user may have or have not a privilege to use and execute these procedures SQLProcedures returns the results in the format of the standard result set format sorted in order by PROCEDURE CAT PROCEDURE SCHEM and PROCEDURE NAME Note SOLProcedures may not return all procedures An application can use the valid procedures whether the procedure is returned by SQLProcedures or not Name No Data Type Description PROCEDURE CAT VARCHAR Procedure catalog identifier NULL if not applicable to the database PROCEDURE SCHEM VARCHAR Procedure schema identifier NULL if not applicable to the database PROCEDURE NAME VARCHAR Procedure identifier NOT NULL NUM INOUT PARAMS N A Reserved for future use An application must not apply any returned data to this result string NUM OUTPUT PARAMS N A Reserved for future use An application must no
26. SQL HANDLE STMT SOLHANDLE InputHandle Input If the input HandleType is SQL HANDLE ENV InputHan dle will be SOL Null Handle Or if the input HandleTyp is SQL HANDLE DBC it will be the environment handle In case of SOL HANDLE STMT it will be the connection handle SOLHANDLE OutputHandlePtr Output The pointer of the allocated handle Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR ODBC Users Manual 22 SQLAllocHandle SOLAllocHandle allocates the environment connection and statement handles to be described in the next paragraph This function will replace SOLAllocEnv SOLAllocConnect and SOLAllocStmt functions To request the environment handle an application calls SOLAllocHandle of which HandleTyp is SOL HANDLE ENV and input handle is SOL Null Handle To request the connection handle an application must call SOLAllocHandle of which HandleTyp is SQL HANDLE DBC and the input handle must be a valid environment handle To request the statement handle an application must call SOLAllocHandle of which HandleTyp is SOL HANDLE STMT and the input handle must be a valid connection handle One application can allocate multiple environment connection and statement handles at one time However several environment connection or statement handle cannot be used at the same time on another thread of one process The environment handle provid
27. SQL_ATTR_USE_BOOKMARKS SQL_ATTR_CURSOR_SCROLLABLE or SQL_ATTR_CURSOR_SENSITIVITY SQLStatistics See SQLColumns SQLTables See SQLColumns State Transition Tables The followings summarize the major functions that affect the state transition glia so S1 52 56 UNALLOCATED ALLOCATED PREPARED INFETCH Request Prepare IH S gt S1 S gt 52 24000 E gt S1 ExecDirect 1H S NR gt S1 S NR gt S1 24000 S R gt S6 S R gt S6 E gt S1 Execute IH HY010 S NR gt 52 24000 S R gt S6 E gt S2 Fetch IH HY010 HY010 S gt S6 RD NF E gt if NP gt S1 if P gt 52 FreeStmt CLOS IH S1 S2 NP gt S1 E P gt 52 237 ODBC Error Codes State Transition Tables SN So S1 s2 S6 UNALLOCATED ALLOCATED PREPARED INFETCH Request FreeStmt DRO IH SO SO SO P Cf IH Invalid Handle HYO10 Function Sequence Error 24000 Invalid Cursor State S Success R Results P Prepared ODBC User s Manual E Error except Network Error NR No Results NP Not Prepared NF No data Found 238 RD Receive Done Interface Conformance Levels Appendix D ODBC Confor mance Levels This appendix describes the conformance level of Altibase ODBC Driver Interface Conformance Levels The purpose of classifying the conformance levels is to have the information about the featu
28. cient It exceeded the length of the communication buffer HY001 0x5104A Memory allocation error Cannot allo SOLConnect cate the memory requested for the SOLDriverConnect SOLCLI to execute the function and complete execution 08001 0x50032 The ODBC cannot set the connection SOLConnect to a database SOLDriverConnect 229 ODBC Error Codes Statement State Transition related Errors Network related Error Codes SQLSTATE Code Error Can be returned from 08002 0x51035 The corresponding dbc is already SQLConnect connected to the database SQLDriverConnect 08003 0x51036 Connection does not exist SQLExecDirect SQLExecute SQLPrepare 08501 0x51043 Communication channel error SOLColumns Communication channel failure SQLConnect before the function is processed SQLDriverConnect between the SQLCLI and the data SOLExecDirect base SQLExecute SQLFetch SOLForeignKeys SQLGetConnectAttr SQLPrepare SQLPrimaryKeys SQLProcedureColumns SQLProcedures SQLSetConnectAttr SQLSpecialColumns SQLStatistics SQLTablePrivileges SQLTables Statement State Transition related Errors The following table shows how each status is converted when the ODBC function that uses the cor responding handle type environment connection or statement is called in the statement status Summited statements have the following status State Description SO Unallocated statement The connec
29. stmt SQL DROP return SQL ERROR SOLBindCol stmt 1 SOL C CHAR szCatalog STR LEN amp cbCatalog SOLBindCol stmt 2 SOL C CHAR szSchema STR LEN amp cbSchema SOLBindCol stmt 3 SOL C CHAR szTableName STR LEN amp cbTableName SOLBindCol stmt 4 SOL C CHAR szColumnName STR LEN amp cbColumnName SOLBindCol stmt 5 SOL C SSHORT amp DataType 0 amp cbDataType SOLBindCol stmt 6 SOL C CHAR szTypeName STR LEN amp cbTypeName SOLBindCol stmt 7 SQL C SLONG amp ColumnSize 0 amp cbColumnSize SOLBindCol stmt 8 SOL C SLONG amp BufferLength 0 amp cbBufferLength SOLBindCol stmt 9 SOL C SSHORT amp DecimalDigits 0 amp cbDecimalDigits SOLBindCol stmt 10 SOL C SSHORT amp NumPrecRadix 0 amp cbNumPrecRadix SOLBindCol stmt 11 SOL C SSHORT amp Nullable 0 amp cbNullable SOLBindCol stmt 17 SOL C SLONG amp OrdinalPosition 0 amp cbOrdinalPosition SOLBindCol stmt 18 SOL C CHAR szIsNullable STR LEN amp cbIsNullable while rc SQLFetch stmt SOL NO DATA if Ya SOL ERROR execute err dbc stmt SQLColumns SQLFetch 49 ODBC Functions SOL Connect SOL Connect SOLConnect connects the ODBC with the database The connection handle refers to all data related to the database connection including connection status transaction status and error data SQLConnectW as a Unicode string supports same execution as SOLConnect SOLRETURN
30. 0 pos lt len size len pos if unitsize lt size size unitsize sRetCode SQLPutData sStmt i2 i pos size pos size else printf bbbbbbbbbbbbbbbbbbbbbbbbbbbbb unknown marker value exit 1 sRetCode SQLParamData sStmt void amp sMarker sRetCode SQLFreeHandle SQL HANDLE STMT sStmt check error SOL HANDLE DBC gHdbc STMT free sRetCode Limitation on ALTER SESSION statements Altibase 4 specifies AUTOCOMMIT MODE and DEFAULT_DATE_FORMAT as session properties as fol lows SQLExecDirect stmt ALTER SESSION SET AUTOCOMMIT FALSE SQL NTS SQLExecDirect stmt ALTER SESSION SET DEFAULT DATE FORMAT YYYY MM DD SQL NTS 2 session properties above must have information on ODBC CLI because they definitely affect con version of ODBC CLI and operation of functions related to transactions However ODBC CLI can t know property changes if transmitting SOL syntaxes to server directly with using SOLExecDirect ODBC CLI can get information from server to know the values of property but this causes to have worse performance In Altibase 5 the property is modified with SQLSetConnectAttr to solve this problem Altibase 5 always makes the property in ODBC CLI same as that in server Altibase executes as follows when using ODBC CLI SOL ATTR AUTOCOMMIT SOLPOINTER SQL AUTOCOMMIT OFF 0 SOLSetConnectAttr conn
31. 1 SOL C BLOB LOCATOR amp lobLoc 0 NULL SQL SUCCESS execute err dbc stmt SOLBindCol ts SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLFetch stmt SOL SUCCESS execute err dbc stmt SOLFetch yos SOLFreeStmt stmt SQL DROP return SQL ERROR if SOLGetLobLength stmt lobLoc SOL C BLOB LOCATOR amp valueLength SOL SUCCESS execute err dbc SQLFreeStmt stmt return SQL ERROR stmt SQLGetLobLength SOL DROP ys printf SQLGetLobLength success n if SOLFreeLob stmt lobLoc SOL SUCCESS execute err dbc stmt SOLFreeLob fy ss SOLFreeStmt stmt SOL DROP return SQL ERROR ODBC Users Manual 190 SOL Gel ob SOLGetLob SQLGetLob gets a part of data in the LOB pointed by the LOB locator obtained during the current transaction to an application data buffer SQLRETURN SQLGetLob SOLHSTMT stmt SOLSMALLINT locatorCType SOLUBIGINT sourceLocator SOLLEN fromPosition SOLLEN forLength SQLSMALLINT targetCType SOLPOINTER value SOLLEN bufferSize SOLLEN valueLength Data Type Argument In Out Description SOLHSTMT Stmt Input A handle for the found results SOLSMALLINT locatorCType Input The C data type identifier of a LOB locator It can have the following values SQL C BLOB LOCATOR SQL C CLOB LOCATOR SOLUBIGINT sourceLocator Input A source LOB locator SOLLEN fromPosition Input The start point of data to transfer from LOB b
32. 115 Arguments ete este ti cete ue ina eee aeree eee een oa vet ue esr nr eae n e 115 Rer VAS S e 115 Descriptio EUIS 115 DIAN OSI viniera 115 A O RE EER E ee Rb uero eode 116 RR m 116 AS E 118 Sucre 118 A A TOR 118 Result Mii iio 118 IR aigle E 118 Related F rictioria di 118 SREL 119 cro MM 119 Preise ERR 119 Retales nicas 119 Deseription m data0 sss 119 DN CAES ESN EAEE ENAT ENEA AEE SEAE EDS 120 EMO la A N EE A RAEAN S 120 Se ETT ed TERES 121 NRO 121 A RO RON 121 Return Valise es ee es a aa te A eet eee e enis 121 RI gl Ce MRNA 121 DIAN OS ii a Nacido 121 Related UA E 121 E RO 122 SQUNU IU 123 Encre M 123 get inn 123 A ESA 123 DE SECrF PTTON E H 123 Ee e DE 124 Related O Ateo 124 a Trio RENE EN 124 SOL Param EE 125 KEE 125 e UL Ee 125 AC BEIC eseu A EE EES EE 125 DN ida 125 DIA Ile DC 125 R l t dtE NEt Ot eege O 126 LSK 127 e UE e 127 REGU tet Egye dreet dE EE 127 Descriptio E 127 DIA le DEE 128 Related Enciso 128 EX linia iia 128 SOLPrima y RON 130 KLL 130 AITQUITIeDts
33. C Data Types C Type Identifier ODBC C typedef C type SOL C FLOAT SOLREAL float SOL C DOUBLE SOLDOUBLE double SOL C BINARY SOLCHAR unsigned char C Type Identifier ODBC C typedef Ctype SOL C TYPE DATE SOL DATE STRUCT struct tagDATE_STRUCT SQLSMALLINT year SQLSMALLINT month SQLSMALLINT day DATE_STRUCT SQL_C_TYPE_TIME SQL_TIME_STRUCT struct tagTIME STRUCT SOLSMALLINT hour SOLSMALLINT minute SQLSMALLINT second TIME STRUCT SOL C TYPE TIMESTAMP SOL TIMESTAMP STRUCT struct tagTIMESTAMP STRUCT SOLSMALLINT year SQLSMALLINT month SQLSMALLINT day S QLSMALLINT hour SOLSMALLINT minute SQLSMALLINT second SOLINTEGER fraction TIMESTAMP STRUCT SOL C BYTES SOLCHAR unsigned char SOL C NIBBLE SOL NIBBLE STRUCT struct tagNIBBLE STRUCT SOLCHAR length SOLCHAR value 1 NIBBLE STRUCT 223 Data Types SOL CHAR Converting SOL Data into C Data Types Converting SOL Data into C Data Types Converting Data from SOL to C Data types SOL C CHAR SQL C BIT SOL C STINYINT SOL C UTINYINT SOL C SBIGINT SOL C UBIGINT SOL C SSHORT SOL C USHORT SOL C SLONG SOL C ULONG SOL C FLOAT SOL C DOUBLE SOL C BINARY C TYPE DATE C TYPE TIME SQL SQL C TYPE TIMESTAMP SOL C BYTES SQL SOL C NIBBLE SOL VARCHAR SOL DECIM
34. Continuous function error not con dbc is not connected or disconnected nected or disconnected status in SQLConnect SQLFreeStmt See SALTIBASE_HOME sample SQLCLI demo_ex1 cpp Memory allocation for a statement if SQL ERROR SQLAllocStmt dbc amp stmt printf SQLAllocStmt error n return SQL ERROR ODBC Users Manual 26 SQLBindCol SQLBindCol SQLBindCol binds an application variables to the columns of the result sets for all data types SQLRETURN SQLBindCol SQLHSTMT stmt SQLSMALLINT col SQLSMALLINT cType SQLPOINTER value SQLINTEGER max SQLINTEGER valueLength Argume Data Type Argument In Out Description SQLHSTMT stmt Input Statement handle SQLSMALLINT col Input Column position in the result set to bind Starts with 1 SQLSMALLINT cType Input Out C data type identifier of the Value put Sus buffer About the OODBC data pended types See the appendix of this document SOLPOINTER value Output Pointer of the buffer to store the data SQLFetch returns the data to this buffer If the value is a NULL pointer the ODBC will unbind the data buffer for the result set col umns An application unbinds all columns by calling SOLFreeStmt using SOL UNBind option How ever if the ValueLength argument is valid even though the value argument is a NULL pointer an application still have buffer for binding of the length 27 ODBC Funct
35. In Out Description SOLSMALLINT HandleType Input A handle type to be assigned It can be any of the followings SOL HANDLE ENV SOL HANDLE DBC SOL HANDLE STMT SOLHANDLE Handle Input Ifinput HandleTypeis SOL HANDLE ENV InputHandle should be SOL NULL HANDLE If SOL HANDLE DBC it should be an envi ronment handle If SOL HANDLE STMT it should be a connection handle SQLSMALLINT Diagldentifier Input A type to be diagnosed For now SQL_DIAG_NUMBER is only supported SQLPOINTER DiaglInfoPtr Output A pointer to the buffer to which diagnos tic information is returned SOLINTEGER BufferLength Input If DiagInfoPtr is the pointer of character string this has the byte length of string or the value of SOL NTS If DiaginfoPtr is the pointer of binary buffer this has the binary length of data If DiagInfoPtr is the pointer with fixed length data type its value is ignored ODBC Users Manual 102 SQLGetDiagField Data Type Argument In Out Description SOLINTEGER StringLength Output This returns bytes excluding the null ter Ptr mination character available to return in ValuePtr Result An error message for each handle type This function is used to diagnose the execution result for an error It is used in the following case In ODBC functions when SOL ERROR or SQL SUCCESS WITH INFO is returned error and warning information is gathered This function is used to determine the g
36. Message Reference Korean and English versions of on line manuals PDF or HTML are available from Altibase Download v Preface About This Manual Center http atc altibase com Altibase Welcomes Your Opinions Please send us your comments and suggestions regarding this manual Your comments and sugges tions are important and they may be used to improve future versions of the manual When you send your feedback please make sure to include the following information The name and version of the manual in use Your comments or suggestions regarding the manual Your name address and phone number Please send your e mail to the following address support altibase com This address is intended to report any errors or omissions discovered in the manual When you need an immediate assistance regarding technical issues please contact Altibase Customer Support Cen ter We always appreciate your comments and suggestions ODBC Users Manual vi l ODBC Introduction The ODBC is a callable SOL programming interface The callable SOL interface is used to access the database and execute a dynamic SOL statement through calling the function 1 ODBC Introduction Open Database Connectivity Open Database Connectivity The ODBC is a standard open application program interface to access the database It makes possi ble for applications to access data from a variety of database management systems DBMSs It pro vides calling
37. SOLSTATE Description Comments HY000 General Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle HY010 Order Error of Calling Function 07009 Invalid Descriptor Index The value of recNumber is incorrect SOLBindCol SQLBindParameter SQLGetDescField SQLGetDescRec ODBC Users Manual 148 SQLSetEnvAttr SQLSetEnvAttr SQLSetEnvAttr sets the environment attribute for the current environment Syntax SOLRETURN SQLSetEnvAttr SOLHENV env SOLINTEGER Attribute SOLPOINTER Value SOLINTEGER StringLength Arguments Data Type Argument In Out Description SOLHENV env Input Environment Handle SOLINTEGER Attribute Input Environment attribute to set SOLPOINTER Value Input Pointer of the value related to the Attri bute Depending on the Attribute the Value will be either a 32 bit unsigned integer or a pointer indicating the Null terminator string SOLINTEGER StringLength Input In case the attribute is the character it is the length of Value Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description An application can call SOLSetEnvAttr only when no connection handle is allocated in the current environment All environment attribute successfully set in an application are stored till SOLFreeHan dle is called in the current environment 149 ODBC Functions SQLSetEnvAttr
38. SQL C CHAR szCatalog STR LEN amp cbCatalog SOLBindCol stmt 2 SOL C CHAR szSchema STR LEN amp cbSchema SOLBindCol stmt 3 SQL C CHAR szProcName STR LEN amp cbProcName SOLBindCol stmt 4 SOL C CHAR szColumnName STR LEN amp cbColumnName SOLBindCol stmt 5 SOL C SSHORT amp ColumnType 0 amp cbColumnType SOLBindCol stmt 7 SOL C CHAR szTypeName STR LEN amp cbTypeName SOLBindCol stmt 8 SOL C SLONG amp ColumnSize 0 amp cbColumnSize SOLBindCol stmt 10 SOL C SSHORT amp DecimalDigits 0 amp cbDecimalDigits SOLBindCol stmt 11 SOL C SSHORT amp NumPrecRadix 0 amp cbNumPrecRadix SOLBindCol stmt 18 SOL C SLONG amp OrdinalPosition 0 amp cbOrdinalPosition ODBC Users Manual 136 SQLProcedures SQLProcedures SQLProcedures returns the list of procedure names stored in a specific database Procedure is a generic term used to describe an executable object or a named entity that can be invoked using input and output parameters SQLProceduresW as a Unicode string supports same execution as SOLProcedures SOLRETURN Arguments SOLHSTMT SOLCHAR SOLSMALLINT SOLCHAR SOLSMALLINT SOLCHAR SOLSMALLINT S c S p SQLProcedures tmt cName NameLength sName NameLength pName NameLength Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SQLCHAR cName Input Procedure Catalog Name
39. SQLINTEGER columnSize SQLSMALLINT scale SQLPOINTER value SQLINTEGER valueMax SQLINTEGER valueLength Arguments Data Type Argument In Out Description SQLHSTMT stmt Input Statement handle SQLSMALLINT par Input Parameter order Starting with 1 SQLSMALLINT plype Input Parameter type All parameters in an SQL statement are input variables SQL_PARAM_INOUT When executing a stored procedure arguments can be are input output or input output type vari ables SQL_PARAM_INOUT SQL_PARAM_OUTPUT SQL_PARAM_INOUT_OUTPUT SQLSMALLINT cType Input C data type of parameterSQL C CHARSQL C SBIGINT etcSee Appendix of this document SOLSMALLINT sglType Input Data type SOL CHAR of the parameterSQL_VARCHAR etcSee Appendix of this document 33 ODBC Functions SQLBindParameter Data Type Argument In Out Description SOLINTEGER SOLSMALLINT columnSize scale Input Input An argument that indicates the precision of a parameter marker Based on SOL type it can be used as follows SOL CHAR SOL VARCHAR Indicates the max allowed length of a parameter marker If columnSize is O the default columnSize is used For SOL CHAR and SOL VARCHAR their columnSize is 32 000 SOL DECIMAL SOL NUMERIC Indicates the decimal significant digits of a parameter marker If columnSize is 0 the default columnSize is used For both SOL DECIMAL and SOL NUMERIC the columnsSize is 38 which is the max num ber of de
40. SQLPrepare SQLPrepare This prepares an SQL string for execution SOLPrepareW as a Unicode string supports same execu tion as SOLPrepare Cuntay 3 y n La X SOLRETURN SQLPrepare SOLHSTMT stmt SOLCHAR sgl SOLSMALLINT sqlLength Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLCHAR sql Input SQL text string column SOLSMALLINT sqlLength Input The character number of sql length SQL SUCCESS SQL SUCCESS WITH INFO SQL INVALID HANDLE SOL ERROR Description An application calls SQLPrepare to send an SQL statement to the database The application may include more than one parameter markers in the SOL statement To include the parameter marker an application inserts the parameter marker in the SOL character string at a proper position Once the statement is ready an application calls the function To refer to the statement use the statement handle The statements related to the statement handle can be executed again when an application calls SOLFreeStmt using SOL DROP option to release the statement or when the state ment handle is used again to call SOLPrepare SOLExecDirect or catalog function such like SQL Columns SOLTables Once an application prepares the statement an application an request information about the result set format Calling SOLDescribeCol after SOLPrepare may not be as effective as calling it af
41. a file name is 255 characters ODBC Users Manual 178 SQLBindFileToCol Data Type Argument In Out Description SOLINTEGER fileOptions Input Pend ing A pointer to the buffer that holds a file option or an array of file options Upon SQLFetch there should a file option stored in this buffer The following options are available SOL FILE CREATE creates one if there is no file and returns SOL_ERROR if there is a file SQL FILE OVERWRITE creates one if there is no file and overwrites it if there is a file SQL FILE APPEND creates one if there is no file and appends to it if there is a file Only one of the above options can be selected and there is no default option This argument cannot be NULL SOLINTEGER fileNameBuf ferSize Input Sets the length of the fileName buffer SOLLEN valueLength Output Pend ing A pointer to the buffer that holds an indi cator variable or an array of indicator vari ables It cannot be NULL It is used to return the length of the data stored in a file or to indicate that LOB is NULL SQLFetch can return the following val ues to the buffer pointed by this pointer 1 Data length 2 SQL NULL DATA SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR SQLBindFileToCol binds LOB data in the result set to a file and SOLBindCol binds it to an applica tion variable memory buffer If
42. be returned Related Functions SQLBindCol SOLColAttribute SOLDescribeCol SQLExecDirect SQLExecute SQLFetch SQLGetData SOLPrepare SOLSetStmtAttr Example See SALTIBASE HOME sample SQLCLI demo ex1 cpp sprintf query SELECT FROM DEMO EX1 if SQLExecDirect stmt query SQL NTS SQL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SOLNumResultCols stmt amp columnCount ODBC Users Manual 124 SQLParamData SQLParamData You can use this when inserting data while running command Syntax SQLRETURN SQLParamData SOLHSTMT stmt SOLPOINTER value Argument Data Type Argument In Out Description SOLHSTMT stmt In Command Handle SOLPOINTER value Out Pointer to save address specified in SQL BindParameter Return Value SQL SUCCESS SQL SUCCESS WITH INFO SQL NEED DATA SQL NO DATA SOL INVALID HANDLE SOL ERROR Description You can use this with SOLPutData when inserting data while running command Diagnosis SOLSTATE Description Comments HY000 General Error No error occurs explicitly 125 ODBC Functions SQLParamData SOLSTATE Description Comments HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle HY010 Continuous Function Error SQLBindParameter SQLExecDirect SOLExecute SQLPutData ODBC Users Manual 126
43. byte integer mat nc 07 815 T 8n 8n 7 Precision Data Where n Precision 1 2 Precision Length of NIBBLE data Data Nibble Data Data themselves are sent from server to user when you bind and fetch NIBBLE to SOL C BINARY Data types stored in user buffer are as metioned above You can access to the server conveniently if specifying nibble tas the results are as follows CREATE TABLE T1 I1 NIBBLE I2 NIBBLE 10 I3 NIBBLE 21 NOT NULL INSERT INTO T1 VALUES NIBBLE A NIBBLE 0123456789 NIB BLE 0123456789ABCDEF00121 INSERT INTO T1 VALUES NIBBLE B NIBBLE 789 NIBBLE ABCD1234 void dump unsigned char Buffer int Length for int i 0 i lt Length i printf 02X Buffer i typedef struct nibble t ODBC User s Manual 248 Data Type unsigned char mPrecision unsigned char mData 1 nibble t nibble t Buffer SOLLEN Length SOLRETURN rc Buffer nibble t malloc BUFFER SIZE SOLBindCol stmt 2 SOL C BINARY SOLPOINTER Buffer BUFFER SIZE amp Length do memset Buffer 0 BUFFER SIZE rc SQLFetch stmt printf Mn printf Length d n Length printf Precision d n Buffer gt mPrecision dump Buffer gt mData Length sizeof SQLUINTEGER while rc SQL NO DATA When you execute the program above the results are as follows Length 6 Precision 10 01 23 4
44. calling of the ODBC function To prevent the error message from being cut the buffer length will be declared as SOL MAX MESSAGE LENGTH 1 The message text cannot be longer than this See SALTIBASE HOME sample SQLCLI demo ex1 cpp SOLINTEGER errNo SOLSMALLINT msgLength SOLCHAR errMsg MSG LEN if SOLERROR SOL NULL HENV aCon aStmt NULL amp errNo errMsg MSG LEN amp msgLength SQL SUCCESS printf Error 1d s n errNo errMsg ODBC Users Manual 68 SOLExecDirect SQLExecDirect Ifan SOL statement includes parameters the given SOL statement will be directly executed using the current value of the parameter marker When Using SOLExecDirect the SOL statement can be executed only once and is the fastest method to submit for an one time execution SQLExecDirectW as a Unicode string supports same execution as SOLExecDirect Syntax SOLRETURN SQLExecDirect SOLHSTMT stmt SOLCHAR sgl SOLINTEGER sqlLength Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLCHAR sql Input SQL statement to be executed SOLINTEGER sqlLength Input The character number of sql length Return Values SOL SUCCESS SQL SUCCESS WITH INFO SQL NO DATA FOUND SOL INVALID HANDLE SOL ERROR Description The parameter marker can be included in an SOL statement string Tthe parameter marker specified by and designates the pla
45. cursor and discards pending resuts SQLConnect SQLDisconnect Connects to a target database Closes the connection Releases an environ ment connection statement or descriptor han dle SQLDriverConnect Connects to a specific driver by connection string or requests that the Driver Manager and driver display connection dialog boxes for the user SQLEndTran Commits or rolls back a transaction SQLFreeConnect Closes the connection handle and releases the memory SQLFreeEnv Closes the environment handle and releases the memory SQLFreeFailover Frees the failover handle assigned to SQLAlloc Failover SQLFreeHandle Releases the memory allocated to the connec tion the handle and the command SQLFreeStmt Closes the statement handle and releases the allocated memory SQLTransact Commits or releases all changes related to the database 13 ODBC Introduction Summary of ODBC Functions Task Function Name Purpose SOLPro Reque SQLBindParameter Binds the parameter to an SQL statement cessing sting 7 SQLExecDirect Directly executes an SQL statement SQLExecute Executes a prepared SQL statement SQLNativeSq This efficiently tests the syntax of SQL state ments and converts it to that ODBC driver sup prots SQLParamData This is used to supply data at statement execu tion time SQLPrepare Prepares an SQL statement for later executi
46. data from the result set and returns data for all bound columns Rowsets can be specified at an absolute or relative position You can set the cursor direction like followings SQL FETCH NEXT ODBC Users Manual 78 SQLFetchScroll Return the next rowset This is equivalent to calling SOLFetch SOLFetchScroll ignores the value of FetchOffset SQL FETCH PRIOR Return the prior rowset SOLFetchScroll ignores the value of FetchOffset SQL FETCH RELATIVE Return the rowset FetchOffset from the start of the current rowset SQL FETCH ABSOLUTE Return the rowset starting at row FetchOffset SQL FETCH FIRST Return the first rowset in the result set SOLFetchScroll ignores the value of FetchOffset SQL FETCH LAST Return the last complete rowset in the result set SQLFetchScroll ignores the value of FetchOffset SOLSTATE Description Comments 01004 String data right truncated String or binary data returned for a column resulted in the truncation of nonblank character or non NULL binary data If it was a string value it was right truncated 08501 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error SOLFetch SOLFetchScroll stmt SOL FETCH RELATIVE 10 79 ODBC Functions SQLForeignKeys SQLForeignKeys SQLForeignkeys can return the following A list of foreign keys
47. e lkv e keze A AA K N A A RD Nt 25 Return Vales SEA 25 DESCHDHHOM ees 25 BE le DC 26 Related Functioris iii inicia 26 A R ON UN 26 Kiel Te RE 27 EE EE 27 et Uu 27 Return Vale na 28 DR O A 28 BE e DC 29 Related O ENEE 29 Example 29 SQLCloseCursor a31 Syntax 31 Arguments Return Value saal Description 431 Diagnostics 200 31 Related Function NN 32 SOLBIN AP arameter iii A A bees Eee eh EE RR ERRORES 33 Mir ai AI RN 33 te Unie 33 Reg ales 45 eta Eoi EE 34 DESCRIPTION Ae dE ed ER O EEN 38 CU EE 39 DIA le GC 39 A A E E KE EES 39 NR ER 39 SACA dt Ee EE EE 42 KU 42 ei UE e 42 O dE 43 Description Ee 43 Diagnosis 44 Related Functions Example 45 SQLColumns 1 46 Syntax A Arguments A8 Return Values 46 Raid ue sici n ii ii aria 47 IB le GC 48 Related RU DEES 48 EXIM pl nnere E RNA 49 A A dE Ee 50 OS 50 ege Unie EE 50 A RR RR EUR RR RERO SEENEN 50 Des Ni 51 BE le DC 51 Rel FCO ascii 51 SOLDESErnbeGo ia ad 52 ales Din En 52 Return Values s e EE Ee 53 Des aiii 53 A RATON 53 Related FUNCtIONS iii asta 54 ER 54 SOLEDescribeParatm Re ee Re eee teet Re eee res aa 55 KEE 55 Ge VE ER Return Valenciana and 55 Re le el E 56 RE le DC 56 A EE e EE E 56 Example eee IS 56 SQLDISCONMECE eter REMISE UIROS EE ee 5
48. level interfaces to access database servers and to execute SOL statements That application will be independent of DBMS This Guide is for the Altibase ODBC Driver s users Backgrounds of the ODBC The ODBC was first created by SOL Access Group SAG and introduced in September 1992 Now var ious versions for UNIX OS 2 Microsoft Windows and Macintosh are available also The ODBC is based on the callable standard SQL interface CLls The ODBC enables the programs to use the SOL request to access the database although those programs do not know the independent interface of the database The ODBC receives the SOL request and converts each request in a format comprehensible for the database system ODBC versus Embedded C C Programming The ODBC interface is designed for use C C Languages Then what s the difference between pro grams using ODBA and C C precompiler An application that uses C C Precompiler interface requires a precompiler to convert an SQL statement into a code The ODBC application uses the standard function that executes an SQL statement while it does not need pre compiling The advantage is that it can use other database products that provide the standard functions In other words the ODBC supports independent development of an application for each database product Groups of ODBC Functions The API of the ODBC consists of functions that define environment for running applications manag ing connections and process
49. level of Altibase ODBC Driver This chapter describes the rules of this manual With understanding of this rule it is easy to retrieve information in this manual and other manuals Rules are as follows Syntax diagram Sample code rule This manual describes the command syntax by using the diagram composed of the following ele ments Elements semantics The command starts The syntax element which is not a com plete command starts with an arrow Reserved word The command continues to the next line The syntax element whichis not a complete command terminates with this sym bol The command continues from the previous line The syntax element which is a complete command starts with this sym gt bol The command terminates Mandatory SELECT DD lii Preface About This Manual Elements semantics Optional NOT A Mandatory field with optional items Only one field must be provided ADD DROP Optional field with optional item DESC Optional Multiple fields are allowed The comma must be in front of every repetition ASC T DESC C The code example explains SQL stored procedure iSQL or other command line syntax The following table
50. network SQL_ATTR_PORT Server port number 32 bit Integer SQL_ATTR_TXN_ISOLATION 32 bit value that sets the transaction isolation level for the current connection referred to by dbc SQL_ATTR_LOGIN_TIMEOUT SQLINTEGER value corresponding to the waiting time in seconds for logging in before the data is returned to an application The default depends on the driver If ValuePtr is 0 timeout will be disabled and connection attempt will be permanently awaited SQL_ATTR_CONNECTION_DEAD SQL_CD_TRUE Disconnected status SQL_CD_FALSE Connected status SQLSTATE Description Comments 08S01 Communication channel error Communication channel failure before the function processing is completed between the ODBC driver and the database HYCOO Optional feature not implemented Not supported by the driver specified in the argument Attribute ODBC Users Manual 92 SQLGetConnectAttr Related Functions SQLSetConnectAttr Example See SALTIBASE HOME sample SOLCLI demo dead cpp rc SQLGetConnectAttr dbc SOL ATTR CONNECTION DEAD amp isDead 0 NULL iE rc SOL SUCCESS i isDead SQL CD TRUE printf The Connection has been lost Wn else printf The Connection is active n 93 ODBC Functions SQLGetData SQLGetData SQLGetData retrieves data for a specified column in the result set It can be called multiple times to retrieve variab
51. not NULL AGE NUMERIC 3 DEPT VARCHAR 10 DEPT NO NUMERIC 4 ODBC User s Manual 206 NULL 0 Sample of Simple Basic Program rc SOLExecDirect hstmtl guery SOL NTS if tesz SOL ERROR printf Error s n query db error henv hdbc hstmt1 SOLFreeStmt hstmt1 SQL CLOSE sprintf query INSERT INTO EMPLOYEE VALUES rc SQLPrepare hstmt1 query SQL NTS Xf ix oc SOL ERROR rc SOLBindParameter hstmt1 1 SOL PARAM INOUT SQL C CHAR SQL VARCHAR 8 0 id 0 amp bindp len VEA CTE SOL ERROR rc SQLBindParameter hstmt1 2 SOL PARAM INOUT SOL C CHAR SQL VARCHAR 30 0 name 0 amp bindp len if rc SQL ERROR rc SOLBindParameter hstmt1 3 SOL PARAM INOUT SQL C CHAR SQL NUMERIC 3 0 age 0 amp bindp len YE re SS SOL ERROR rc SOLBindParameter hstmt1 4 SOL PARAM INOUT SQL C CHAR SQL VARCHAR 10 0 dept 0 amp bindp len Tf tE EZ SOL ERROR db error henv hdbc hstmt1 db error henv hdbc hstmt1 db error henv hdbc hstmt1 db error henv hdbc hstmt1 db error henv hdbc hstmt1 rc SOLBindParameter hstmt1 5 SOL PARAM INOUT SQL C CHAR SQL NUMERIC 4 0 dept no 0 amp bindp len ab ee EE ss SOL ERROR sprintf query SELECT FROM EMPLOYEE WHERE NAME rc SQLPrepare hstmt2 query SQL NTS Lf uec SOL ERROR db error h
52. of a specified table columns of a specified table referring to the primary keys of other tables A list of foreign keys of other tables referring to the primary keys of a specified table SQLForeignKeysW as a Unicode string supports same execution as SOLForeignKeys SOLRETURN SQLForeignKeys SOLHSTMTstmt SOLCHAR pkcName SOLSMALLINT pkcNaneLength SOLCHAR pksName SOLSMALLINT pksNameLength SOLCHAR pktName SOLSMALLINT pktNameLength SOLCHAR fkcName SOLINTEGER fkcNaneLength SOLCHAR fksName SOLSMALLINT fksNameLength SOLCHAR fktName SOLSMALLINT fktNameLength Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SQLCHAR pkcName Input Primary key table catalog name SQLSMALLINT pkcName Input The character number of pkcName Length SQLCHAR pksName Input Primary key table schema name SQLSMALLINT pksName Input The character number of pksName Length SQLCHAR pktName Input Primary key table SQLSMALLINT pktName Input The character number of pktName Length SQLCHAR fkcName Input Foreign key table catalog name ODBC Users Manual 80 SQLForeignKeys Data Type Argument In Out Description SOLSMALLINT fkcName Input The character number of fkcName Length SQLCHAR fksName Input Foreign key table schema name SOLSMALLINT fksName Input The character number of fksName Length SQLCHAR fktName Input Forei
53. procedure column as a NOT NULL parameter or a result set col umn SOL PARAM INOUT The procedure column is the input parame Ier SOL PARAM INOUT OUTPUT The procedure column is the input output parameters SQL PARAM OUTPUT The procedure column is the output parame ter DATA TYPE SMALLINT SQL data type NOT NULL TYPE NAME VARCHAR Name of the data type corresponding to NOT NULL the database ODBC Users Manual 134 SQLProcedureColumns Name No Data Type Description COLUMN_SIZE INTEGER Column Size NULL will be returned when the column size is not proper BUFFER_LENGTH INTEGER The maximum byte storing the data DECIMAL_DIGITS SMALLINT The NULL will return the data type that cannot apply the decimal points of the string and the decimal points NUM_PREC_RADIX SMALLINT In case of the numeric data type 10 For COLUMN SIZE and DECIMAL_DIGIT deci mal digits allowable in this string is be given For example DECIMAL 1 2 5 string can return NUM_PREC_RADIX 10 COLUMN SIZE 12 and DECIMAL_DIGITS 5 NULLABLE SMALLINT NOT NULL SOL NO Null when the procedure col umn does not allow NULL value or SOL Nullable when NULL is allowed REMARKS VARCHAR Description of the procedure column COLUMN DEF SOL DATA TYPE 14 VARCHAR SMALLINT NOT NULL The default value of the column If NULL was specified as the default value this column is t
54. respectively before they are passed to the user Therefore if ODBC Driver Manager is used transparent manipulation of LOB data can be ensured 177 LOB Interface SQLBindFileToCol SQLBindFileToCol SOLBindFileToCol binds a file or files to the columns in the result set for BLOB or CLOB data type Cuntav syntax E SOLRETURN SQLBindFileToCol SOLHSTMT stmt SOLSMALLINT col SOLCHAR fileName SOLINTEGER fileNameLength SOLUINTEGER fileOptions SOLINTEGER fileNameBufferSize SOLLEN valueLength Data Type Argument In Out Description SOLHSTMT Stmt Input An instruction handle for the found results SQLSMALLINT Col Input Begins from 1 in the order of columns in the result set to bind SOLCHAR filename Input Pend A pointer to the buffer that holds a file ing name or an array of filenames It cannot be NULL Upon SQLFetch there should be a filename stored in this buffer and SQLFetch returns data to the file s Either of an absolute path recom mended and a relative path is allowed SQLINTEGER fileName Input Pend A pointer to the buffer that holds a file Length ing name length or an array of filename lengths Upon SQLFetch there should be a filename length stored in this buf fer If this argument is NULL a filename is regarded as a null terminated string That is it has the same effect as if SQL_NTS were stored in the memory pointed by this argument The max length of
55. set is ODBC Users Manual 74 SQLFetch from the 52nd row to 56th row of the current row set 57th rows to 61st rows will be returned by SQLFetch SOL SUCCESS will be returned and the number of released rows will be 5 The follow ing table shows the row set and returns the code that was returned by SQLFetch Number of Current row set Returned code New row set the fetched rows Post start SQL_SUCCESS 1to5 1to5 SQL SUCCESS 6to 10 52 to 56 SQL SUCCESS 57 to 61 91 to 95 SOL SUCCESS 96 to 100 93 to 97 SOL SUCCESS 98 to 100 3 96 to 100 SQL NO DATA None 0 99 to 100 SQL NO DATA None 0 After end SOL NO DATA None 0 After SOLFetch is returned the current row will become the first row of the row set As SQLFetch returns each row it places the data for each bound column in the buffer bound to that column If no columns are bound SQLFetch does not return any data but does move the block cur sor forward For each bound column SOLFetch does the following When the data is NULL set SOL NULL DATA in the length indicator buffer and go to the next col umn If the data for the column is not NULL SOLFetch proceeds to step 2 Converts the data of the type specified in the type argument of SQLBindCol If the data is converted into the flexible length data type SOLFetch will inspect whether the data length including NULL terminatior when converted into SOL C CHAR ex
56. supported by this driver 01004 Cutted Resource The size of value buffer is lesser than the size of returned data HYCOO Unsupported Attribute Use The value specified in attribute is unsupported in driver SOLSetEnvAttr 107 ODBC Functions SQLGetFunctions SQLGetFunctions This retrieves function list supported by ODBC driver Syntax SOLRETURN SQLGetFunctions SOLHDBC dbc SOLUSMALLINT functionId SOLUSMALLINT supported Argument Data Type Argument In Out Description SOLHDBC dbc In Connection Handle SQLUSMALLINT functionld In Function ID SQLUSMALLINT supported Out Array pointer recieving the supported function list Return Value SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description This retrieves function list supported by ODBC driver One list can be retrieved at a time or all lists can be retrieved with SOL API ALL FUNCTIONS and SQL API ODBC3 ALL FUNCTIONS You should pinpoint the location suited for ID value of function in argumnet Supported If this function is supported SOL TRUE is returned Otherwise SOL FALSE is returned If using SQL API ALL FUNCTIONS you shoould apply pointer of array whose size is 100 to Supported pointer and pinpoint the location suited for the value of function ID If using SOL API ODBC3 ALL FUNCTIONS you should apply pointer of array whose size is the value of SQL API ODBC3 ALL FUNCTIONS SIZE to Supported pointer
57. than the column value in the result set An application has already called SLOGetData for the current row The number of columns in the current calling is smaller than the number of columns in the previous calling HY000 General error HY010 Continuous function error The given stmt cannot execute this function This function can be called after the result set creation phase HY090 Invalid string or buffer length valueMax is smaller than 0 SQLBindCol ODBC Users Manual 96 SOLExecDirect SOLExecute SOLFetch Example See SALTIBASE HOME sample SOLCLI demo info1 cpp See example of SQLGetTypeInfo 97 SQLGetData ODBC Functions SQLGetDescField SOLGetDescField This retrieves an attribute of descriptor Unicode SOLGetDescFieldW supports same execution as SQLGetDescField Syntax SQLRETURN SQLGetDescField SOLHDESC desc SOLSMALLINT recNumber SOLSMALLINT fieldIdentifier SOLPOINTER ValuePtr SOLINTEGER bufferLength SQLINTEGER stringLengthPtr Arguments Data Type Argument In Out Description SQLHDESC desc In Descriptor Handle SQLSMALLINT recNumber In This starts from 1 of column number SQLSMALLINT fieldldentifier In This specifies the attribute of column to retrieve SOLPOINTER ValuePtr Out Buffer pointer where attributes are saved SOLINTEGER bufferLength In ValuePtr Size SOLINTEGER stringLength Out Size speciified in ValuePtr Ptr Retur
58. the fixed type like SQL C UBIGINT this and they are SQL C SSHORT ignored in case of SQL C USHORT coversion SQL C SLONG SQL C ULONG SQL C FLOAT SQL C DOUBLE SQL C NUMERIC SOL C BIT None Data 0 or 1 1 n a SOL C BINARY None Data See below Data length to be n a for formats written in the memory the user binds The following indicates conversion table related to VARBIT C type id Test TargetValuePtr Strlen or IndPtr SOLSTATE SQL C CHAR BufferLength gt 1 Data Precision of varbit n a BufferLength lt 1 Undefined Undefined 22003 SOL C BIT None Data 0 or 1 1 n a SQL_C_BINARY Data Its format Data length to be n a is same as that written in the of BIT memory the user binds No type is converted to BIT currently ODBC User s Manual 244 Data Type Binary Format 07 815 16 23 24 31 3239 M 8n 8n 7 Precision Data where n Precision 7 8 3 Precision Length of BIT data Data BIT Data Data Type Conversion Example BIT VARBIT SQL_C_BINARY Data themselves are sent from server to user when you bind and fetch BIT to SOL C BINARY Data formats sotred in user buffer are as mentioned above You can access to the server conveniently if specifying struct bit_t as the following examples and using it CREATE TABLE T1 11 BIT 17 12 VARBIT 37 INSERT INTO T1 VALUES BIT 11111011010011011 VARBIT 0010010010101110001010100010010011011 INSERT INT
59. the result sets 81 ODBC Functions SQLForeignKeys String Name dd Data Type Description PKTABLE CAT 1 VARCHAR Always NULL Return PKTABLE SCHEM 2 VARCHAR Foreign key table schema name NULL if not applicable to the database PKTABLE NAME 3 VARCHAR Primary key table name NOT NULL PKCOLUMN NAME 4 VARCHAR Primary key column name As for the NOT NULL unnamed string ODBC makes the empty character string return FKTABLE CAT 5 VARCHAR Always NULL Return FKTABLE SCHEM 6 VARCHAR Primary key table schema name NULL if not applicable to the database FKTABLE NAME 7 VARCHAR Foreign key table name NOT NULL FKCOLUMN NAME 8 VARCHAR Foreign key column name As for the NOT NULL unnamed string ODBC makes the empty character string return KEY SEQ 9 SMALL Column number sequence starting with 1 INT NOT NULL UPDATE RULE 10 SMALLINT Application of SOL NO ACTION to the for eign key upon UPDATE operation DELETE RULE 11 SMALLINT Application of SOL NO ACTION to the for eign key upon DELETE operation FK NAME 12 VARCHAR Foreign key name NULL not proper for the database PK NAME 13 VARCHAR Primary key name NULL not proper for the database DEFERRABILITY 14 SMALLINT SOL INITIALLY IMMEDIATE ODBC Users Manual 82 SQLForeignKeys Diagnosis SOLSTATE Description Comments 08501 Communication channel error Communication channel failure before the function processing betw
60. to find the number of the columns in the result set This step is not needed if an applica tion already knows the number of columns in the result set Then an application brings the name of the result set the data type and the precision to SQLDe scribeCol In the same way if an application already knows this information this step will not be necessary Then an application sends this information to SQLBindCol that binds an application variables and the columns of the result set Then an application calls SQLFetch to fetch the first row of data and stores the data in the vari ables bound to SQLBindCol In case there is only one recored in the row use the SQLGetData to get the data To fetch multiple rows of data an application keeps calling SQLFetch and SQLGet Data An application returns to Step 3 to execute other statements in the same transaction or goes to step 5 to commit or rollback the transaction If a statements executed in Step 3 is UPDATE INSERT or DELETE an application will bring the num ber of affected rows using SQLRowCount An application goes back to Step 3 to execute other statements in the same transaction or Step 5 to commit or rollback the transaction 11 ODBC Introduction Basic Programming Steps Step 5 Commit Rollback a Transaction In Step 5 an application commits the transaction or calls SOLEndTran for rollback An application performs this phase only when the transac
61. 13 SQLGetTypelnfo 115 SQLMoreResult 118 SQLMoreResults 258 SQLNativeSql 119 SQL_NIBBLE 247 SQLNumParams 121 SQLNumResultCols 123 SQLParamData 125 SQLParamData 256 SQLPrepare 127 SQLPrimaryKeys 130 SQLProcedureColumns 133 SQLProcedures 137 SQLPutData 140 SQLPutData 256 SQLPutLob 195 SQLRowCount 142 SOLRowCount 258 SOLSetConnectAttr 144 SOLSetDescField 147 SQLSetEnvAttr 149 SOLSetStmtAttr 151 SQLStatistics 162 SOLTablePrivileges 166 SQLTables 169 SOLTransact 173 SOL TYPE TIMESTAMP 251 SOL VARBIT 243 State Transition Tables 237 Statement State Transition related Errors 230 StrLen or IndPtr 255 U Using SQLFreeStmt function 204 Using the ODBC 4 Using Windows ODBC versus Using UNIX ODBC 7 262
62. 5 67 89 Length 3 Precision 3 78 90 Examples and results are omitted cause of no unusual events in this case SQL BYTE JUL_ DI This is bound to SOL C BINARY instead of SOL C BYTE in Altibase4 and then is executed in the same way as this is in Altibase4 m to Erro x TVI aq ey Pp ISI Conversion to other types is not available except SOL_C_CHAR and SOL C BINARY However origi nal data requires special care that its 1 byte is expressed as ASCII 2 characters when you convert binary data to SOL C CHAR StrLen or IndPt Ctype id Test TargetValuePtr SQLSTATE SQL_C_CHAR Byte length of data Data Length of datain n a 2 lt BufferLength bytes Byte length of data Truncated data Length of datain 01004 2 gt BufferLength bytes 249 Upgrade Data Type ODBC User s Manual C type id Test TargetValuePtr E SOLSTATE SQL_C_BINARY Byte length of data Data Length of datain n a lt BufferLength bytes Byte length of data gt Truncated data Length of datain 01004 BufferLength bytes Each byte of binary data is always converted to a pair of hex characters when Altibase ODBC CLI con verts them to SOL C CHAR Therefore if buffer size of bound SOL C CHAR indicates the even NULL termination character is printed not in the last byte of it but in ahead of that Source binar Size of data hex y bound Cont
63. 58 SQLDisconnect Diagnosis SQLSTATE Description Comments HYO0OO General error Related Functions SOLAllocHandle SQLConnect SQLDriverConnect SQLEndTran SQLFreeConnect Example See SALTIBASE_HOME sample SQLCLI demo_ex1 cpp SQLDisconnect dbc 59 ODBC Functions SQLDriverComnect SQLDriverConnect SQLDriverConnect is alternative to SQLConnect This function supports the connection string that requires more information than three arguments DSN user ID and password of SOLConnect SQLDriverConnect provides connection attributes as follows host IP or host nameone or more user IDsone or more passwordsconnection methodport number 5 USETIMEOUT setting SQLDriverConnectW as a Unicode string supports same execution as SQLDriverConnect SOLRETURN SQLDriverConnect SOLHDBC dbc SOLPOINTER windowHandle SOLCHAR InConnectionString SOLSMALLINT length SOLCHAR OutConnectionString SOLSMALLINT bufferLength SOLSMALLINT strLength2Ptr SOLSMALLINT DriverCompletion uments Data Type Argument In Out Description SOLHDBC Dbc Input Connection Handle SOLPOINTER windowHandle Input Not used SOLCHAR InConnectionString Input A complete connection string a partial connection string or an empty character string For more information see the following description section SOLSMALLINT length1 Input The character number of InCon n
64. 8 SUE 58 Arguments 58 Return Values Description 58 Diagnosis 2 59 Related Functions 0 59 Example 2 59 SOLDriverConnect 60 UEL 60 gen En 60 Returni Values sye a 61 Descriptio E 61 E dad Le EE 62 D To le DEE 63 Related Eed 63 STT E 64 SOLE Tra A aia 65 SY UEL E 65 gel Din En 65 A ee tede ance EE 65 A 65 IB To le DC 66 Related F nctiors e etie e e e ates e EE HR Reb tete Pb RR Eee EU e ben eiue 66 Exaimple 5 et RE RE RE te E ERR Rei dA RE EG 66 SOL Error 67 Syntax 20 07 Arguments 2 07 Return Values Description 68 Example 68 SOLExecDirect 69 SY INCA ORE EEEE EO ANE N EEA 69 Get Die VE 69 GCUIDATIUCHM P 69 DescriptilOEi sce tee RERO ua 69 D To le DC 70 A ERROR EE ERN TT EE ARR I UNE REOR 70 SET TEE 70 SOLEXGCUtG Ee 71 E E AAN 71 TJUMEM S ii A A aid 71 A A E TINA 71 Description EE 71 RI le GC 72 SE PP ERUE 72 E RR T m 73 SQL OCC uc 74 LEE 74 AU Nai ASE RARA Ati 74 Return e 74 DescriptlOh AE 74 BIENS le GC 76 A ss AES ere Ee 77 E TEE 77 A T 78 uu 78 e n VE 78 AO EE Edert 78 BI gl ee EE 78 DAG Ile DC 79 Related Functions 79 Example 79 SOLForeignKeys
65. 9 DESC Le EE 179 BE le DEE 180 Related EUnctloris eege ee EE Ee 180 A eei e RE ee ERU o er esegue EE a RE Ue RR etr a 180 S BT dew A 183 Encre 183 ATQUMENES eR 183 Result A ouveecoanaobnnecaaisanitdessqcnvaccbascansasscoulevennntsbreanecertse 184 Description i da saaisR 184 BE le DC 185 Related Functions es Eed 185 Sue EC 185 SOLGetEobkength sss aid 188 DEE ee 188 e UE e 188 Result Val Ue S ta 188 DI O sais 188 DIA le DC 189 A A O nb EER E re Re eub aeai 189 EXAMDI EL S0 A 190 OJEE mr E EE 191 UL 191 repe 191 Result Vall e 192 Desc iE NI NUMAE MM M Me metre 192 D Te ge DC 192 Rel 192 A 193 SQUP Be c A M 195 crc z ci 195 e UE 195 A A NRO ORAL 196 DescriptiON vico idas 196 E C 196 A A ATA 196 E li cai 197 Ki ge DE 201 cree 201 Peu eA 201 LECHE M P 201 DESCHIPTIOM aie 201 BIEL EAE AE ANE EE M RUP 202 Related Fu rictions caet arie EE 202 Example ctc ase odd Hates A AR 202 AppendixA Sample Codes cscsssssscsssseccsssseccscscecssccsccssccsscsscscssssccssssccssssescsccscssesesessscssec
66. AL SOL NUMERIC O SQL_SMALLINT signed SQL INTEGER signed ARGANDA E SQL BIGINT signed OOOO SOL REAL SOL FLOAT EE E EEN OIEA SOMO La OLO SOL DOUBLE PAREJAS ARE MIES IG oO OJ LAO B CALA be O OJOJOJOJOJOJ EE E o Jojo C3 PO Sx e CIE EO e eu e E Eder CANSAR CIENCIA ESAS SALEN DO Ee LEO pOr DS SOL BINARY EE EE le EE SOL TYPE DATE SOL TYPE TIME SOL TYPE TIMESTAMP SOL INTERVAL SOL BYTES SOL NIBBLE OJOJOJOJOJO JOJ O SOL GEOMETRY Default conversion O Supported conversion ODBC User s Manual 224 OEA LO Converting C Data into SOL Data types Converting C Data into SOL Data types Converting Data from C to SOL Data types E Sl e AERBEFRECDEEPERRE 188232219858 I5338 S EEEEEEEEEEEEER tada Is Qa SQL_C_CHAR O O CO CO CO O OO O O SQL_C_BIT CO O CO OC Of OC OC Of OC OC SQL_C_STINYINT O O CO 0 Of OF OC Of OC OC SQL_C_UTINYINT OO CO OC Of OF OC Of OC OC SQL_C_SBIGINT CO CH OC CO COOC CO CH SOL C UBIGINT OI O CO OC Of OF OC Of OC 0 SQL_C_SSHORT CO O CO CO HI CO OOOO SQL_C_USHORT OI OL CO OC Of OF OC Of OC OC SQL_C_SLONG O O0 0 OF OC Of OC 0 SQL_C_ULONG OO CO 0 Of OF OI Of OC OC SQL_C_FLOAT OLO CO OC Of OC
67. ALTIBASE Application Development ODBC Users Manual release 5 3 3 CT ALTIBASE PERFORMANCE SOLUTIONS ALTIBASE Application Development ODBC User s Manual Release 5 3 3 Copyright 2001 2009 Altibase Corporation All rights reserved This manual contains proprietary information of Altibase Corporation it is provided under a license agreement containing restrictions on use and disclosure and is also protected by copyright patent and other intellectual property law Reverse engineering of the soft ware is prohibited Altibase Corporation 10F Daerung PostTower II 182 13 Guro dong Guro gu Seoul 152 847 Korea Telephone 82 2 2082 1000 Fax 82 2 2082 1099 E mail support altibase com www http www altibase com Contents Preface O NN NON i About TbiscMangdal eee pee e ect tel te ARR A AGNI RR ae Re REN e eA EEN ven cett ii Neb ccxP a ii Software Environmieht ect a ade ii DOOM IZAN cete ite t Mure Mese esset up TU E ii eno iii Related Res miniai r E ENERE REAT Ebc v Online EI RE v Altibase Welcomes Your Opinions Vi 1 ODBC Introduction 1 Open Database Connectivity 2 2 Backgrounds of the ODBC ss 52 ODBC versus Embedded C C Programming 252 Groups of ODBC Functions sees 22 Using the ODBC sss A Basic E A
68. ALTIBASE client library doesn t use signal processor Therefore if access to network terminates due to external factors application can be shut down compulsorily by receiving signal of SIGPIPE You may process it in user application to avoid forced shutdown And you can t call functions of ALTIBASE client library to process it because program can be stopped However you can after processing it ODBC Users Manual 6 Using ODBC Using ODBC This chapter describes how to use ODBC in Unix and Windows Using UNIX ODBC versus Using Windows ODBC All APIs are used in the same way but different strings supported by SOLDriverConnect are used to connect to a database server depending on kinds of API Unix DSN host ip PORT NO 20300 UID SYS PWD MANAGER CONN TYPE 1 NLS USE US7ASCII The name of shared library is libodbcinst so the extension of HP is sl by default in Unix ODBC or iODBC where Altibase ODBC library is installed However if wanting to set its name manually you can specify it with UNIX ODBC INST LIB NAME ex You should change setting of environment variable in iODBC Unix ODBC Extra setting is not a requisite for running Unix ODBC Manager iODBC You should specify the following setting of evironment variable to make an iODBC manager provide an ODBC driver for ALTIBASE export UNIX ODBC INST LIB NAME libiodbcinst so You can specify the following setting of evironment variable under the necessi
69. B is a binary data type with a variable length SQL CLOB CLOB CLOB is a character data type with a variable length The following table shows C data type identifiers that support LOB It lists C data type of ODBC for each identifier and their definition C Type Identifier ODBC C Type C Type Definition SOL C BLOB LOCATOR SQLUBIGINT unsigned _int64 SQL_C_CLOB_LOCATOR SQLUBIGINT unsigned _int64 The name of a 64 bit integer type may vary depending on platform The _int64 shown in the above table is the name of a 64 bit integer that is used in several platforms including Windows Use SQL_C_CHAR for CLOB data and SQL_C_BINARY for BLOB data to bind user variables To obtain a LOB locator bind SQL_C_CLOB_LOCATOR or SQL_C_BLOB_LOCATOR appropriately based on the LOB column type A LOB locator in this context a LOB location input scheme is a handle that is used during LOB data operation like a file pointer in an operating system The LOB location input scheme for Read can be obtained after SELECT LOB column name FROM table where and select are executed The LOB location input scheme for Write can be obtained after SELECT LOB column name FROM table where FOR UPDATE are executed Since a LOB location input scheme refers to LOB data at a certain point in relation to MVCC it has the same life cycle with the transaction that has created itself Therefore to perform LOB operation with a LOB location input sch
70. BC to execute the func tion and complete execution SOLAllocHandle SQLConnect SQLDisconnect SQLFreeHandle SQLSetConnectAttr 63 ODBC Functions SQLDriverComnect Example See SALTIBASE HOME sample SQLCLI demo ex1 cpp sprintf connStr DSN 127 0 0 1 UID s PWD s CONNTYPE d NLS USE s PORT NO 20300 USERNAME PASSWD 2 NLS Establish a connection if SOLDriverConnect dbc NULL connStr SQL NTS NULL 0 NULL SOL DRIVER NOPROMPT SQL SUCCESS execute err dbc SOL NULL HSTMT SQLDriverConnect return SQL ERROR ODBC Users Manual 64 SQLEndTran SQLEndTran SQLEndTran requests a commit or rollback operation for all active operations on all statements asso ciated with a connection SOLEndTran can also request that a commit or rollback operation be per formed for all connections associated with an environment Syntax SQLRETURN SQLEndTran SQLSMALLINT handleType SQLHENV handle SQLSMALLINT type Arguments Data Type Argument In Out Description SQLSMALLINT handleType Input Handle type identifier It should be either SQL_HANDLE_ENV or SQL_HANDLE_DBC SQLHENV handle Input The handle SQLSMALLINT type Input One of the following two val ues SQL_COMMITSQL_ROLLBACK Return Values SOL SUCCESS SOL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description If the handleType is SOL HANDLE ENV and the handle is eff
71. CLI demo_meta7 cpp gt if SQLSpecialColumns stmt 0 NU NU NU bb 0 bili 0 DEMO META7 SOL NTS L 0 SOL SUCCESS execute err dbc stmt SQLColumns SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindCol stmt 2 SOL C CHAR szColumnName STR LEN amp cbColumnName SOLBindCol stmt 3 SOL C SSHORT amp DataType 0 amp cbDataType SOLBindCol stmt 4 SOL C CHAR szTypeName STR LEN amp cbTypeName ODBC Users Manual SQLSpecialColumns SQLBindCol stmt 5 SQL C SLONG amp ColumnSize 0 amp cbColumnSize SOLBindCol stmt 6 SOL C SLONG amp BufferLength 0 amp cbBufferLength SQLBindCol stmt 7 SQL C SSHORT amp DecimalDigits 0 amp cbDecimalDigits 161 ODBC Functions SQLStatistics SQLStatistics SQLStatistics retrieves a list of statistics about a single table and the indexes associated with the table The driver returns the information as a result set SOLStatisticsW as a Unicode string supports same execution as SOLStatistics SQLRETURN SQLStatistics SQLHSTMT stmt SQLCHAR cName SOLSMALLINT cNameLength SOLCHAR sName SOLSMALLINT sNameLength SOLCHAR tName SOLSMALLINT tNameLength SOLSMALLINT unique SOLSMALLINT reserved Argun Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SQLCHAR cName Input Catalog Name SOLSMAL
72. Desc DESC LEN SOLINTEGER PriceInd SOLINTEGER PartIDInd SOLINTEGER DescLenOrInd PartStruct PartStruct PartArray ARRAY SIZE SOLCHAR Statement INSERT INTO Parts PartID Description Price VALUES SOLUSMALLINT i ParamStatusArray ARRAY SIZE SQLUINTEGER ParamsProcessed Set the SQL ATTR PARAM BIND TYPE statement attribute to use column wise binding SOLSetStmtAttr hstmt SQL ATTR PARAM BIND TYPE sizeof PartStruct 0 Specify the number of elements in each parameter array SOLSetStmtAttr hstmt SOL ATTR PARAMSET SIZE ARRAY SIZE 0 Specify an array in which to return the status of each set of parameters SOLSetStmtAttr hstmt SQL ATTR PARAM STATUS PTR ParamStatusArray 0 Specify an SQLUINTEGER value in which to return the number of sets of parameters processed SOLSetStmtAttr hstmt SOL ATTR PARAMS PROCESSED PTR amp ParamsProcessed 0 Bind the parameters in row wise fashion SOLBindParameter hstmt 1 SOL PARAM INOUT SQL C ULONG SQL INTEGER 5 0 ODBC Users Manual 38 amp PartArray 0 PartID 0 SOLBindParameter hstmt 2 SOL PARAM INOUT T 0 PartArray 0 Desc SQLBindParameter hstmt 3 amp PartArray 0 Price 0 DESC LEN SQL PARAM INOUT SOLBindParameter amp PartArray 0 PartIDInd SOL C CHAR SQL CHAR DESC LEN amp PartArray 0 DescLenOrInd SOL C FLOAT amp PartArray 0 PriceInd S
73. E FROM T1 WHERE 11 gt 10 AND I1 20 199 gt This is affected row count of DELETE FROM T1 WHERE 11 gt 100 AND I1 200 0 gt This is affected row count of DELETE FROM T1 WHERE 11 gt 11 AND I1 14 No record exists because it is deleted by the first execution 208 gt This is the total of affected row counts Each execution result of syntax the argument indicates is created and then sent to ODBC CLI When multiple results are created like this each data can move for next result with SOLMoreResults and have its result with SQLRowCount If you sum up 3results above in Altibase4 SOLRowCount returns 208 If you want same results in Altibase 5 as in Altibase 4 you may execute SOLMoreResults repeatedly until it returns SOL NO DATA and then add this result to result of SQLRowCount Unlimited Array Execute Array Fetch Altibase doesn t have restrictions on Array Execute and Array Fetch as buffer size Therefore you can bind array in the allocated memory and can use CM BUFF SIZE no more Unavailable Properties Batch Processing Mode You can t use batch keyword of connection string and SOL ATTR BATCH SQL ATTR MAX ROWS This indicates to specify the number of prefetched row for better performance in Altibase4 How ever this property is similar to LIMIT of SELECT statement following ODBC This option isn t available for ODBC CLI of Altibase Therefore if you specify property above as SOLSetStmtAttr this asks your attention
74. EE 130 Return Valles cai iii ins 130 est O idad 131 Diagnosis M RS 131 A SEN 131 EXAM TE 132 attert A EE 133 A NN 133 Return Malget 133 np A 134 A EEEE 136 Related Eunctiorns urit rentre titt geriet iia 136 SET 136 Kieler 137 EL 137 te UE E 137 Return Values 45e Embed gU dum EM ds 137 Descriptio M aeea eei tee serie e pes e et a e eee ENEE 138 E det gt ss 139 Related Functions ta eee rr ede redet tee eei tee ed 139 SET 139 SOLPUT DALA eegener 140 KL 140 ATU p e 140 Rer Veal Ue nin ai 140 RI e el E 140 BE le DC 140 Related EURCEHOL AE EE 141 SOLROWGOUDt i aieo esee resi dre aan 142 che RIA 142 Arguments ise ste ie e e dee i i en ed eee oe e RM pe Ro e ete ea i ed 142 Return EE 142 Be goto p PP M 142 Diagnosis ini v E M HERR 143 Related F rictions cotes ttl bi ise et tud de tede PARDO OR Bed 143 A AR 143 SQLSCTCONMECHA rs RP estiba rococ 144 KE UEL 144 te UE CN 144 Ret rn Valtes e ee RU ee e Aere eas 144 RI el ELON EE 145 BE le DC 145 Related Euphorie EE 145 Example 2 5 etes O eR etre 146 SUS Dei H 147 KU 147 e UE e 147 PRET CAI Value ee t EA REAL A RN RUIN esL E 147 Descripti M p P 147 E RA 148 Related O re ese es ree
75. ETCH BOOKMARK PTR SQL ATTR IMP PARAM DESC SOL ATTR IMP ROW DESC SQL ATTR KEYSET SIZE SQL ATTR MAX LENGTH SOL ATTR METADATA ID SQL ATTR NOSCAN SOL ATTR PARAM BIND OFFSET PTR SOL ATTR PARAM OPERATION PIR SOL ATTR QUERY TIMEOUT SQL ATTR RETRIEVE DATA SOL ATTR ROW BIND OFFSET PTR SOL ATTR ROW NUMBER SQL ATTR ROW OPERATION PTR SQL ATTR SIMULATE CURSOR SQL ATTR USE BOOKMARKS SOLPOINTER param Input Pointer of the value related to the Attribute Depending on the pointer Attribute the param will be a 32 bit integer the pointer of the Null terminator the character string s pointer the binary pointer or the value defined in the ODBC If Attribute is the unique value of the ODBC param is the integer number with a sign ODBC Users Manual 152 turn Y SQLSetStmtAttr Data Type Argument In Out Description SQLINTEGER StringLength Input If Attribute has been defined in the ODBC and param indicates the character string or binary buffer this argument must be the byte length of param If Attribute has been defined in the ODBC and param is an integer this argument is ignored SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR The command option for stmt is valid until the option is changed by calling of SOLSetStmtAttr or till stmt is removed by calling of SOLFreeHandle Handle release method
76. GER PRIMARY KEY i2 CLOB After inserting a record with the CLOB column value being Ver Beta replace Beta with Gamma SOLCHAR buf 5 SQLUBIGINT lobLoc strcpy query INSERT INTO T1 VALUES 1 Ver Beta if SQLExecDirect stmt query SOL NTS SOL SUCCESS execute err dbc stmt SOLExecDirect SOLFreeStmt stmt SOL DROP return SQL ERROR strcpy query SELECT i2 FROM T1 WHERE il 1 FOR UPDATE if SQLExecDirect stmt query SOL NTS SQL SUCCESS execute err dbc stmt SOLExecDirect SOLFreeStmt stmt SOL DROP return SQL ERROR if SOLBindCol stmt 1 SOL C CLOB LOCATOR amp lobLoc 0 NULL SQL SUCCESS execute err dbc stmt SOLBindCol SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLFetch stmt SOL SUCCESS execute err dbc stmt SOLFetch SOLFreeStmt stmt SOL DROP return SQL ERROR memcpy buf Gamma 5 if SQLPutLob stmt SOL C CLOB LOCATOR lobLoc 4 4 SQL C CHAR buf 5 SOL SUCCESS execute err dbc stmt SOLPutLob SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLFreeLob stmt lobLoc SQL SUCCESS execute err dbc stmt SOLFreeLob SOLFreeStmt stmt SOL DROP return SQL ERROR 197 LOB Interface SOLPutLob After inserting a record with the CLOB column value being sss insert mile between two ss SOLCHAR buf 4 SQLUBIGINT lobLoc strcpy query INSERT I
77. INT locator Arguments Data Type Argument In Out Description SOLHSTMT stmt Input A handle for the found results SQLUBIGINT locator Input A LOB locator Result Values SOL SUCCESS SOL INVALID HANDLE SOL ERROR Description Reports that operation of LOB pointed by a LOB locator is complete This will release the LOB locator assigned by a server and other related resources in the server This function does not commit or rollback changes to LOB pointed by a LOB locator If a transaction is terminated with SQLEndTran a LOB locator is automatically released and this function does have to be called 201 LOB Interface SOL Freet ob Diagnosis SOLSTATE Description Note 08501 A communication link fault Data A communication link failed before transmission failure function processing is complete between ODBC and DB HY000 A general error Related Functions SOLGetLobLength SOLGetLob SOLPutLob Example Please see the examples of SOLGetLobLength SOLGetLob and SOL Putt obt ODBC Users Manual 202 Appendix A Sample Codes The appendix contains the entire sample codes which used this document Programing Considerations The following describes notes on programming the client using the ODBC and frequent errors S MA Mu On multi threaded operating systems multiple environment handle SOLHENV can be allocated by one application In cas
78. Info is used to get general information of DBMS You can get relevant information of each type according to InfoType with this function and Altibase follows the standard of ODBC SQLSTATE Description Comments 01004 String data right truncated The size of returned values is bigger than that of the given buffer 08003 Disconnection Disconnection Status 08S01 Communication channel error Data Communication channel error before Sending Recieving Failure the function processing is completed between the ODBC and the database HY000 General Error HY090 Invalid Arguments used One value among name length argu ments must be under 0 or not be equal to SQL_NTS HY096 Out of InfoType Range The values specified in InfoType are invalid in the version which ODBC provides 111 ODBC Functions SQLGetPlan SQLGetPlan This is nonstandard function returning execution information Syntax SQLRETURN SQLGetPlan SOLHSTMT stmt SOLCHAR aPlan Arguments Data Type Argument In Out Description SOLHSTMT stmt In Input Statement Handle SQLCHAR aPlan Out Pointer to store output execution infor mation Returned Values SOL SUCCESS SOL ERROR Description SOLGetPlan is nonstandard function but you can use it when retrieving information of execution plan At this time you shouldn t modify information returned by aPlan Related Function SQLSetConnectAttr Example
79. LAllocStmt SQLDriverConnect SQLExecDirect SQLExecute SQLPrepare SOLBindParameter ak SQLDisconnect kk SOLERROR SQLFreeEnv SQLFreeStmt SQLFreeConnect FR KK RR RK RR RR RK RR RRR KK RR RR KK include lt idl h gt include lt sqlcli h gt include lt time h gt include lt stdio h gt include lt stdlib h gt include lt string h gt include lt iduPropertyMgr h gt 217 Sample Codes Example of Procedure test Program Hdefine ADDR LEN 50 Hdefine PHONE LEN 13 Hdefine MSG LEN 1024 Hdefine JOB LEN 14 Hdefine YMD LEN 15 Hdefine ZIP LEN 7 Hdefine REC CNT 100000 Hdefine NUM LEN 22 int main SOLCHAR errMsg MSG LEN SOLCHAR sq1 1000 SOLHENV env SOLHDBC con SOLHSTMT stmt SInt i SInt il SInt 12 SInt 13 SInt il len SInt i2 len SInt i3 len if SOL ERROR SQLAllocEnv amp env printf AllocEnv error ln exit 1 else if SQL ERROR SQLAllocConnect env amp con printf success AllocEnv n printf AllocEnv error ln SQLFreeEnv env exit 1 else char connStr 1024 sprintf connStr DSN 127 0 0 1 UID SYS PWD MANAGER CONNTYPE 2 if SQL ERROR SQLDriverConnect con NULL connStr SQL NTS NULL 0 NULL SOL DRIVER NOPROMPT printf success AllocConnect Wn printf connection error n SInt errNo SShort msgLength i
80. LINT cNameLength Input The character number of cName SOLCHAR sName Input Schema Name SQLSMALLINT sNameLength Input Length of character string of sName SQLCHAR tName Input The table name Cannot be a NULL pointer SQLSMALLINT tNameLength Input Length of character string of tName SQLSMALLINT unique Input index type SQL_INDEX_UNIQUE or SQL_INDEX_ALL SQLSMALLINT reserved Input For future use rn Val SOL SUCCESS SOL SUCCESS WITH INFO ODBC Users Manual 162 SOL INVALID HANDLE SOL ERROR SQLStatistics returns information about a single table as a standard result set ordered by NON_UNIQUE TYPE INDEX_QUALIFIER INDEX NAME and ORDINAL_ POSITION The result set combines the statistical information of the table and the data for index Column Name No Data Type Description TABLE_CAT VARCHAR Null will be always returned TABLE_SCHEM VARCHAR Schema name of the table to which the sta tistic or index applies TABLE_NAME VARCHAR Table name of the table to which the statistic NOT NULL or index applies NON_UNIQUE SMALLINT Indicates whether the index prohibits dupli cate values SQL_TRUE if the index values can be nonu nique SQL_FALSE if the index values must be unique NULL is returned if TYPE is SQL_TABLE_STAT INDEX_QUALIFIER VARCHAR An empty character string is returned INDEX_NAME VARCHAR Index name NULL data will be returned when the TYPE is SOL TABLE STAT TYPE SMALLINT TYPE of
81. LINT columnNumber SQLSMALLINT fieldIdentifier SQLCHAR charAttributePtr SOLSMALLINT bufferLength SOLSMALLINT stringLengthPtr SOLPOINTER numericAttributePtr Arguments Data Type Argument In Out Description SQLHSTMT stmt Input Statement handle SOLSMALLINT columnNum Input The column position in the result set ber Starts with 1 ODBC Users Manual 42 SOLColAttribute Data Type Argument In Out Description SOLSMALLINT fieldldentifier Input Information identifier to know SQL DESC CASE SENSITIVE SQL DESC CATALOG NAMESOL DESC COUNT SQL DESC DISPLAY SIZESQL D ESC LABEL SQL DESC LENGTH SQL DES C NAME SQL DESC NULLABLE SQL DES C PRECISION SOL DESC SCALE SQL DESC SCHEMA NAME SQL DESC T ABLE NAME SOL DESC TYPE SQL DESC TYPE NAME SQL DESC UNSIGNED SOLCHAR charAttrib Output Buffer pointer to store data to be utePtr returned when fieldldentifier in column Number is the character string If field value is an integer it is not used SQLSMALLINT bufferLength Input The character number of charAttributeP trif charAttributePtr is an integer this field is ignored SQLSMALLINT stringLength Output Pointer to a buffer in whih to return the Ptr total number of bytes excluding the null termination byte available to return in charAttributePtr SQLINTEGER numericAt Output Pointer of the integer buffer to which the tributePtr value of fieldldentifier field in column Number row is r
82. LOB pointed by the LOB locator obtained during the cur rent transaction Syntax SOLRETURN SQLGetLobLength SQLHSTMT stmt SQLUBIGINT locator SQLSMALLINT locatorCType SQLLEN valueLength Arguments Data Type Argument In Out Description SQLHSTMT Stmt Input A handle for the found results SQLUBIGINT locator Input A LOB locator SQLSMALLINT locatorCType Input The C data type of A LOB locator It can have the following values SQL_C_BLOB_LOCATOR SQL_C_CLOB_LOCATOR SQLLEN valueLength Output Used to store the LOB length or to indi cate that LOB is NULL The buffer pointed by the pointer returns the following val ues Data length SQL_NULL_DATA Result Values SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description A function that is used to get the length of the LOB pointed by a LOB locator ODBC Users Manual 188 SQLGetLobLength A LOB locator has the value that directly points LOB in a database not offset in LOB A LOB locator can be obtained in two ways It can be obtained from the LOB column in the result set of the SELECT SQL statement with SQLBind Col or SOLGetData function In this case the application buffer type bound by the user should be SQL_C_CLOB_LOCATOR or SQL C BLOB LOCATOR It can be obtained from the output parameter of SOLBindParameter In this case the application buffer type bound by the user should be SOL C CLOB LOCA
83. NECTION AUTOCOMMIT This makes off mode SQLCHAR sBlobData 128 SOLCHAR sClobData 128 SOLLEN sBlobLength SOLLEN sClobLength SOLCHAR sQuery SQLCHAR INSERT INTO T1 VALUES SOLPrepare stmt sQuery SOL NTS SOLBindParameter stmt 1 SOL C BINARY SOL BLOB 0 0 sBlobData sizeof sBlobData amp sBlobLength SOLBindParameter stmt 2 SOL C CHAR SOL CLOB 0 0 sClobData sizeof sClobData amp sClobLength sBlobLength create blob data sBlobData sprintf char sClobData this is clob data sClobLength SQL NTS SOLExecute stmt Using LOB in ODBC application If you want to fetch LOB column in ODBC application and store data in LOB column call SQLDe scribeCol SOLColAttribute or SOLDescribeParam If you execute these functions in LOB column they are returned as data types of SOL BLOB and SQL CLOB However ODBC application doesn t recognize data types such as SOL BLOB or SQL CLOB Therefore you may return them as data type which ODBC application recognizes You can solve this problem by setting LongDataCompat on in odbc ini If you call SOLColAttribute in LOB column for this option ODBC returns SOL LONGVINARYto SOL BLOB and SOL LONGVARCHAR to SOL CLOB relatively LOB Use Examples in PHP Program The following is the examples using LOB in PHP application You may check 2 properties as follows in php ini before executing programs odbc defaultlrl 4096 This value must be
84. NTO T1 VALUES 2 ss if SQLExecDirect stmt query SOL NTS SQL SUCCESS execute err dbc stmt SOLExecDirect yos SOLFreeStmt stmt SOL DROP return SQL ERROR strcpy query SELECT i2 FROM T1 WHERE il 1 FOR UPDATE if SQLExecDirect stmt query execute err dbc SQLFreeStmt stmt return SQL ERROR stmt SQL DROP SOL NTS SOLExecDirect SOL SUCCESS Zi if SOLBindCol stmt 1 SOL C CLOB LOCATOR amp lobLoc 0 NULL SQL SUCCESS execute err dbc stmt SOLBindCol ys SOLFreeStmt stmt SQL DROP return SQL ERROR if SQLFetch stmt SQL SUCCESS execute err dbc stmt SOLFetch s SOLFreeStmt stmt SQL DROP return SQL ERROR memcpy buf mile 4 if SQLPutLob stmt SOL C CLOB LOCATOR lobLoc 1 0 SOL C CHAR buf 4 SOL SUCCESS execute err dbc stmt SOLPutLob sys SOLFreeStmt stmt SOL DROP return SQL ERROR Delete mil from smiles if SQLPutLob stmt SOL C CLOB LOCATOR lobLoc 1 3 SOL C CHAR NULL 0 SOL SUCCESS execute err dbc stmt SOLPutLob W I SOLFreeStmt stmt SOL DROP return SQL ERROR Append 4 to ses memcpy buf 4 1 if SOLPutLob stmt SOL C CLOB LOCATOR lobLoc 3 0 SQL C CHAR buf 1 SOL SUCCESS execute err dbc SQLFreeStmt stmt return SQL ERROR stmt SOLPutLob SOL DROP if SQLFreeLob stmt lobLoc ODBC Users Manual 198 ys SOL SUCCESS execute e
85. NULLABLE SQLINTEGER Whether or not to NULL Yes SQL_NULLABLE No SQL NO NULLS SQL DESC PRECISION SQLINTEGER Precision of the column SQL DESC SCALE SOLINTEGER Decimal point attributes of the column SOL DESC SCHEMA NAME SQLCHAR Schema of the table including the columns SOL DESC TABLE NAME SOLCHAR Table Name SOL DESC TYPE SOLINTEGER SQL data type SQL DESC TYPE NAME SQLCHAR Database type name SQL DESC UNSIGNED SOLINTEGER Inspection of column items SOLSTATE Description Comments 07009 Invalid column number columnNumber is 0 or higher than the number of columns in the result set HYO000 General error ODBC Users Manual 44 Related Functions SOLBindCol SOLDescribeCol SOLFetch Example See SALTIBASE_HOME sample SQLCLI demo_meta8 cpp sprintf query SELECT FROM DEMO METAS8 if SQLExecDirect stmt query SQL NTS SQL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SQLNumResultCols stmt amp columnCount for i20 i columnCount i SQLColAttribute stmt i 1 SQL DESC NAME columnName sizeof columnName NULL SOLColAttribute stmt i l SQL DESC TYPE NULL 0 NULL amp dataType SOLColAttribute stmt i l SOL DESC PRECISION NULL 0 NULL amp columnPrecision SOLColAttribute stmt i 1 SQL DESC SCALE NULL 0 NULL amp scale SQLColAttribute stmt i 1 SQL DESC NULLABLE NULL 0 NULL amp nullable 45 S
86. O T1 VALUES BIT 110011011 VARBIT 001110001010100010010011011 void dump unsigned char Buffer SOLINTEGER Length for SQLINTEGER i 0 i Length 1 printf 302X Buffer 1 typedef struct bit_t SOLUINTEGER mPrecision unsigned char mData 1 bit t bit t Bit bit t Varbit SOLLEN Length SOLRETURN rc Bit bit t malloc BUFFER SIZE Varbit bit t malloc BUFFER SIZE SQLBindCol stmt 1 SQL C BINARY SOLPOINTER Bit BUFFER SIZE amp LengthBit SQLBindCol stmt 2 SOL C BINARY 245 Upgrade Data Type SOLPOINTER Varbit BUFFER SIZE amp LengthVarbit do memset Buffer 0 BUFFER SIZE rc SQLFetch stmt printf Nn printf gt gt Bitin printf Length d n LengthBit printf Precision d n Bit mPrecision dump Bit mData LengthBit sizeof SQLUINTEGER printf gt gt Varbit n printf Length d n LengthVarbit printf Precision d n Varbit gt mPrecision dump Varbit gt mData LengthVarbit sizeof SQLUINTEGER while rc SOL NO DATA When you execute the program above the results are as follows Length 7 Precision 17 FB 4D 80 1111 1011 0100 1101 1 gt gt Varbit Length 9 Precision 37 24 AE 2A 24 D8 0010 0100 1010 1110 0010 1010 0010 0100 1101 1 Length 7 Precision 17 gt Precision indicates 17 beca
87. OA 98 le UE EE 98 Return Value 98 Description 10 99 Diagnostics 99 Related Function 99 SOLGetDescRec 100 E UEL 100 ge inn 100 Ret rn Malte da 100 Description p 101 DIA OSTIES pM 101 Related EUA das 101 SOU aaa 102 KE ERAN 102 lge Un CT 102 Result Val e ZENNER 103 Description vna H R 103 RelatectEunetiop atetngegEe 103 Kuele c 104 Encre 104 freiem M n 104 RV 104 DescriptlOn i ecce aia 105 Related FAC EE De DE 105 SOLGEtENVAT i A 106 SYNTAX Ae EE EE EEGEN 106 Le ie EE 106 Return VU EE 106 DIe o el E 106 BIFES LAV DC 107 Rel ted id 107 kelKe dUYaietpe E M 108 Sucre 108 Preig 108 Return Val M I ee 108 Descriptio A Ee 108 DIAGMOSEICS E 109 Related it 109 A TR RR RN 110 A RAN 110 lge Un 110 A A AE 110 pS A NN 111 E RAR 111 KEE 112 AT UL E CN 112 Ret med NEU 112 RI git det EE 112 Related FEUfetlOris ri Ke S ON Ee 112 EXE plett 112 Kuel E 113 DUSEL 113 Arguments inician AR di 113 Ret rniValues toi 114 po 114 RI le GC 114 AA Eed 114 STT E 114 SOLA peli aaa 115 cq ES
88. ODBC Users Manual 76 SQLFetch SOLSTATE Description Comments 07006 Restricted data type attribute viola The column data within the result set tion must not be converted to the data type expressed in cType of SOLBind Col 08S01 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error SQLBindCol SQLDescribeCol SQLExecDirect SOLExecute SOLFreeStmt SQLGetData SQLNumResultCols SQLPrepare See SALTIBASE_HOME sample SQLCLI demo_ex2 cpp See example of SQLBindCol 77 ODBC Functions SQLFetchScroll SQLFetchScroll SQLFetchScroll fetches the specified rowset of data from the result set and returns data for all bound columns Rowsets can be specified at an absolute or relative position Syntax SOLRETURN SQLFetchScroll SQLHSTMT stmt SOLSMALLINT fOrient SOLINTEGER fOffset Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SQLSMALLINT fOrient Input Type of fetch This argument determines scroll direc tion SQL_FETCH_NEXTSQL_FETCH_PRIO RSQL_FETCH_FIRSTSQL_FETCH_LASTSQL _FETCH_ABSOLUTESQL_FETCH_RELATIV E SQLINTEGER fOffset Input Number rows to fetch Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR SQL NO DATA FOUND Description SQLFetchScroll fetches the specified rowset of
89. OL REAL 7 O0 For SQL BINARY SOL BYTES SOL NIBBLE and SQL VARBIT types the buffer size and column size must be specified For SQL CHAR and SQL VARCHAR types the default precision is the max size that a column can have For SOL NUMERIC and SQL NUMBER types the precision is 38 SOLSTATE Description Comments 07006 Violation of the limited data type attri A cType data type cannot be con butes verted into a sqlType data type 07009 Invalid number Indicated par value is smaller than 1 HY000 General error HY001 Memory allocation error Failed to allocate the memory for the explicit handle HY003 An application buffer type is not valid A cType value is invalided C data type HY009 Invalid pointer used null pointer valueLength is a NULL pointer and pType is not SQL_PARAM_OUTPUT HY090 Invalid buffer length valueMax value is smaller than O or higher than 64K HY105 Wf73 Invalid parameter type pType is invalided value in out inout SOLExecDirect SOLExecute SOLFreeStmt See SALTIBASE HOME sample SQLCLI demo ex2 cpp 39 ODBC Functions SQLBindParameter sprintf query INSERT INTO DEMO EX2 VALUES Tf por 1 1 Prepare for a statement and bind the variable SOLPrepare stmt query SOL NTS SOL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindParameter stmt 1 the sequence of host va
90. OLBindCol hstmt2 2 SOL C CHAR name sizeof name amp len printf SQLBindCol error n db error henv hdbc hstmt2 if SOL ERROR SOLBindCol hstmt2 3 SOL C CHAR age sizeof age amp len printf SQLBindCol error n db error henv hdbc hstmt2 if SOL ERROR SOLBindCol hstmt2 4 SOL C CHAR dept sizeof dept amp len printf SQLBindCol error n db error henv hdbc hstmt2 if SOL ERROR SQLBindCol hstmt2 5 SOL C CHAR dept no sizeof dept_no amp len printf SQLBindCol error n db error henv hdbc hstmt2 while SQLFetch hstmt2 SOL SUCCESS printf ID s Name s Age s Dept s dept no s n n n id name age dept dept no SOLFreeStmt hstmt1 SQL CLOSE SOLFreeStmt hstmt2 SQL CLOSE sprintf query SELECT FROM EMPLOYEE rc if SQLExecDirect hstmt1 query SQL NTS rc SQL ERROR db error henv hdbc hstmt1 else printf 8s 30s 5s 10s 8s n Id Name i Ag Dept n P Dept no n int i for i 0 i lt 65 i printf printf n if SOL ERROR SOLBindCol hstmt1 1 SOL C CHAR id sizeof id amp len printf SQLBindCol error im db error henv hdbc hstmt2 lf SOL ERROR SOLBindCol hstmti1 2 SOL C CHAR name sizeof name amp len printf SQLBindCol error im db error henv hdbc hstmt1 209 S
91. OLColAttribute amp columnNameLength ODBC Functions SOL Columns SQLColumns SQLColumns retrieves column information of a specified tableas an result set format SQLColumnsW as a Unicode string supports same execution as SOLColumns SOLRETURN SQLColumns SOLHSTMT stmt SOLCHAR cName SOLSMALLINT cNameLength SOLCHAR sName SOLSMALLINT sNameLength SOLCHAR tName SOLSMALLINT tNameLength SOLCHAR colName SOLSMALLINT colNameLength Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLCHAR cName Input Catalog Name SOLSMALLINT cNameLength Input The character number of cName SOLCHAR sName Input Name of the schema to retrieve SQLSMALLINT sNameLength Input The character number of sName SQLCHAR tName Input Table name to retrieve SQLSMALLINT tNameLength Input The character number of tName SOLCHAR colName Input Column to retrieve SOLSMALLINT colName Input The character number of colName Length SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE ODBC Users Manual 46 SOL ERROR SOL Columns This function is usually used before execution of the command to get column information in the database catalog SQLColumns can be used to retrieve all data types returned by SQLTables On the contrary SOLColAttribute and SOLDescribeCol functions describe columns of the result set and SQLNumResultCols
92. OLENumbhesultCols x32 c tort t e eet ect ora dei ed ron te e ede eee x 235 SOLE A id 235 SQLPrimaryKeys See SOLCOoltimns Age id 235 SOLProcedureColumns See SQLCOIUMNS EEN 236 SQLProcedures See SQLColumns SOLSetConnectAttr SQLSetEnvaAttr RTE du E SOL Statistics See SOL Columns EEN SOL Tables See SOLCOlumfis bot bti EEGENEN e State Transition Table enee AppendixD ODBC Conformance Levels Interface Conformance Levels Function Conformance Level AppetidixE Upgrades siicsccstsccscesscescecssoscesssvsoastonteanastiesecsessscssbssaececssseccasssacsediondeanashdedadsusedsssdsenessbeetedsesetescosdnascassoaes RECH SOLEHAR ele ON SQL BIT SQL VARBIT ascii SEET SOLE NIBBLE sio tiet ctt edet opt A DIARI M RN TIER SOM BYTE D DATE SQL TYPE TIMESTAMP Other Chand pe PD PES SOLC OSeCU ratita ia Ai SQLBindParameter ColumnSize Aroument EEN 255 SQLBindParameter StrLen or IndPtr Argument EEN 255 SOLPu tData SOLPararmbDatal oec ete esed Cet ee Ee gto EAR ee 256 Limitation on ALTER SESSION statements SQLRowCount SOLMoreResults functions Unlimited Array Execute Array Fetch E Un available Properties 260 Preface About This Manual About This Manual This manual describes how to use the ODBC Target Users This manual has been prepared for the following Altibase users Database Manager Performance Manager Dat
93. OLFreeStmt stmt SQL DROP return SQL ERROR SOLBindParameter stmt 6 SOL PARAM INOUT SOL C DOUBLE SQL NUMERIC 10 3 amp etc 0 amp etc ind SOL SUCCESS ODBC Users Manual 40 SQLBindParameter execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR Execute the prepared statement sprintf id 10000000 sprintf name namel age 28 birth year 1980 birth month 10 birth day 10 birth hour 8 birth minute 50 birth second 10 sex 1 etc 10 2 id ind SOL NTS id gt NULL terminated string name ind 5 name gt length 5 etc is the fixed size type Therefore it will be ignored unless the indi cator is SQL NULL DATA if SQLExecute stmt SQL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR 41 ODBC Functions SOLColAttribute SOLColAttribute SQLColAttribute brings the attributes for the column of the result set and judges the count of col umns SQLColAttributeW as a Unicode string supports same execution as SOLColAttribute Syntax 64 bit Windows SQLRETURN SQLColAttribute SOLHSTMT stmt SOLSMALLINT columnNumber SOLSMALLINT fieldIdentifier SOLCHAR charAttributePtr SOLSMALLINT bufferLength SOLSMALLINT stringLengthPtr SOLLEN numericAttributePtr Other Platforms SOLRETURN SQLColAttribute SOLHSTMT stmt SOLSMAL
94. Prepare function is called and successfully executed when the handle type is SQL_HANDLE_STMT and the status is S1 S1 status will be kept If SQLPrepare function is called and successfully executed when the handle type is SOL HANDLE STMT and the status is converted to 52 the status of the command will be converted into S2 Otherwise the command status will remain as S1 as it was If the function is called while the handle type is SQL_HANDLE_STMT and the status is S6 the ODBC administrator always returns SOL ERROR and SQLSTATE 24000 Invalid Cursor State 231 ODBC Error Codes Statement State Transition related Errors SOLAllocHandle SoUnallocated S1Allocated S2Prepared S6Infetch S1 When HandleType is SOL HANDLE STMT SQLBindCol SOUnallocated S1Allocated S2Prepared S6Infetch IH SQLBindParameter SoUnallocated S1Allocated S2Prepared S6Infetch 1H SQLColumns SQLGetTypelnfo SQLPrimaryKeys SQLProcedureCol umns SQLProcedures SQLStatistics SQLTables SOUnallocated S1Allocated S2Prepared S6Infetch 1H S gt S6 E gt S1 24000 S gt S6 ODBC User s Manual 232 Statement State Transition related Errors SoUnallocated S1Allocated S2Prepared S6Infetch Error Error Error Error SOUnallocated S1Allocated S2Prepared S6Infetch gt S0 gt S0 gt S0
95. QLCLI demo_ex4 cpp SOLSetStmtAttr stmt SOL ATTR PARAM BIND TYPE void sizeof demo ex4 data 0 ODBC Users Manual 156 SQLSetStmtAttr SOLSetStmtAttr stmt SOL ATTR PARAMSET SIZE void 10 0 SOLSetStmtAttr stmt SQL ATTR PARAMS PROCESSED PTR void amp processed ptr 0 SOLSetStmtAttr stmt SOL ATTR PARAM STATUS PTR void status 0 You may use Automic Array Insert SOLSetStmtAttr stmt SOL ATTR PARAMSET SIZE SOLPOINTER array size 0 Specify Array Size SOLSetStmtAttr stmt ALTIBASE STMT ATTR ATOMIC ARRAY SOLPOINTER SOL TRUE 0 Specify Atomic attribute 157 ODBC Functions SQLSpecialColumns SQLSpecialColumns SQLSpecialColumns retrieves the following information about columns within a specified table The optimal set of columns that uniquely identifies a row in the table Columns that are automatically updated when any value in the row is updated by a transac tion SQLSpecialColumnsW as a Unicode string supports same execution as SQLSpecialColumns SOLRETURN SQLSpecialColumns SOLHSTMT stmt SOLSMALLINT fColType SOLCHAR szTableQual SOLSMALLINT cbTableQual SOLCHAR szTableOwner SOLSMALLINT cbTableOwner SOLCHAR szTableName SOLSMALLINT cbTableName SOLSMALLINT fScope SOLSMALLINT fNullable Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLSMALLINT fColTyp
96. QLSMALLINT type Arguments Data Type Argument In Out Description SOLHENV Env Input Environment Handle SOLHDBC Dbc Input Connection Handle SOLSMALLINT type Input One of the following two val ues SOL COMMIT SOL ROLLBACK Return Values SQL SUCCESS SOL INVALID HANDLE SOL ERROR Description Completing the transaction with SOL COMMIT or SOL ROLLBACK will have the following effects Even after SOLTransact is called the statement handle remains valid The bound parameter and the column binding remain alive longer than the transaction 173 ODBC Functions SQLTransact Discarding incompleted result sets Calling SQLTransact when there is not transaction is currently used will return SQL_SUCCESS with out any affecting the database server SQLTransact may fail while Commit or Rollback is executed due to loss of connection In this case an application cannot judge whether commit or rollback was made In this case the database admin istrator handles it manually Example See SALTIBASE_HOME sample SQLCLI demo_tran1 cpp SQLTransact SQL NULL HENV dbc SQL COMMIT ODBC Users Manual 174 3 LOB Interface This chapter describes functions and data types that can be used for handling LOB data 175 LOB Interface LOB Data Types LOB Data Types The following table shows SOL data type identifiers that support LOB SOL GE Typeldentifier Data Type Description SQL_BLOB BLOB BLO
97. ROP return SQL ERROR if SOLGetLobLength stmt lobLoc SOL C CLOB LOCATOR amp valueLength SOL SUCCESS execute err dbc stmt SOLGetLobLength SOLFreeStmt stmt SOL DROP return SQL ERROR for accumLength 0 accumLength lt valueLength accumLength procLength if valueLength accumLength 256 forLength 256 else forLength valueLength accumLength if SOLGetLob stmt SOL C CLOB LOCATOR lobLoc accumLength forLength SOL C CHAR buf 256 amp procLength SOL SUCCESS execute err dbc stmt SOLGetLob SOLFreeStmt stmt SQL DROP 193 LOB Interface SOL Gett ob return SOL ERROR printf s buf if SQLFreeLob stmt lobLoc SQL SUCCESS execute err dbc stmt SOLFreeLob SOLFreeStmt stmt SOL DROP return SQL ERROR ODBC Users Manual 194 SOLPutLob SOLPutLob SOL Putt ob insert update or delete data in an application data buffer to the current LOB pointed by a LOB locator Each operation is handled as a special case of the update operation Inserting is to update LOB data with length 0 with new data Deleting is to update the LOB data for length n with 0 SQLRETURN SQLPutLob SOLHSTMT stmt SQLSMALLINT locatorCType SOLUBIGINT targetLocator SOLLEN fromPosition SOLLEN forLength SOLSMALLINT sourceCType SOLPOINTER value SOLLEN valueLength Data Type Argument In Out Descrip
98. SOL INVALID HANDLE SQL ERROR ODBC Users Manual 166 SQLTablePrivileges SQLTablePrivileges returns the data in the standard result set format sorted by TABLE CAT TABLE_SCHEM TABLE_NAME PRIVILEGE and GRANTEE Column Name No Data Type Description TABLE_CAT VARCHAR Always NULL Return TABLE_SCHEM VARCHAR Schema name NULL if not applicable to the database TABLE_NAME VARCHAR NOT NULL Table name GRANTOR VARCHAR Name of the user who granted the privilege NULL if not applicable to the database GRANTEE VARCHAR NOT NULL Name of the user to whom the privilege was granted PRIVILEGE VARCHAR NOT NULL Table privilege One of the following privi leges Alter The grantee can change the definition of the table Delete The grantee can dele the rows in the table Index The grantee can perform index opera tions such as create or alter for the table INSERT The grantee can insert new rows to the table REFERENCES The grantee can refer to the columns of the table with the limited condi tions SELECT The grantee can search one or multi ple columns in the table UPDATE The grantee can modify one or more data for the table IS_GRANTABLE VARCHAR Indicates whether the grantee can give privi lege to other users Yes No Or NULL if unknown or not applicable to the database 167 ODBC Functions SOLT
99. SOL statement has been successfully executed The macro value is 0 SOL PARAM SUCCESS WITH INFO An SOL statement has been successfully executed however the warning data can be viewed from the diagnosis data structure The macro value is 5 SOL PARAM ERROR Error occurs during the execution of parameters additional error information can be viewed on the diagnosis data structure The macro value is 6 SOL PARAM UNUSED This parameter set is not used partly because an error has occurred preventing the previous parameter from further proceeding The macro value is 7 ODBC Users Manual 154 SQLSetStmtAttr Attribute Contents SQL ATTR PARAMS PROCESSED PTR Necessary for array binding Indicates the buffer that return the number of parame ters including the errors In case of the NULL pointer no data will be returned If SOL SUCCESS or SOL SUCCESS WITH INFO is not returned upon calling of SOLExecDirect or SOLExe cute the contents of the buffer will not be defined SQL ATTR PARAMS ROW COUNTS Necessary for array binding PTR Sets the buffer that returns the following values as the result of SOLExecute to array binding SQL SUCCESS When an SQL statement was success fully executed for all array elements SQL ERROR When even one array element fails to exe cute SQL statement SQL NO DATA When no array element was changed inputted or deleted SOL ATTR PARAMS SET ROW COU Necessary for arra
100. SOLFreeStmt stmt SOL DROP return SQL ERROR if SOLBindParameter stmt 1 SOL PARAM INOUT SQL C CHAR SQL CHAR 8 O id in sizeof id in NULL SQL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR 29 ODBC Functions SQLBindCol Set the variable to bring the result of Select 1f SOLBindCol stmt 1 SOL C CHAR id sizeof id NULL SOL SUCCESS printf SQLBindCol error n execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLBindCol stmt 2 SOL C CHAR name sizeof name NULL SQL SUCCESS printf SQLBindCol error n execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLBindCol stmt 3 SOL C SLONG amp age 0 NULL SQL SUCCESS printf SQLBindCol error n execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR To display the result while the result is available printf id tName tAge tbirth t sex tetc n sprintf id in d0000000 i if SQLExecute stmt SOL SUCCESS execute err dbc stmt SQLExecute SOLFreeStmt stmt SOL DROP return SQL ERROR if rc SQLFetch stmt SOL NO DATA amp amp rc SOL SUCCESS printf 10s 20s 5d 4d 02d 02d 02d 02d 02d t 2d t id name age birth year birth month birth day birth hour birth minute birth second sex if etc ind SQL NULL DATA
101. SOLHSTMT hstmt SQLCHAR table TBL NAME LEN column name COL LEN type name TBL NAME LEN default val TBL NAME LEN is nullable 5 SOLINTEGER column size order len SQLSMALLINT scale precision printf Type Table Name gets table if SOL ERROR SQLColumns hstmt NULL 0 NULL 0 table SOL NTS NULL 0 printf SQLExecute SQLExecDirect An db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 4 SOL C CHAR column name COL LEN amp len printf SQLBindCol error gt 4 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 6 SOL C CHAR type name TBL NAME LEN amp len printf SQLBindCol error gt 6 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 7 SOL C SLONG amp column size 0 amp len printf SQLBindCol error gt 7 db error henv hdbc hstmt return SQL ERROR if SQL ERROR SOLBindCol hstmt 8 SOL C SSHORT precision 0 printf SQLBindCol error gt 10 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 9 SOL C SSHORT amp scale 0 amp len printf SOLBindCol error gt 9 db error henv hdbc hstmt return SQL ERROR if SQL ERROR SQLBindCol hstmt 13 SQL C CHAR default val TBL NAME LEN amp len printf SQLBindCol error gt 13 db er
102. SOLINTEGER StringLength Input When ValuePtr is the character string StringLengt is the length of the character string or SQL NTS If ValuePtr is 32 bit integer this argument is ignored Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR ODBC Users Manual 144 SQLSetConnectAttr An application can call SOLSetConnectAttr at any point whether the connection is allocated or released All connections successfully set by an application and statement attribute are stored until SQLFreeHandle is called in the current connection Attribute Contents SQL_ATTR_AUTOCOMMIT 32 bit value to set the commit mode SQL_AUTOCOMMIT_ON Each SQL statement is auto matically committed SQL_AUTOCOMMIT_OFF Not automatically commit ted SQL_ATTR_CONNECTION_TIMEOUT Set timeout value to prevent blocking that may occur in select or poll in an unstable network SQL_ATTR_PORT Server port setting 32 bit Integer SQL_ATTR_TXN_ISOLATION 32 bit value that sets the transaction isolation level for the current connection referred to by dbc ALTIBASE_APP_INFO Specify an identifier for an ODBC client to obtain more detailed information on the user s session ALTIBASE_DATE_FORMAT Sets the date format Supports YYYY MM DD HH MI SS as the default SQLSTATE Description Comments 08S01 Communication channel error Communication channel fail
103. SQLFetch is called after SOLBindFileToCol is called LOB data from DBMS is stored in a file and the length byte of the data stored in the file is stored in the buffer pointed by the valueLength pointer If LOB is NULL SOL NULL DATA is stored in the buffer pointed by the valueLength pointer The values of fileName fileNameLength and fileOptions arguments are referred to upon SQLFetch 179 LOB Interface SQLBindFileToCol and any error in these arguments is also reported during fetching To transfer more than one LOB to a file at once upon fetching all of the fileName fileNameLength fileOptions and valueLength arguments should be arrays Diagnosis SOLSTATE Description Note 08501 A communication line fault Data A communication line fails before transmission failure function processing is complete between ODBC and DB HY000 A general error Related Functions SOLBindCol SOLBindFileToParam SQLDescribeCol SOLFetch Examples It is assumed that a table has been created with the following DDL CREATE TABLE T1 il INTEGER PRIMARY KEY i2 BLOB Write one LOB to a file SOLCHAR fileName 16 SQLINTEGER fileNameLength 15 SQLUINTEGER fileOptions SOL FILE CREATE SOLINTEGER valueLength strcpy query SELECT i2 FROM T1 WHERE il 1 if SOLPrepare stmt query SQL NTS SQL SUCCESS execute err dbc stmt SOLPrepare SOLFreeStmt stmt SOL DROP return SQL ERROR
104. Statement Hanle Calling SOLFreeHandle of which handleType is SOL HANDLE STMT will release all resources allo cated by calling SOLAllocHandle of which handleType is SOL HANDLE STMT Calling SOLFreeHan dle to release the command with the result suspended by an application will delete the suspended results Diagnosis SOLSTATE Description Comments HY000 General error HY001 Memory allocation error Failed to allocate the memory for the explicit handle Related Functions SOLAllocHandle Example See SALTIBASE_HOME sample SQLCLI demo_meta1 cpp gt if dbc NULL SQLFreeHandle SQL HANDLE DBC dbc if env NULL SQLFreeHandle SQL HANDLE ENV env ODBC Users Manual 88 SQLFreeStmt SQLFreeStmt SQLFreeStmt stops processing associated with a specific statement closes any open cursors associ ated with the statement discards pending results or optionally frees all resources associated with the statement handle Syntax SOLRETURN SQLFreeStmt SOLHSTMT stmt SOLSMALLINT fOption Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLSMALLINT fOption Input Handle Control Method SOL CLOSE SOL DROP SOL UNBIND SQL RESET PARAMS Return Values SOL SUCCESS SOL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description Calls SOLFreeStmt with the one of following options SQL CLOSE Closes th
105. StrLen or Ind as the last argument of SOLBindParameter to not Null pointer but valid pointer vari ables If SOL DATA AT EXEC is 2 as constant number or SOL LEN DATA AT EXEC is less than 100 with out initializing memory completely CLI library judges user intends to send the argument with SOLPutData And CLI library returns SOL NEED DATA when you call SQLExecute If SOLExecDirect returns the unintended value SOL NEED DATA cause of no initialized value above this influences on functions called next So you need special care that function sequence errors in all functions called next cause to return SOL ERROR SQLPutData SOLParamData ODBC CLI in Altibase 5 supports SOLPutData and SOLParamData provided not in previous ver sion Refer to MSDN for details about each function The following is the example program with using functions and StrLen or IndPtr mentioned above Table Schema CREATE TABLE T2 CHAR I1 INTEGER I2 CHAR 50 void putdata test void SOLRETURN sRetCode SOLHANDLE sStmt SQLINTEGER il SQLLEN ilind ODBC User s Manual 256 Other Changes SOLCHAR i2 10 unsigned char 0000000000000 unsigned char 1111111111111 test has been done unsigned char 2222222222222 Abra ca dabra unsigned char 3333333333333 Short accounts make long friends unsigned char 4444444444444 Whar the hell are you doing man unsigned char 5555555555555 Oops I missed
106. TOR or SQL C BLOB LOCATOR If a LOB locator has not been obtained during the current transaction it cannot be used as an argu ment for this function This is because a LOB locator becomes invalid if a transaction is terminated If an invalid LOB locator is used as an argument this function will return SOL ERROR and the buffer pointed by the valueLength argument will not be changed The length of LOB is returned via the valueLength argument However If a LOB locator points NULL LOB SQL NULL DATA is returned to the buffer pointed by the valueLength argument If a LOB loca tor points NULL LOB this function will not return an error SOLSTATE Description Note 08S01 A communication link fault Data A communication link failed before transmission failure function processing is complete between ODBC and DB HY000 A general error SQLBindCol SQLBindParameter SOLFetch SOLExecute SOLGetLob SOLPutLob 189 LOB Interface SQLGetLobLength Example It is assumed that a table has been created with the following DDL CREATE TABLE T1 il INTEGER PRIMARY KEY i2 BLOB Get the length of LOB data DOLINTEGER valueLength SOLUBIGINT lobLoc strcpy query SELECT i2 FROM T1 WHERE il 1 if execute err dbc SQLFreeStmt stmt return SQL ERROR SQLExecDirect stmt query SQL NTS SQL SUCCESS stmt SQLExecDirect SQL DROP Tis if SQLBindCol stmt
107. The connection name is already in The corresponding dbc is already con use nected to the database 08501 Communication channel error Communication channel error before the function processing is completed between the ODBC and the database HY000 General error The character set does not exist HY001 Memory allocation error Cannot allocate the requested mem ory for the ODBC to execute the func tion and complete execution SOLAllocHandle SOLDisconnect SQLDriverConnect SQLSetConnectAttr 51 ODBC Functions SQLDescribeCol SQLDescribeCol SQLDescribeCol returns the name of the column data type decimal value and NULLability of col umns from the result set SQLDescribeColW as a Unicode string supports same execution as SOLDescribeCol SQLRETURNSQLDescribeCol SOLHSTMT stmt SOLSMALLINT col SOLCHAR name SOLSMALLINT nameMax SOLSMALLINT nameLength SOLSMALLINT type SOLINTEGER precision SOLSMALLINT scale SOLSMALLINT nullable Argun Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLSMALLINT col Input Order of the parameter marker Starts with 1 SOLCHAR name Output Pointer of the column name SOLSMALLINT nameMax Input The character number of the Name SOLSMALLINT nameLength Output The length of the name excluding NULL termination byte SOLSMALLINT type Output Pointer of the SOL data type in the col
108. Type Argument In Out Description SOLHENV env Input Environment Handle SOLHDBC dbc Input Connection Handle SOLHSTMT stmt Input Statement handle SQLCHAR state Output Pointer of SOLSTATE SOLINTEGER err Output Pointer of unique Altibase error code SQLCHAR msg Output Pointer of the diagnosis message SQLSMALLINT msgMax Input The character number of the msg buffer SQLSMALLINT msgLength Output Pointer of the total length of return buf fer Excludes NULL termination character urn SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR 67 ODBC Functions SOLSTATE is the same as defined by X OPEN SQL CAE and X OPEN SQLCLI snapshot SOLERROR gets diagnosis information as followings To gain environment related diagnosis information send a valid environment handle Set dbc and stmt as SOL NULL DBC and SOL NULL STMT To acquire connection related diagnosis information send the valid database connection handle and set stmt as SOL NULL STMT Arguments env will be ignored To acquire diagnosis information related to a command send the valid statement handle env and dbc Arguments will be ignored If diagnosis information created by one ODBC function is not catched before functions other than SQLERROR are called by the same handle information related to calling of the previous functions will be lost Always true regardless whether there is diagnosis information created by the second
109. UCCESS SOL INVALID HANDLE SOL ERROR Description The ODBC uses the output connection handle to refer to all information related to the connection such as connection status transaction status and error information If the pointer dbc indicating the connection handle refers to the valid connection handle allocated by SOLAllocConnect the calling result will change the original value If it is application program ming error it is not detected by ODBC Call SQLAllocEnv before calling this function ODBC Users Manual 18 SQLAIlocConnect Diagnosis SQLSTATE Description HY000 General error Channel initialization error HY001 Memory allocation error Failed to allocate the memory for the explicit handle HY009 Invalid Arguments used dbc is a NULL pointer null pointer Related Functions SOLAllocEnv SQLConnect SQLDisconnect SQLFreeConnect Example See SALTIBASE_HOME sample SQLCLI demo_ex1 cpp Memory allocation for the environment if SQLAllocEnv amp env SOL SUCCESS printf SQLAllocEnv error WMn return SQL ERROR Memory allocation for the connection if SQLAllocConnect env amp dbc SOL SUCCESS printf SQLAllocConnect error n return SQL ERROR 19 ODBC Functions SQLAllocEnv SQLAllocEnv SOLAllocEnv allocates the resources related to the environment handles SQLAllocEnv can be replaced by SQLAllocHandle
110. Y SIZE 0 SQLSetStmtAttr stmt 153 ODBC Functions SQLSetStmtAttr SOL ATTR PARAM STATUS PTR ParamStatusArray 0 SQLSetStmtAttr stmt SQL ATTR PARAMS PROCESSED PTR amp ParamsProcessed 0 then Execute SQLBindParameter Attribute Contents SQL_ATTR_CONCURRENCY SQLUINTEGER value specifying the temporary process ing of the cursor SQL_CONCUR_READ_ONLY The cursor supports read only Updating is not allowed SQL_ATTR_CURSOR_SCROLLABLE 32 bit integer to designate whether the open cursor can be scrolled for this statement handle Supports only SQL_FETCH_NEXT SQL_ATTR_CURSOR_SENSITIVITY Not used SQL_ATTR_CURSOR_TYPE SQLUINTEGER indicating the cursor type SQL_CURSOR_FORWARD_ONLY The cursor only pro ceeds forward SOL CURSOR STATIC The data located in the result set are static SOL_ATTR_PARAM_BIND_TYPE Setting value which is necessary for array binding To retrieve the data by the column wise binding SOL PARAM BIND BY COLUMN default is set in this field To retrieve the data by the row wise binding the length of the structure or the length of the buffer to which the dynamic parameter will be bound will be set This length must include the bound parameter space SOL ATTR PARAM STATUS PTR Necessary for array binding This field is requested only when PARAMSET_SIZE is higher than 1 Status values are as follows SOL PARAM SUCCESS An
111. a lot Therefore the stored result set must be used instead of repeating the calling The following table lists the columns of the result set No Name Data Type Description 1 TABLE CAT VARCHAR Null will be always returned 2 TABLE SCHEM VARCHAR Primary key table schema name 3 TABLE NAME VARCHAR NOT NULL Primary key table name 4 COLUMN NAME VARCHAR NOT NULL First primary key column name 5 KEY SEQ SMALLINT NOT NULL Column orders of the first primary key starting with 1 6 PK NAME VARCHAR First primary key name SOLSTATE Description Comments 08501 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error HY009 Invalid Arguments used null pointer tNameTransfer NULL pointer SQLBindCol SOLFetch 131 ODBC Functions SQLPrimaryKeys SQLStatistics Example See SALTIBASE_HOME sample SQLCLI demo_meta3 cpp if SQLPrimaryKeys stmt NULL 0 NULL 0 char DEMO META3 SOL NTS SQL SUCCESS execute err dbc stmt SOLPrimaryKeys SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindCol stmt 1 SOL C CHAR szCatalog STR LEN amp cbCatalog SOLBindCol stmt 2 SOL C CHAR szSchema STR LEN amp cbSchema SOLBindCol stmt 3 SOL C CHAR szTableName STR LEN amp cbTableName SOLBindCol stmt 4 SOL C CHAR szColumnName STR LEN a
112. abase User Application Program Developer Technical Assistance Team Before reading this manual understanding of following background knowledge is recommended Basic knowledge required for computers operation systems and operating system utilities Experience in using the relational database or understanding of the database concept Computer programming experience Experience in managing the database server the operation system or the network Software Environment This manual has been prepared assuming Altibase 5 3 1 will be used as the database server Organization This manual has been organized as follows Chapter 1 ODBC Introduction This chapter shows you how to use ODBC ODBC programming procedure ODBC functions Chapter 2 ODBC Functions This chapter shows you the specifications of ODBC functions Chapter 3 LOB Interface This chapter shows functions and data types that can be used for handling LOB data Appendix A Sample Codes This appendix shows the entire sample codes used this documents Appendix B Data Types ODBC Users Manual 11 About This Manual This appendix explains the Altibase SOL data types C data types and conversion between data types Appendix C ODBC Error codes This appendix explains the Altibase ODBC Drive Error reference as defined in X Open and SOL Access Group SOL CAE specification Appendix D ODBC Conformance Levels This appendix describes the conformance
113. ablePrivileges Diagnosis SOLSTATE Description Comments 08501 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY009 Invalid Arguments used null pointer Argument cName is a NULL pointer HY090 Invalid character string or buffer One of the name length Arguments is length smaller than 0 or is not equal to SQL_NTS Related Functions SQLBindCol SQLCancel SQLColumns SOLFetch SOLPrimaryKeys SQLStatistics SOLTables Example See SALTIBASE_HOME sample SQLCLI demo_meta10 cpp if SQLTablePrivileges stmt execute err dbc SQLFreeStmt stmt return SQL ERROR SQLBindCol SQLBindCol SQLBindCol SQLBindCol SQLBindCol SQLBindCol ODBC Users Manual stmt stmt stmt stmt stmt stmt NULL O SYS SQL NTS DEMO META10 SQL NTS SQL SUCCESS stmt SQLTablePrivileges SQL DROP 2 SOL C CHAR szSchema NAME LEN amp cbSchema 3 SQL C CHAR szTableName NAME LEN amp cbTableName 4 SQL C CHAR szGrantor NAME LEN amp cbGrantor 5 SOL C CHAR szGrantee NAME LEN amp cbGrantee 6 SOL C CHAR szPrivilege NAME LEN amp cbPrivilege 7 SQL C CHAR szGrantable 5 amp cbGrantable 168 SQLTables SQLTables SQLTables returns the list of table catalog or schema names and table types stored in a specific data source The driver returns t
114. ample Codes Sample of Using Metadata if SOL ERROR SOLBindCol hstmt1 3 SOL C CHAR age sizeof age amp len d printf SQLBindCol error im db error henv hdbc hstmt1 if SOL ERROR SOLBindCol hstmt1 4 SOL C CHAR dept sizeof dept amp len printf SQLBindCol error im db error henv hdbc hstmt1 if SOL ERROR SOLBindCol hstmt1 5 SOL C CHAR dept no sizeof dept no amp len printf SQLBindCol error nm db error henv hdbc hstmt1 while SQLFetch hstmt1 SOL SUCCESS printf 8s 30s 5s 10s 8s n id name age dept dept no printf Mn SOLFreeStmt hstmt1 SQL CLOSE Disconnect amp free all handle re SQLDisconnect hdbc VES rec SS SOL ERROR printf disconnect errorMm SQLFreeConnect hdbc SOLFreeEnv henv int db error SQLHENV henv SOLHDBC hdbc SOLHSTMT hstmt SQLINTEGER errNo SQLSMALLINT msgLength SOLCHAR errMsg MSG LEN if SOL SUCCESS SQLERROR henv hdbc hstmt NULL amp errNo errMsg MSG LEN amp msgLength return SOL ERROR printf ERR 1d s n errNo errMsg Sample of Using Metadata RR KK RR KK RR RR RK RRR RK RR RK RR RR RR k k KK RR AAA File name meta cpp Meta data search program example k k Used ODBC function SQLAllocEnv ODBC User s Manual 210 ak SQLAllocConnect kk SOLAllocStmt SOLBindCol ak SQLC
115. and you can check supported func tions by using SOL FUNC EXISTS ODBC Users Manual 108 SQLGetFunctions SOLSTATE Description Comments HY000 General Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle HY010 Function Sequence Error SQLGet Info 109 ODBC Functions SQLGetInfo SQLGetinfo This indicates to return general information of DBMS accessed to application SQLGetInfoW as a Unicode string supports same execution as SQLGetInfo SOLRETURN SQLGetInfo SOLHANDLE ConnectionHandle SOLUSMALLINT InfoType SOLPOINTER InfoValuePtr SOLSMALLINT BufferLength SOLSMALLINT StringLengthPtr Data Type Arguments In Out Description SQLHANDLE Connection In Database Connection Handle Handle SQLUSMALLINT InfoType In Data Type which you want to search SQLPOINTER InfoValuePtr Out 5 kinds of data are outputted according to data types of buffer pointer which makes data returned 16 bit integer value32 bit integer value32 bit binary value32 bit maskNull Determination Character String SQLSMALLINT BufferLength In The byte size of buffer which InfoValuePtr indicates SQLSMALLINT StringLength Out The byte length of result values which Ptr InfoValuePtr indicates Return Values SOL SUCCESS SOL SUCCESS WITH INFO SOL ERROR SOL INVALID HANDLE ODBC Users Manual 110 SQLGetInfo SQLGet
116. are hstmt Statement SQL NTS Check to see if there are any parameters If so process them SQLNumParams hstmt amp NumParams if NumParams Allocate memory for three arrays The first holds pointers to buffers in w hich each parameter value will be stored in character form The second con ODBC Users Manual 56 SOLDescribeParam tains the length of each buffer The third contains the length indicator value for each parameter PtrArray SQLPOINTER malloc NumParams sizeof SQLPOINTER BufferLenArray SQLINTEGER malloc NumParams sizeof SQLINTEGER LenOrIndArray SQLINTEGER malloc NumParams sizeof SQLINTEGER for i 0 i c NumParams i Describe the parameter SQLDescribeParam hstmt i 1 amp DataType amp ParamSize amp DecimalDigits amp Nullable Call a helper function to allocate a buffer in which to store the parame ter value in character form The function determines the size of the buffer fr om the SQL data type and parameter size returned by SQLDescribeParam and returns pointer to the buffer and the length of the buffer PtrArray i char malloc ParamSize BufferLenArray i SQL NTS Bind the memory to the parameter Assume that we only have input parame ters SOLBindParameter hstmt i 1 SOL PARAM INOUT SQL C CHAR DataType Param Size DecimalDigits PtrArray i BufferLenArray i amp LenOrIndArray il
117. ase i db indices henv hdbc hstmt break case f db fields henv hdbc hstmt break case q goto end break default printf You Select Wrong job Nn Do Something end re SQLFreeStmt hstmt SQL DROP TE ere ES SOL ERROR printf SQLFreeStmt Error n Disconnect amp free all handle rc SQLDisconnect hdbc if ore SQL_ERROR SOLFreeConnect hdbc SQLFreeEnv henv int db error SQLHENV henv SOLHDBC hdbc SOLHSTMT hstmt printf disconnect error n SQLINTEGER errNo SQLSMALLINT msgLength SOLCHAR errMsg MSG LEN if SOL SUCCESS SQLERROR henv hdbc hstmt NULL amp errNo errMsg MSG LEN amp msgLength printf rCM 1d s n errNo errMsg return SQL ERROR int db tables SOLHENV henv SQLHDBC hdbc SQLHSTMT hstmt SQLCHAR TABLE name TBL NAME LEN type name TBL NAME LEN SQLINTEGER len if SOL ERROR SQLTables hstmt NULL O0 NULL 0 NULL 0 NULL 0 printf Error SQLTables An db error henv hdbc hstmt return SQL ERROR 1f SOL ERROR SQLBindCol hstmt 3 SQL C CHAR TABLE name TBL NAME LEN amp len 213 Sample Codes Sample of Using Metadata printf SQLBindCol error gt 3 In db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 4 SQL C CHAR type name TBL NAME LEN amp len printf SQLBindCol error g
118. athered information Any ODBC function can call this function for diagnosis after its execution This function shows the most recently stored diagnosis information Currently it works for the following handle types SQL HANDLE ENV SQL HANDLE DBC SOL HANDLE STMT For an input Argument if HandleType is SOL HANDLE ENV InputHandle should be SQL NULL HANDLE or if SOL HANDLE DBC it should be an environment handle or if SQL HANDLE STMT it should be a connection handle That is a value should be set properly for each input handle SQLError 103 ODBC Functions SQLGetDiagRec SQLGetDiagRec You can use this when retrieving serveral attributes of diagnostic message after using ODBC func tion Unicode SOLGetDiagRecW supports same execution as SQLGetDiagRec SOLRETURN SQLGetDiagRec Argument SOLSMALLINT SOLHANDLE SOLSMALLINT SOLCHAR SOLINTEGER SOLCHAR SOLSMALLINT SOLSMALLINT handleType handle recNumber sqlstatus nativeError messageText bufferLength stringLength Data Type Argument In Out Description SQLSMALLINT handleType Handle Type SQLHANDLE handle Handle SQLSMALLINT recNumber This starts from 1 of diagnostic message SQLCHAR sqlstatus SQLSTATE SQLINTEGER nativeError Unique Error Number SQLCHAR messageText Buffer pointer recieving message SQLSMALLINT bufferLength Size of message text
119. because error occurs like Optional feature not implemented ODBC User s Manual 260 Index B Basic Programming Steps 9 Binding Parameters 203 C C Data Types 222 Converting C Data into SOL Data types 224 Converting SOL Data into C Data Types 223 D Data Type 243 E Example of Procedure test Program 217 F Function Conformance Level 239 Function Overview 177 L Limitation on ALTER SESSION statements 257 LOB 251 LOB Data Types 176 M Managing Diagnosis Messages 6 o ODBC Error Codes 227 Open Database Connectivity 2 P Programing Considerations 203 S Sample of Simple Basic Program 204 Sample of Using Metadata 210 SOL Data Types 221 SOLAllocConnect 18 SOLAllocEnv 20 SOLAllocHandle 22 SOLAllocStmt 25 SQL_ATTR_MAX_ROWS 260 SQLBindCol 27 SQLBindFileToCol 178 SQLBindFileToParam 183 SQLBindParameter 33 255 SQL_BIT 243 SQL_BYTE 249 SQLCloseCursor 31 255 SOLColAttribute 42 SQLColumns 46 SQLConnect 50 SQLDescribeCol 52 SQLDescribeParam 55 SQLDisconnect 58 SQLDriverConnect 60 SQLEndTran 65 SQLError 67 SQLExecDirect 69 SQLExecute 71 SQLFetch 74 SQLFetchScroll 78 SQLForeignKeys 80 SQLFreeConnect 84 SQLFreeEnv 86 SQLFreeHandle 87 SQLFreeLob 201 SQLFreeStmt 89 SQLGetConnectAttr 91 SQLGetData 94 SQLGetDescField 98 SQLGetDescRec 100 SQLGetDiagField 102 SQLGetDiagRec 104 SQLGetEnvAttr 106 SQLGetFunctions 108 SQLGetInfo 110 SQLGetLob 191 SQLGetLobLength 188 SQLGetPlan 112 SQLGetStmtAttr 1
120. cal server can regard this trial as remote access and then can t allow it shell gt isql u sys p manager s 192 168 3 91 port 11515 sysdba ODBC Users Manual 62 SQLDriverConnect ISQL CONNECTION TCP SERVER 192 168 3 91 PORT NO 11515 ERR 410C8 remote access as SYSDBA not allowed If the values of PORT_NO and NLS_USE aren t specified in connection string you should set same value of environment variable below as the value specified in property file However if you want to set national character figurative constant instead of environment variable you should specify ALTIBASE_NLS_NCHAR_LITERAL_REPLACE as 1 This causes parsing addition ally export ALTIBASE PORT NO 20300 export ALTIBASE NLS USE US7ASCII export ALTIBASE NLS NCHAR LITERAL REPLACE 0 SOLSTATE Description Comments 08001 Unable to establish connection The client is unable to connect to a server 08002 The connection name is in use The connection handle dbc is already connected to the database and still open 08501 Communication channel error The communication channel between the driver and the database to which the driver was attempting to connect failed before the function completed processing HY000 General error An error occurred for which there was no specific SQLSTATE and for which no implementation specific SOLSTATE was defined HY001 Memory allocation error Cannot allocate the requested mem ory for the OD
121. cate memory for three arrays The first holds pointers to buffers in which each parameter value will be stored in character form The second con tains the length of each buffer The third contains the length indicator value for each parameter PtrArray SQLPOINTER malloc NumParams sizeof SQLPOINTER BufferLenArray SQLINTEGER malloc NumParams sizeof SQLINTEGER LenOrIndArray SQLINTEGER malloc NumParams sizeof SQLINTEGER for i 0 i lt NumParams i Describe the parameter SQLDescribeParam hstmt i 1 amp DataType amp ParamSize amp DecimalDigits amp Nullable Call a helper function to allocate a buffer in which to store the parame ter value in character form The function determines the size of the buffer from the SQL data type and parameter size returned by SQLDescribeParam and returns a pointer to the buffer and the length of the buffer PtrArray i char malloc ParamSize BufferLenArray i SQL NTS Bind the memory to the parameter Assume that we only have input parame ters SOLBindParameter hstmt i 1 SOL PARAM INOUT SQL C CHAR DataType Param Size DecimalDigits PtrArray i BufferLenArray i amp LenOrIndArray il Prompt the user for the value of the parameter and store it in the memory allocated earlier For simplicity this function does not check the value against the information returned by SQLDescr
122. ce of the parameters to be replaced as an application variable when SQLExecDirect is called SOLBindParameter binds an application variable with the parameter marker and displays whether data must be converted during data transmission All parameters must be bound before SQLExecDirect is called To select the row in the result set received from the server when an SQL statement is SELECT the buffer must be bound by SQLBindCol after SOLExecDirect is successfully returned and SQLFetch 69 ODBC Functions SQLExecDirect must be called to refer to the bound buffer If SOLExecDirect executes an UPDATE or DELETE statement that does not affect any row calling SQLExecDirect will return SOL NO DATA Use SQLRowCount to check the number of affecting records SOLSTATE Description Comments 08003 Invalid connection handle used 08501 Communication failure Communication channel error HY000 General error HY001 Memory allocation error Failed to allocate the memory for the explicit handle HY009 Invalid Arguments used null pointer sgl is a NULL pointer SOLBindCol SOLEndTran SOLExecute SOLFetch SQLGetData SQLPrepare SOLStmtAttr See SALTIBASE HOME sample SQLCLI demo ex1 cpp sprintf query SELECT FROM DEMO_EX1 if SQLExecDirect stmt query SQL NTS execute err dbc stmt query SQLFreeStmt stmt SOL DROP return SQL ERROR
123. ceeds the data buffer length If the character data length exceeds the data buffer length SOLFetch will cut the NULL ter minatior according to the data buffer length In this way finish the data composed of NULL charac ters If the binary data length exceeds the data buffer length SOLFetch will cut the data according to the data buffer The length of the data buffer is specified in SOLBindCol length Positions the converted data in the data buffer Positions the data length in the length indicator buffer If the indicator pointer and the length pointer are set as the same buffer the length will be recorded for the valid data and SQL NULL DATA will be recorded for the NULL data If there is no bound length indicator buffer SQLFetch will not return the length The contents of the bound data buffer and the length indicator buffer are not defined unless 75 ODBC Functions SOL Fetch SQLFetch returns SOL SUCCESS or SOL SUCCESS WITH NOINFO When the result of SQLFetch is SOL ERROR it is invalid value The row status array is used to return the status of each row in the rowset The address of this array is specified with the SOL_ATTR_ROW_STATUS_PTR statement attribute The array is allocated by the application and must have as many elements as are specified by the SOL_ATTR_ROW_ARRAY_SIZE statement attribute If the value of SOL ATTR ROW STATUS PTRis a NULL pointer SOLFetch will not return the row status etch
124. cessing I 1 SQLFreestrnt SQLDisconnect Release Handles SQLFreeConnect SOLFreeEnv Initializing Handles This is a part to allocate and initialize the environment and connection handles Transition from one phase to the next phase is made through transmission of proper handles to send information about the execution results from the previous phase Handle types provided by ODBC Users Manual 4 Using the ODBC the ODBC are as follows Environment Handles Tthe environment handles obtain general environment about an application environment The envi ronment handles must be allocated before the connection handle In one application multiple envi ronment handles can be allocated Connection Handles The connection handles obtain connection related information that the ODBC manages They Inclu desconnection and transaction status and diagnosis information An application allocates the con nection handle for each connection and attempts to connect to a database server Statement handles The statement handles obtain the information of SOL statements The statement handleare related to the connection handles They allocate the statement handle to execute SOL statements Maxi mum 1024 statements can be allocated to one connection Processing of Transactions The following figure is a general procedure of calling functions to processing a transaction
125. cimal significant digits SQL BINARY SOL BYTES SOL NIBBLE SOL VARBIT Indicates the max allowed length of a parameter marker If column Size is 0 the default columnSize is used The columnSize for each type is as fol lows For SOL BINARY SOL BYTE and SOL VARBIT their columnSize is 32000 For SOL NIBBLE its columnSize is 254 For other types the user defined column Size argument is ignored and the follow ing fixed value is used SOL SMALLINT 5SQL INTEGER 10SQL BIGINT 19SQL REAL 7SQL FLOAT 38SOL DOUBLE 15SQL TYPE DATE 30SQL TYPE TIME 30SQL TYPE TIMESTAMP 30SQL INTERVAL 10SQL_GEOMETRY 3200 The Scale of value SOLPOINTER value Input Sus pended The pointer of the actual data about the parameter when SOLExecute or SOLEx ecDirect is called SOLINTEGER valueMax Input Output Maximum length of the Value buffer for the character or binary C data SOLINTEGER valueLength Input Sus pended Pointer of the input output data length when SOLExecute or SOLExecDirect is called SOL SUCCESS ODBC Users Manual 34 SQLBindParameter SQL SUCCESS WITH INFO SQL INVALID HANDLE SQL ERROR Description Binding Arrays The array binding method reduces the network round trip count and improves the speed by send ing the parameter using array types The following figure briefly shows how works array binding Larger amount of data can be sent in a short
126. d when any value in the row is updated by a transaction SQLStatistics Returns statistics about a single table and the list of indexes associated with the table SQLTablePrivileges Returns a list of tables and the privileges associ ated with each table SQLTables Returns the list of table names stored in a spe cific database 15 ODBC Introduction Summary of ODBC Functions ODBC Users Manual 16 2 ODBC Functions This chapter describes the specifications of ODBC functions For each ODBC functions the following information are described Name of the function and purpose of use Function prototype for C C Users Arguments list of the function Return Values Usages of function and notes Diagnosis message that can be displayed when an error occurrs in function Related Function list Example source codes 17 ODBC Functions SOLAllocConnect SOLAllocConnect SQLAllocConnect allocates an environment connection statement or descriptor handle This func tion allocates the related resources in the environment identified by the connection handles and the input environment handles SQLAllocConnect can be replaced by SOLAllocHandle Syntax SOLRETURN SQLAllocConnect SOLHENV env SQLHDBC dbc Arguments Data Type Argument In Out Description SOLHENV env Input Environment Handle SOLHDBC dbc Output Connection Handle Pointer Return Values SQL S
127. describes the printing rules used in the code example Rules semantics Example Display the optional fields VARCHAR size FIXED VARIABLE 1 Display the mandatory fields Indi ENABLE DISABLE COMPILE cates to make sure to select at least one ODBC Users Manual iv About This Manual Rules semantics Example Argument indicating optional or man ENABLE DISABLE COMPILE datory fields ENABLE DISABLE COMPILE Repetition of the previous argument SQL SELECT ename FROM Omit the example codes employee ENAME HSCHOI 20 rows selected Other symbols Symbols other than the above EXEC p1 1 acc NUMBER 1 1 2 Itelicized words Indicates variable or value that must SELECT FROM TABLE name be provided by user CONNECT userlD password Lower case words Program elements provided by the SELECT ename FROM user such as table names column employee names file names etc Upper case words Elements provided by the system or DESC SYSTEM SYS INDICES keyword appeared in the syntax For more detailed information see the following document list Altibase Installation Manual Altibase Administrator s Manual Altibase Replication User s Manual Altibase Precompiler User s Manual Altibase ODBC User s Manual Altibase Application Program Interface User s Manual Altibase iSQL User s Manual Altibase Utilities User s Manual Altibase Error
128. e If the TYPE is not SQL_TABLE_STAT this col umn contains the number of pages used to store the index If the database does not support the TYPE NULL data returns FILTER_CONDITION VARCHAR In case of the filtered index this column will have the filtering conditions 30000 filter conditions cannot be decided this column is an empty character string Null In case the filter has not been faltered When it is not possible to decide whether the index has been filtered or the TYPE is SQL_TABLE_STAT SQLSTATE Description Comments 08S01 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database ODBC Users Manual 164 SQLStatistics SQLSTATE Description Comments HY000 General error HY009 Use an invalid pointer null pointer tName is a NULL pointer cName is a NULL pointer sName is a NULL pointer Related Functions SQLBindCol SOLFetch SOLPrimaryKeys Example See SALTIBASE_HOME sample SQLCLI demo_meta4 cpp gt if SQLStatistics stmt NULL 0 NULL 0 DEMO META4 SQL NTS SOL INDEX ALL 0 SQL SUCCESS execute err dbc stmt SOLStatistics SOLFreeStmt stmt SOL DROP return SQL ERROR SQLBindCol stmt 2 SQLBindCol stmt 3 SQLBindCol stmt 4 SQLBindCol stmt 6 8 9 1 SQLBindCol stmt SQLB
129. e Input Type of the column to be returned SQL BEST ROWID Returns the optimal column that uniquely identify the rows in the table by searching column value s SQLCHAR szTableQual Input Null will be always returned SOLSMALLINT cbTableQual Input The character number of szTableQual SOLCHAR szlableOwner Input Schema Name SOLSMALLINT cbTable Input The character number of szTableOwner Owner SOLCHAR szlableName Input The table name Cannot be a NULL pointer SOLSMALLINT cbTableName Input The character number of szTableNam SOLSMALLINT fScope Input Not used ODBC Users Manual 158 SQLSpecialColumns Data Type Argument In Out Description SQLSMALLINT fNullable Input Not used Does not allow NULL data because the corresponding columns are returned to the primary keys SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR When fColType is SQL BEST ROWID SQLSpecialColumns returns column s that uniquely identify each row in the table These columns can be used in select list or Where clause SQLSpecialColumns is used to return these columns because SOLColumns does not return the columns that are automatically updated when columns or rows are updated by the transaction If there are no columns that uniquely identifies each row in the table SOLSpecialColumns will return the row set without rows To subsequently call SQLFetch on the command syntax return
130. e SOLGetLob function works in the same way as when a LOB locator points LOB with length 0 If the size of data that will be returned by calling SOLGetLob exceeds the size of bufferSize the SOL GetLob will return SOL SUCCESS WITH INFO SQLSTATE 01004 and the data will be truncated to fit the buffer size before it is returned to the buffer SOLSTATE Description Remark 08S01 A communication link fault Data A communication link failed before transmission failure function processing is complete between ODBC and DB HYO000 A general error SQLGetLobLength ODBC Users Manual 192 SOL Gel ob SOLPutLob Example It is assumed that a table has been created with the following DDL CREATE TABLE T1 il INTEGER PRIMARY KEY i2 CLOB Get LOB data to an application buffer by using the SOLGetLob function SOLCHAR buf 1024 SOLINTEGER valueLength accumLength forLength procLength SOLUBIGINT lobLoc strcpy query SELECT i2 FROM Tl WHERE il 1 if SQLExecDirect stmt query SOL NTS SQL SUCCESS execute err dbc stmt SOLExecDirect SOLFreeStmt stmt SQL DROP return SQL ERROR if SQLBindCol stmt 1 SOL C CLOB LOCATOR amp lobLoc 0 NULL SQL SUCCESS execute err dbc stmt SOLBindCol SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLFetch stmt SQL SUCCESS execute err dbc stmt SOLFetch SOLFreeStmt stmt SOL D
131. e all rolled back However if the program is terminated after SOLDisconnect is called the program will be committed Using SQLFreeStmt function If the second argument is SOL DROP in SOLFreeStmt the status of the handle will be changed into the previous status before the handle was allocated however when SOL CLOSE argument is used the handle status after SOLAllocStmt is executed will be selected and can be used for other que ries In case the command executes SOLPrepare the status will be changed into the preparation status after SOLFreeStmt is called by SOL CLOSE In case SELECT statement is executed by SOLPrepare Execution result of SELECT statement upon changing from SQLExecute to SQLFetch When SQLExecute is called again by binding other hosts variables without fetching untill the last record of the result set invalid cursor state may occur To prevent this the user must call SOLFreeStmt SOL CLOSE and SOLExecute However if SOLFetch was executed until the last record in the execution result of SELECT statement SOL FreeStmt of SOL CLOSE does not need to be called for normal operation Sample of Simple Basic Program IK File name basic cpp Record insertion example of EMPLOYEE table Used ODBC function SQLAllocEnv ak SQLAllocConnect SQLAllocStmt SQLBindCol SOLBindParameter SQLDisconnect SQLDriverConnect SQLExecDirect
132. e cursor related to stmt and discards all pending results An application can open this cursor again by executing SELECT statement again using the same or different variables However if no cursor is open this option will not effect for the application SQL DROP The resources related to the input statement handle will be released and the handle will be freed In case there is an open cursor the cursor will be closed and all pending results will be deleted 89 ODBC Functions SQLFreeStmt SQL_UNBIND Releases all column buffers bound by SOLBindCol for the given StatementHandle SOL RESET PARAMS Releases all parameter buffers set by SOLBindParameter The relation between an application variable or file reference and an SQL statement parameter marker of the statement handle will be released Diagnosis SOLSTATE Description Comments HYO0OO General error Related Functions SOLAllocHandle SOLFreeHandle Example See SALTIBASE HOME sample SQLCLI demo ex1 cpp SOLFreeStmt stmt SOL DROP ODBC Users Manual 90 SQLGetConnectAttr SQLGetConnectAttr SQLGetConnectAttr gets the current setting of connection SQLGetConnectAttrW as a Unicode string supports same execution as SOLGetConnectAttr Syntax SOLRETURN SQLGetConnectAttr SOLHDBC dbc SOLINTEGER Attribute SOLPOINTER ValuePtr SOLINTEGER BufferLength SOLINTEGER StringLengthPtr A
133. e of a multi threaded application one environment handle and one connec tion handle must be allocated to each thread In the multi threaded program the same connection handle can be used by multiple threads at the same time When develop multi threaded applications ideAllocErrorSpace function that allocates space for each thread to store the database related errors must be called during creation of the thread The statement handles SOLHSTMT can be allocated by one connection handle SOLHDBC up to 1024 Note on using the last argument valueLength indicator upon calling SOLBindCol and SOLBind Parameter In case the value fetched by the output argument in SOLBindCol is NULL SOL NULL DATA will be returned to the indicator argument The valueLength of SOLBindParameter is used to indicate the length of the buffer when the data type ofthe argument bound to the input buffer is the variable type When the parameter inout type is SOL_PARAM_INOUT For example Indicator value is SOL_NTS A string in which the buffer ends with NULL SOL NULL DATA Binding the NULL value Ifinout type is SOL_PARAM_OUTPUT in SOLBindParameter the indicator functions same as SQL BindCol indicator in SELECT statement 203 Sample Codes Sample of Simple Basic Program Transaction Commit Mode In case the program is terminated without being committed in the autocommit off session all exe cution statement not committed will b
134. e types If sName is SOL ALL SCHEMAS and cName and tName are empty character strings the result set will include the schema list valid for the database All columns expect that TABLE SCHEM columns will include NULL data If tableType is SQL ALL TABLE TYPES and cName sName and Name are empty character strings the result set will include the list of table types valid for the database All columns except TABLE TYPE column will include the NULL data An application must specify the tableType in capital letters SQLTables returns the data in the standard result set format sorted by TABLE TYPE TABLE CAT TABLE SCHEM and TABLE NAME Name No Data Type Description TABLE CAT 1 VARCHAR Null will be always returned TABLE SCHEM 2 VARCHAR Schema name including TABLE Name NULL if not applicable to the database TABLE NAME 3 VARCHAR Table Name NOT NULL TABLE TYPE 4 VARCHAR Table type name Only Table exists in Altibase REMARKS 5 VARCHAR For future use ODBC Users Manual 170 SQLTables Diagnosis SQLSTATE Description Comments 08501 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error Related Functions SQLBindCol SQLColumns SOLFetch SQLStatistics Example See SSALTIBASE_HOME sample SQLCLI demo_meta1 cpp if if if if SQLTab
135. ectionString SOLCHAR OutConnectionString Output Not used SQLSMALLINT bufferLength Input Not used SQLSMALLINT strLength2Ptr Output Not used SQLSMALLINT DriverCompletion Input Not used ODBC Users Manual 60 SQLDriverConnect Return Values SOL SUCCESS SQL SUCCESS WITH INFO SQL NO DATA FOUND SOL INVALID HANDLE SOL ERROR Description This connection string is used to transmit one or more values needed for completion of the connec tion The contents of the connection string and DriverCompletion determine the connection method Each keyword has following attributes DSN Database name Host IP or host name UID User Id PWD Password If there is no password for the user id no data will be defined CONNTYPE Connection methods 1 TCP IP 2 UNIX DOMAIN 3 IPC PRIVILEGE sys account could be granted sysdba privilege for remote access Access with sysdba sysdba privilege is available through TCP IP and UNIX DOMAIN but remote access is only through TCP IP PORT NO Connection port number NLS USE NLS language such as US7ASCII for English KO16KSC5601 for Korean NLS NCHAR LITERAL REPLACE This checks to use NCHAR with analyzing SQL statements 0 doesn t analyze SQL statments 1 analyzes SOL statements 61 ODBC Functions SQLDriverComnect This causes worse performance TIMEOUT Time waiting for server connection attemption The default value is 3 seconds CONNECTION_TIMEOUT
136. ective environment handle the ODBC will call SQLEndTran for each connection handle related to the environment The handle argument to call the ODBC must be the environment handle of the ODBC In this case the ODBC may commit the transaction or attempt to rollback depending on the type in the connected status If the type is SOL COMMIT SOLEndTran will send commit command to the session related to the connection If the type is SQL ROLLBACK SOLEndTran will give rollback request to the connec tion related session 65 ODBC Functions SQLEndTran In case of the manual commit mode by calling SQLSetConnectAttr that can set SQL_ATTR_AutoCommit statement attribute as SQL AutoCommit OFF the new transaction will internally start when an SOL statement to be included in the transaction is executed Diagnosis SQLSTATE Description Comments HY000 General error Related Functions SQLFreeHandle SOLFreeStmt Example See SALTIBASE HOME sample SQLCLl demo tran1 cpp SOLEndTran SQL HANDLE DBC dbc ODBC Users Manual SOL COMMIT 66 SOL Error SOL Error SQLError returns error or status information SQLErrorW as a Unicode string supports same execution as SOLError SQLRETURN SQLError SQLHENV env SQLHDBC dbc SQLHSTMT stmt SQLCHAR state SOLINTEGER err SOLCHAR msg SOLSMALLINT msgMax SOLSMALLINT msgLength Data
137. ed Buffer The rows fetched buffer is used to return the number of rows fetched including those rows for which no data was returned because an error occurred while they were being fetched In other words it is the number of rows for which the value in the row status array is not SOL ROW NOROW The address of this buffer is specified with the SOL ATTR ROWS FETCHED PTR statement attribute The buffer is allocated by the application This buffer is allocated by an application and set by SQLFetch If SOL ATTR ROWS FETCHED PTR statement attribute is a NULL pointer SOLFetch will not return the number of the fetched rows If SOLFetch does not return SOL SUCCESS or SQL SUCCESS WITH INFO except SOL NO DATA the contents of the row fetched buffer will not be determined In this case the row fetched buffer will be set to 0 idlin g Errors and warnings can apply to individual rows or to the entire function Errors and warnings for the entire function If a random warning is applied to the entire function SQLFetch will return SQL_SUCCESS_WITH_INFO and proper SQLSTATE The warning status records applied to the func tion must be returned before the status records are applied to each row SQLSTATE Description Comments 01004 String data right truncated String or binary data returned for a column resulted in the truncation of nonblank character or non NULL binary data If it was a string value it was right truncated
138. ed it returns row as O The rows in the tables affected by the SOL statement such as cascading delete operationare not included Before this function is called SOLExecute or SOLExecDirect must be called ODBC Users Manual 142 Diagnosis SQLRowCount SOLSTATE Description HY000 Comments General error Related Functions SQLExecDirect SOLExecute Example See SALTIBASE_HOME sample SQLCLI demo_exa5 cpp if SQLExecute stmt execute err dbc stmt query SOLFreeStmt stmt SQL DROP return SQL ERROR SOLRowCount stmt amp row count 143 SOL SUCCESS ODBC Functions SQLSetConnectAttr SOLSetConnectAttr SQLSetConnectAttr sets attributes that govern aspects of connections SQLSetConnectAttrW as a Unicode string supports same execution as SOLSetConnectAttr Syntax SOLRETURN SQLSetConnectAttr SOLHDBC dbc SOLINTEGER Attribute SOLPOINTER ValuePtr SOLINTEGER StringLength Arguments Data Type Argument In Out Description SQLHDBC dbc Input Connection Handle SOLINTEGER Attribute Input Attribute to set SOLPOINTER ValuePtr Input Pointer of value contaied attri bute Depending on the Attribute value the ValuePtr will be either a 32 bit unsigned integer or a pointer indicating the Null terminator string SQL_ATTR_AUTOCOMMIT SOL ATTR CONNECTION TIMEOUT SOL ATTR PORT SOL ATTR TXN ISOLATION ALTIBASE APP INFO ALTIBASE DATE FORMAT
139. een the ODBC and the database is completed HY009 Invalid Arguments used null pointer Argument pktName and fktName are NULL pointer HY090 Invalid string or buffer length The value of one of the name length arguments was less than 0 but not equal to SQL_NTS Related Functions SQLBindCol SOLFetch SOLPrimaryKeys SQLStatistics Example See SALTIBASE_HOME sample SQLCLI demo_meta9 cpp if SQLForeignKeys stmt NULL O SYS SQL NTS ORDERS SQL NTS NULL O NULL O NULL 0 SQL SUCCESS execute err dbc stmt SOLForeignKeys SOLFreeStmt stmt SQL DROP return SQL ERROR SOLBindCol stmt 2 SOL C CHAR szPKSchema NAME LEN amp cbPKSchema SOLBindCol stmt 3 SOL C CHAR szPKTableName NAME LEN amp cbPKTableName SOLBindCol stmt 4 SOL C CHAR szPKColumnName NAME LEN amp cbPKColumnName SOLBindCol stmt 6 SOL C CHAR szFKSchema NAME LEN amp cbFKSchema SOLBindCol stmt 7 SOL C CHAR szFKTableName NAME LEN amp cbFKTableName SOLBindCol stmt 8 SOL C CHAR szFKColumnName NAME LEN amp cbFKColumnName SOLBindCol stmt 9 SOL C SSHORT amp KeySeq 0 amp cbKeySeq 83 ODBC Functions SQLFreeConnect SQLFreeConnect SQLFreeConnect frees resources associated with a specific connection SQLFreeConnect has been replaced by SQLFreeHandle Syntax SQLRETURN SQLFreeConnect SQLHDBC dbe Arguments Data Type Argument In Out De
140. el2 O SQLFreeHandle Core O SQLFreeStmt Core O SOLGetConnectAttr Core O SOLGetCursorName Core O SOLGetData Core O SOLGetDescField Core O ODBC 3 0 SOLGetDescRec Core O ODBC 3 0 SOLGetDiagField Core O ODEC 3 0 SOLGetDiagRec Core O ODBC 3 0 SOLGetEnvAttr Core O SOLGetFunctions Core O SOLGetStmtAttr Core O SQLGetTypelnfo Core O SOLMoreResults Level1 O SQLNativeSal Core O SQLNumParams Core O SQLNumResultCols Core O SQLParamData Core O SQLPrepare Core O ODBC User s Manual 240 Interface Conformance Levels Function Name Level e NN Remarks SOLPrimaryKeys Level O SOLProcedureColumns Level1 O SQLProcedures Level O SOLPutData Core O SOLRowCount Core O SQLSetConnectAttr Core O SQLSetCursorName Core O SQLSetDescField Core O ODBC 3 0 SQLSetDescRec Core O ODBC 3 0 SQLSetEnvAttr Core O SQLSetPos Level X O SQLSetStmtAttr Core O SQLSpecialColumns Core O SQLStatistics Core O SQLTablePrivileges Level2 O SQLTables Core O 241 ODBC Conformance Levels Interface Conformance Levels ODBC User s Manual 242 Appendix E Upgrade This appendix describes the requirements to make ODBC applications for Altibase 4 available for Altibase 5 as follows The level of CLI interface has been improved since the upgrade to Altibase 5 Especially it has high compatibility with user applications and general purpose applications to follow the standard of X O
141. eme a connection should be always established in Non Autocommit Mode Care must be taken as there is no LOB type of a user variable such as SOL C BLOB or SQL C CLOB ODBC Users Manual 176 Function Overview Function Overview The functions that are available for manipulating LOB data are as follows 1 SOLBindFileToCol Non standard Full Retrieve 2 SOLBindFileToParam Non standard Full Insert Full Update 3 SQLGetLobLength Non standard Get the length of LOB data 4 SQLGetLob Non standard Partial Retrieve 5 SQLPutLob Non standard Partial Insert Partial Update Partial Delete 6 SQLFreeLob Non standard Release the LOB locator being used 7 SQLGetData SQLPutData Standard Full Retrieve Update 8 Other ODBC standard functions Among the above functions the functions 1 through 6 are special functions that are provided by Altibase for LOB manipulation and they are not ODBC standard functions ODBC standard functions such as 7 and 8 can be used to access LOB data whether the database column type is LOB or not However when only a standard function is used the functions for partial update and partial retrieve are not available If a user wants to do programming with ODBC Driver Manager he should add the following entry to the odbc ini file LongDataCompat yes If the above entry is added the types such as SQL_BLOB and SQL_CLOB are converted to SQL_LONGVARBINARY and SQL_LONGVARCHAR types
142. enOrIndArray SOLBindParameter hstmt 3 SQL PARAM INOUT SQL C FLOAT SQL REAL 7 0 PriceArray 0 PriceIndArray Row wise Binding When using row wise binding an application defines a structure containing one or two or in some cases three elements for each column for which data is to be returned An application performs the next procedures to use the row wise binding Define the array to include the single set of the parameters including parameters and the length indicator buffers Set SOL ATTR PARAM BIND TYPE in argument attributes of function SOLSetStmtAttr and set the size of the array including program variables in the argument parameter and binds the address of each element to the first element of the array Call SOLBindParameter with following arguments clype is the component type of the parameter buffer sglType is the SQL data type of the parameter Value is the address of the parameter buffer component in the first array element valueMaxis the size of the parameter buffer component valueLength is the address of the length indicator to be bound The following figure shows how row wise binding operates 37 ODBC Functions SQLBindParameter Column A Column B Column C parameter A parameterB parameter C array 0 array 1 d jj AL cora 4 array 3 Example define DESC LEN 51 define ARRAY SIZE 10 typedef tagPartStruct SOLREAL Price SOLUINTEGER PartID SOLCHAR
143. ename3 into T2 if SResult2 print FAIL n msg odbc errormsg Connection echo execute insert msg Mn exit print OK n query select from t2 SResultl odbc_exec Connection query if SResult1 msg odbc errormsg Connection ODBC User s Manual 254 Other Changes echo ERROR select msgin exit Srownumber 0 while odbc fetch row Resultl datal odbc _ result Result1 1 odbc_result Result1 2 data2 data3 odbc_result Resultl1 3 Slen2 strlen data2 Slen3 strlen data3 print in 1n print Row rownumber WMn Srownumber print datal datal An print Mn print data2 Mn print data2 Output is omitted because this is binary data print Mn print dataLen2 Slen2 n print zoe int print data3 Mn print data3 print Mn print dataLen3 1en3 Wn odbc commit Connection Godbc close Connection Other Changes This section describes changes except data types SQLCloseCursor You can call functions in the following order because there isn t ODBC state machine in Altibase4 CLI library SQLHSTMT stmt SQLA1locHandle SQL HANDLE STMT dbc amp stmt SOLPrepare stmt SOLCHAR SELECT 11 FROM T1 SQL NTS SQLExecute stmt SQLFetch stmt SQLExecute stmt However if y
144. ents of the buffer bound StrLen_or_IndPt SOLSTATE buffer byt as SOL C CHAR r characters es AA BB 11 12 8 hex 4141 42423131 00 8 01004 string AABB11 9 hex 414142423131 313200 8 n a string AABB1112 Ee T A rmat Byte type doesn t have special format like NIBBLE or BIT but is the conjunction of binary data CREATE TABLE T1 I1 BYTE 30 INSERT INTO T1 VALUES BYTE 56789ABC SOLLEN Length SOLRETURN rc execution query SELECT FROM T1 Buffer nibble t malloc BUFFER SIZE SOLBindCol stmt 1 do SOL C CHAR SOLPOINTER Buffer BUFFER SIZE memset Buffer 0 BUFFER SIZE rc SQLFetch stmt printf Length d n Length printf Data s n Length while rc SQL NO DATA When you execute the program above the results are as follows 250 amp Length Data Type Execution Query 1 BUFFER SIZE gt 9 Length 8 Data 56789ABC Execution Ouery 2 BUFFER SIZE Length 8 Data 56789A 8 This is bound in byte buffer and then only 6 characters are expressed Execution Ouery 3 BUFFER SIZE Length 8 Data 56789A same as BUFFER SIZE 8 Execution Ouery 4 BUFFER SIZE 6 Length 8 Data 5678 SOLFetch retunrs SOL SUCCESS WITH INFO for execution results except 1 SOLSTATE indicates 01004 BYTEto SQL C BINARY No unusual events for binding to binary in this case DATE SQL TYPE TIMESTAMP SOL TYPE TIMESTAMP
145. env hdbc hstmt1 db error henv hdbc hstmt2 rc SOLBindParameter hstmt2 1 SOL PARAM INOUT SQL C CHAR SQL VARCHAR 30 0 name 0 amp bindp len rf eg EZ SOL ERROR db error henv hdbc hstmt2 207 Sample Codes Sample of Simple Basic Program bindp_len SQL NTS while 1 printf Insert Id Name Age Dept Dept no for EMPLOYEE Table n printf or Type q to Quit n printf Id fflush stdin gets id if id 0 q break printf Name gets name printf Age gets age printf Dept gets dept printf Dept no gets dept no if id 0 name o age 0 dept 0 dept no 0 printf Missing values continue rc SQLExecute hstmt1 rf c SOL ERROR printf Insert Failed n db error henv hdbc hstmt1 else rc SQLTransact henv hdbc SQL COMMIT re SQLEndTran SQL HANDLE ENV hdbc SQL COMMIT if rc SOL ERROR db error henv hdbc hstmt1 else printf Ain COMMIT Success Mn rc SQLExecute hstmt2 ZE pess SOL ERROR else db error henv hdbc hstmt2 printf Inserted row was n if SOL ERROR SOLBindCol hstmt2 1 SOL C CHAR id sizeof id amp len printf SQLBindCol error im db error henv hdbc hstmt2 ODBC User s Manual 208 Sample of Simple Basic Program if SOL ERROR S
146. er marker starting with 1 SOLSMALLINT type Output SQL data type pointer of the parameter SOLINTEGER size Output SQL data type pointer of the parame ter Column size or expression pointer of the corresponding parameter SOLSMALLINT decimaldigit Output Number of decimal values of the column expression pointer of the corresponding parameter SOLSMALLINT NULLable Output Pointer of the value that shows whether NULL is allowed for the parameter or not Return Values SOL SUCC SOL SUCC SOL INVA SOL ERRO ESS ESS WITH INFO LID HANDLE R 55 ODBC Functions SOLDescribeParam Description Parameter iparam is identified by the number It is numbered from the left to the right starting with 1 SQLPrepare must be called before this function Before SOLBindParameter SOLDescribeParam must be called Types sizes decimal digits and NULLable of the parameter have the following limitations type SOL VACHAR size 4000 decimaldigit O nullable SQL NULLABLE UNKNOWN The ODBC Drive cannot decide whether the parameter allows NULL data Diagnosis SOLSTATE Description Comments 07009 Invalid column number iparam is out of the entire argument range HY010 Error in function calling order Called before SQLPrepare SOLEx ecDirect Related Functions SQLExecDirect SQLNumParams SQLPrepare Example See SALTIBASE_HOME sample SQLCLI demo_info2 cpp SOLPrep
147. er time due to reduced network paging count DBMS Applicatio Success Success Insert Success Success Insert Success Success Insert Success Success Success Insert Success Success Insert Success In US Typical Processing Array Binding Processing There are two array binding types Column wise Parameter Binding When using column wise binding an application binds one or two or in some cases three arrays to each column for which data is to be returned To use a column wise binding do the following Set SOL ATTR PARAM BIND TYPE in Arguments Attribute of an application function SOLSetStm tAttr Set SOL PARAM BIND BY COLUMN in param For each column to be bound the applicatoin performs the following procedures ODBC Functions LA Nn SQLBindParameter 1 Allocate the parameter buffer array 2 Allocate the indicator buffer array 3 Call SQLBindParameter with arguments cType is C data type of the single element in the parameter buffer array sglType is the SQL data type of the parameter Value is the address of the parameter buffer array valueMax is the size of the single element in the parameter buffer array valueLength is the address of the length indicator array The following figure shows how the column wise binding operates for each column Column A Column B Column C parameter A parameter B parameter C value length elas length ela length indica
148. es global information about the validity or activation of the connec tion handle To request an environment handle an application must call SOLAllocHandle of which HandleTyp is SQL HANDLE ENV and input handle is SOL Null Handle The ODBC allocates the memory needed for environment information and returns the handle related to the OutputHandle An application sends the OutputHandle value to the subsequent callings that require the environment handles on of the Conne The connection handle provides information about the validity of the statement handle or activa tion of the transaction To request the connection handle an application calls SOLAllocHandle of which HandleTyp is SQL HANDLE DBC InputHandle argument calls SOLAllocHandle and is set as the returned envi ronment handle The ODBC allocates the memory necessary for the connection and returns the han dle values related to the OutputHandle An application sends the OutputHandle to the subsequent callings that require the connection handle n of The statement handle provides command information such as error messages about processing an SQL statement and status state To request the statement handle an application connects to the database and calls SOLAllocHandle before sending an SQL statement For this calling the HandleTyp must be set as SQL HANDLE STM and the InputHandle argument must be set as a connection handle to be returned by calling SOLAllocHandle
149. etch VARBIT columns because conversion tool is made itself without VARBIT types in ODBC standard CREATE TABLE T1 11 VARBIT 12 INSERT INTO T1 VALUES VARBIT 110011000010 INSERT INTO T1 VALUES VARBIT 01011010 SOLCHAR sData 128 SOLLEN sLength sQuery SQLCHAR SELECT I1 FROM T1 SOLBindCol stmt 1 SOL C CHAR sData sizeof sData amp sLength SOLExecDirect stmt sQuery SOL NTS while SQLFetch stmt SOL NO DATA printf bit value Sa sData printf sLength dWMn sLength If you execute program above the following is displayed on the screen 110011000010 sLength 12 01011010 sLength 8 SQL_NIBBLE SQL_C_NIBBLE supported in Altibase4 isn t available to Altibase5 However you can fetch data with SQL_C_BINARY NIBBLE to C type Conversion is available only to SQL_C_CHAR and SQL_C_BINARY 247 Upgrade Data Type Ctypeid Test TargetValuePtr Strlen or IndPtr SOLSTATE SOL C CHAR BufferLength 1 Data CO or 1 Data length to be n a written in the mem ory the user binds Except null and ter mination character BufferLength 2 1 Undefined Undefined 22003 SQL C BINARY None Data See below Data length to be n a for formats written in the mem ory the user binds NIBBLE is fetched in binary format in the same way as BIT but binary format of NIBBLE is different from that of BIT because its precision field has 1
150. eturned SOL SUCCESS SOL INVALID HANDLE SOL ERROR Instead of returning a specified arguments set such as SQLDescribeCol using SQLColAttribute the attributes for a specified column can be defined In case the required information is a string type it will be returned to charAttributePtr In case the required information is numeric type it will be returned to numericAttributePtr The column is identified by its position from left to the right starting with 1 Call SQLNumResultCols before calling SQLColAttribute to check whether the result set exists SOLDescribeCol must be called before SOLBindCol in case an application does not know about column attributes such as data types length etc 43 ODBC Functions SOLColAttribute The following table shows the descriptor types returned by SOLColAttribute Descriptor Data Type Description SQL DESC CASE SENSITIVE SOLINTEGER Discrimination of upper and lower characters SOL DESC CATALOG NAME SOLCHAR Catalog of the table including columns SQL DESC COUNT SOLINTEGER The column number of the result set is returned SOL DESC DISPLAY SIZE SOLINTEGER The maximum number of characters to dis play the column data SQL DESC LABLE SOLCHAR Column label or title SOL DESC LENGTH SOLINTEGER Data bytes related to the column SQL DESC NAME SOLCHAR Name of the column SQL DESC
151. f SQLBindCol error gt 4 db error henv hdbc hstmt return SQL ERROR if SQL ERROR SQLBindCol hstmt 6 SQL C CHAR index name TBL NAME LEN amp len printf SQLBindCol error gt 6 db error henv hdbc hstmt return SQL ERROR if SQL ERROR SOLBindCol hstmt 7 SOL C SSHORT amp indextype 0 amp len ODBC User s Manual 216 Example of Procedure test Program printf SQLBindCol error gt 7 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 8 SOL C SSHORT amp indexno 0 amp len printf SOLBindCol error gt 8 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 9 SOL C CHAR column name COL LEN len printf SOLBindCol error gt 9 db error henv hdbc hstmt return SQL ERROR printf Table s n table while SQLFetch hstmt SQL SUCCESS printf Column Name s n column_name printf Index Name s n index name printf Index Type d n indextype printf Index Num din indexno printf Is Unique s n nonunique NO YES a return SQL SUCCESS Example of Procedure test Program RR K k RRR k k RR RR RK RRR KR RR RK RR RR RR RR RK RR RR e e ke k File name proctest cpp Example of procedure test program ede Used ODBC function SQLAllocEnv kk SQLAllocConnect ak SQ
152. f SOL SUCCESS SQLERROR env con SOL NULL HSTMT NULL amp errNo errMsg MSG LEN amp msgLength printf ERR d s n errNo errMsg SQLFreeEnv env exit 1 ODBC User s Manual 218 if SOLAllocStmt con amp stmt SOL ERROR printf SQLAllocStmt error n exit 1 strcpy sql drop procedure proci if SQLExecDirect stmt sql SQL NTS SQL ERROR printf ERROR drop procedure error Mn else printf SUCCESS drop procedure n strcpy sql create procedure procl pl in integer p2 in out integer p3 out integer as begin p3 pl p2 p2 pl 2 end if SQLExecDirect stmt sql SQL NTS SQL ERROR printf ERROR create procedure error In else printf SUCCESS create procedure n strcpy sql execute proc1 if SQLPrepare stmt sql SQL NTS SQL ERROR printf ERROR prepare stmtin else Bind Parameters printf SUCCESS prepare stmtin if SQLBindParameter stmt 1 SOL PARAM INOUT SQL C SLONG SOL INTEGER 0 O amp il O amp il len SQL ERROR printf ERROR Bind Parameter Wn else printf SUCCESS Bind Parameter Wn if SQLBindParameter stmt 2 SOL PARAM INOUT OUTPUT SQL C SLONG SOL INTEGER 0 O amp i2 4 amp i2 len SQL ERROR printf ERROR 2 Bind Parameter Mn else 219 Example of Procedure test Program Sample Codes Exa
153. f not SOL NO DATA FOUND is returned If the result set is fetched the cursor is located at the first result set Depending on an application when its result set is used a further check is performed to see if there is more result left If there are more result values left SOL SUCCESS is returned and if not SOL NO DATA FOUND is returned Related Function SOLFetch ODBC Users Manual 118 SQLNativeSql SQLNativeSql This coverts SQL statements to statements supported by ODBC driver Unicode SOLNativeSqlW supports same execution as SOLNativeSq l Syntax SOLRETURN SQLNativeSql SOLHDBC dbc SOLCHAR InstatementText SOLINTEGER textLength SOLCHAR OutStstementText SOLINTEGER bufferLength SOLINTEGER textLength Argument Data Type Argument In Out Description SQLHDBC dbc In Connection Handle SOLCHAR Instatement In SQL Statements to Convert Text SQLINTEGER textLength In Length of InstatementText SQLCHAR OutStste Out Buffer Pointer recieving the converted mentText SQL statements SQLINTEGER bufferLength In Size of OutStstementText SQLINTEGER textLength Out Size specified in OutStstementText Return Value SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description This converts SQL statements to statements supported by ODBC driver 119 ODBC Functions SQLNativeSql SOLSTATE Description Comments HY000 Genera
154. gn key table name SOLSMALLINT fktName Input The character number of fktName Length SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SQL ERROR If pktName contains a table name SOLForeignKeys returns a result set containing the primary key of the specified table and all of the foreign keys that refer to it The list of foreign keys in other tables does not include foreign keys that point to unique constraints in the specified table If fktName has a table name SOLForeignKeys will returns a result set containing all of the foreign keys in the specified table that point to primary keys in others tables and the primary keys in the other tables to which they refer The list of foreign keys in the specified table does not contain for eign keys that refer to unique constraints in other tables If both pktName and fktName have table names SOLForeignKeys will return the foreign keys of the table specified by fktName For fktName refer to the primary keys of the table specified in pkt Name SQLForeignKeys returns the result in the standard result set form sorted by FKTABLE CAT FKTABLE SCHEM FKTABLE Name and KEY SEQ in case the foreign keys related to the primary keys are requested If the primary keys related to the foreign keys are requested the result in the standard result set sorted by PKTABLE CAT PKTABLE SCHEM PKTABLE Name and KEY SEQ will be returned The following table lists the strings of
155. h fileOptions 10 ind SOL SUCCESS execute err dbc stmt SOLBindFileToParam wy SOLFreeStmt stmt SOL DROP return SQL ERROR Specify a file to insert data strcpy fileName 0 Cube avi strcpy fileName 1 Movie avi strcpy fileName 2 Term avi for i 0 i c 3 i il i i 1 fileNameLength i SQL FILE READ fileOptions i ind i 0 strlen fileName i if SQLExecute stmt SOL SUCCESS execute err dbc stmt SQLExecute ys SOLFreeStmt stmt SOL DROP return SQL ERROR Update one LOB in a table SOLCHAR fileName 16 SOLINTEGER fileNameLength 15 SQLUINTEGER fileOptions SOLINTEGER ind 0 SQL FILE READ strcpy query UPDATE T1 SET i2 WHERE il 1 Prepare a statement and bind a file if SOLPrepare stmt query SQL NTS SQL SUCCESS execute err dbc stmt SOLPrepare ny SOLFreeStmt stmt SOL DROP return SQL ERROR strcpy fileName Terminator2 fix avi if SQLBindFileToParam stmt 1 SQL BLOB fileName amp fileNameLength amp fileOp tions 16 amp ind SQL SUCCESS execute err dbc stmt SOLBindFileToParam WI SOLFreeStmt stmt SOL DROP return SOL ERROR if SOLExecute stmt SOL SUCCESS execute err dbc stmt SOLExecute n SOLFreeStmt stmt SOL DROP return SQL ERROR 187 LOB Interface SQLGetLobLength SQLGetLobLength SQLGetLobLength gets the length of the
156. he data to ValueMax length with the NULL ter minatior length deducted In this way finish the data composed of NULL characters If the binary 95 ODBC Functions SQLGetData data length exceeds the data buffer length SQLGetData will cut the data according to the Value Max If the data buffer is small and does not include the NULL terminatior SQLGetData will return SQL_SUCCESS_WITH_INFO SQLGetData does not cut the data converted into the fixed length data type SQLGetData always assumes that the Value length is the size of the data type Places the converted or cut data in Value Places the data length in pcbValue If pcbValue is a NULL pointer SQLGetData will not return the length If the data is cut during conversion although there is no loss of significant information for example 1 234 is converted into 1 or if valueMax is too small for example character string abcde i placed in the 4 byte buffer SQLGetData will return SQLSTATE 01004 with the data cut and SQL_SUCCESS_WITH_INFO If SOLGetData does not return SOL SUCCESS or SQL SUCCESS WITH INFO contents of the bound data buffer and the length indicator buffer will not be defined SOLSTATE Description Comments 01004 String data right truncated When the size of the value to be returned is higher than the size of the given buffer 07009 Invalid descriptor index The col value is 0 The col value is higher
157. he information as a result set SQLTablesW as a Unicode string supports same execution as SQLTables SOLRETURN SQLTables SQLHSTMT stmt SQLCHAR cName SQLSMALLINT cNameLength SQLCHAR sName SOLSMALLINT sNameLength SOLCHAR tName SOLSMALLINT tNameLength SOLCHAR tableType SOLSMALLINT tableTypeLength Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle for the searched result SQLCHAR cName Input Catalog Name SOLSMALLINT cNameLength Input The character number of cName SOLCHAR sName Input Schema Name SQLSMALLINT sNameLength Input Length of character string of sName SQLCHAR tName Input Table Name SQLSMALLINT tNameLength Input Length of character string of tName SQLCHAR tableType Input Table type list to compare SQLSMALLINT tableType Input Length of character string of tableType Length SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE 169 ODBC Functions SQLTables SQL ERROR SQLTables displays all table information within the required range Some users may or may not have the SELECT privilege to any of these tables The application must be able to handle a situation where the user selects a table for which SELECT privileges are not granted The following special syntaxes are defined for cName sName Name and tableType of SOLTables to support the catalogs schema and the list of tabl
158. he word NULL not enclosed in quotation marks If the default value can not be represented without truncation this column contains TRUNCATED with no enclosing single quotation marks If no default value was specified this col umn is NULL The value of COLUMN DEF can be used in generating a new column definition except when it contains the value TRUNCATED SQL data type SOL DATETIME SUB SMALLINT The subtype code for datetime and inter val data types For other data types this column returns a NULL CHAR OCTET LENGTH INTEGER Maximum digits of the character string or binary data type string ORDINAL POSITION INTEGER NOT NULL Location of the order of the parameters in the procedure definition starting with 1 IS NULLABLE VARCHAR NO When the string does not contain the NULL YES When the string contain the NULL 135 ODBC Functions SQLProcedureColumns Diagnosis SOLSTATE Description Comments HY000 General error HY009 Invalid Arguments used null pointer CName is a NULL pointer Related Functions SOLBindCol SOLFetch SQLProcedures Example See SALTIBASE_HOME sample SQLCLI demo_meta6 cpp if SQLProcedureColumns stmt NULL O NULL O DEMO META6 PROC SQL NTS NULL 0 SQL SUCCESS execute err dbc stmt SOLProcedureColumns SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindCol stmt 1
159. hen fOption of the second row is SOL DROP SQLGetData SOUnallocated S1Allocated S2Prepared S6Infetch 1H HY010 HYO10 S NF gt SQLGetTypelnfo See SQLColumns SQLNumResultCols SOUnallocated S1Allocated S2Prepared S6Infetch 1H HYO10 S gt Baue SQLPrepare SOUnallocated S1Allocated S2Prepared S6Infetch 1H S gt S gt 24000 E gt S1 SQLPrimaryKeys See SQLColumns ODBC Error Codes Statement State Transition related Errors SQLProcedureColumns See SQLColumns SQLProcedures See SQLColumns SQLSetConnectAttr SOUnallocated S1Allocated S2Prepared S6Infetch 24000 When the set attribute is the connection attribute When the set attribute has the statement attri bute SOLSetStmtAttr will be referred to SQLSetEnvAttr SOUnallocated S1Allocated S2Prepared S6Infetch Error Error Error Error SQLSetStmtAttr SOUnallocated S1Allocated S2Prepared S6Infetch 1H 1 gt 1 gt 2 gt Error 2 gt 24000 1 When Attribute argument is neither SQL_ATTR_CONCURRENCY SQL_ATTR_CURSOR_TYPE SQL_ATTR_SIMULATE_CURSOR SOL ATTR USE BOOKMARKS SOL ATTR CURSOR SCROLLABLE nor SOL ATTR CURSOR SENSITIVITY ODBC User s Manual State Transition Tables 2 When Attribute argumentis either SQL_ATTR_CONCURRENCY SQL_ATTR_CURSOR_TYPE SQL_ATTR_SIMULATE_CURSOR
160. ibeParam Instead the driver does this when a statement is executed strcpy char PtrArray i AAAAAAA BufferLenArray i 7 ODBC Users Manual 122 SQLNumResultCols SQLNumResultCols SQLNumResultCols returns the number of columns in a result set Syntax SOLRETURN SQLNumResultCols SQLHSTMT stmt SQLSMALLINT col Arguments Data Type Argument In Out Description SQLHSTMT stmt Input Statement handle SQLSMALLINT col Output Pointer to save the number of columns in a result set Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SQL ERROR Description If the commands related to stmt do not return columns SOLNumResultCols will set 0 in col This function can be called only after SOLPrepare or SOLExecDirect is called After this function is called SOLDescribeCol SOLColAttribute SOLBindCol or SOLGetData can be called When the command is in ready executed or defined status SOLNumResultCols can be success fully called 123 ODBC Functions SQLNumResultCols Diagnosis SQLSTATE Description Comments 08S01 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error If SQLNumResultCols is called after SQLPrepare and before SQLExecute no SQLSTATE returned by these two functions can
161. indCol stmt SQLBindCol stmt 165 SOL C CHAR szSchema SQL C CHAR szTableName SQL C SSHORT amp NonUnique SOL C CHAR szIndexName SOL C SSHORT amp OrdinalPosition 0 amp cbOrdinalPosition SOL C CHAR szColumnName 0 SQL C CHAR szAscDesc STR LEN amp cbSchema STR LEN amp cbTableName 0 amp cbNonUnique STR LEN amp cbIndexName STR LEN amp cbColumnName 2 amp cbAscDesc ODBC Functions SOLTablePrivileges SQLTablePrivileges SOLTablePrivileges returns a list of tables and the privileges associated with each table The driver returns the information as a result set on the specified statement SQLTablePrivilegesW as a Unicode string supports same execution as SQLTablePrivileges Syntax SOLRETURN SQLTablePrivileges SQLHSTMT stmt SQLCHAR cName SQLSMALLINT cNaneLength SQLCHAR sName SQLSMALLINT sNameLength SQLCHAR tName SQLSMALLINT tNameLength Arguments Data Type Argument In Out Description SQLHSTMT stmt Input Statement handle SQLCHAR cName Input Catalog Name SQLSMALLINT cNameLength Input The character number of cName SOLCHAR sName Input Name of the schema to retrieve SQLSMALLINT sNameLength Input Length of character string of sName SOLCHAR tName Input Table name to retrieve SQLSMALLINT tNameLength Input Length of character string of tName Return Values SQL SUCCESS SOL SUCCESS WITH INFO
162. ing SOL statements and transactions Depending on the features of each function these are groupped by followings Managing Environments and Connections SQL Processing Setting and Retrieving Driver Attributes Meta data processing Managing Environments and Connections The APIs that allocate resources necessary for the connection to the database server and provide connection related features Releases the memory space after disconnected from datasources ODBC Users Manual 2 Open Database Connectivity SOL Processing The APIs that allocate resources and prepare commands for the processing executing and retreiving results of SOL statements Setting and Retrieving Driver Attributes The APIs that set the environment for the processing of the SQL connection status and statement attributes Metadata Processing The APIs that provide features to define tables and columns and to retrieve database metadata 3 ODBC Introduction Using the ODBC Using the ODBC This chapter explains how to develop user application programs using the Altibase ODBC driver Basic Usages The ODBC application program generally consists of following three parts Initializing Handles Transaction Processing Release Handles Besides the above The diagnosis messages is made through the all parts of an application SQLAllocEnv SQLAllocConnect Initializing Handles SOLConnect SQLAllocstrnt Transaction Pro
163. ion statement or descriptor handle Syntax SOLRETURN SQLFreeHandle SOLSMALLINT handleType SOLHANDLE handle Arguments Data Type Argument In Out Description SQLSMALLINT handleType Input Handle type to be freed SQL_HANDLE_ENV SQL_HANDLE_DBC SQL_HANDLE_STMT If the handleType is not the one of these values SQLFreeHandle free SQL_INVALID_HANDLE SQLHANDLE handle Input Handle to be freed Return Values SOL SUCCESS SOL INVALID HANDLE SOL ERROR If SQLFreeHandle returns SQL_ERROR the handle is valid Description SQLFreeHandle can replace with SQLFreeEnv SQLFreeConnect and SQLFreeStmt function Once the handle is released an application cannot use the released handle Freeing an Environment Handle Before handleType calls SOLFreeHandle SOL HANDLE ENV an application must call SQLFreeHan dle of which handleType is SOL HANDLE DBC for all connections allocated in the corresponding 87 ODBC Functions SQLFreeHandle environment Otherwise calling SOLFreeHandle will return SOL_ERROR and the corresponding environment and the random activated connection remains still vaild Freeing a Connection Handle If an error is detected on this handle before handleType calls SOLFreeHandle SOL HANDLE DBC an application must call SOLDisconnect for the connection Otherwise calling of SOLFreeHandle will return SOL ERROR and connection will be still vaild Freeing a
164. ions SQLBindCol Data Type Argument In Out Description SOLINTEGER max Input Maximum size of the buffer in bytes When returning the charac ter data to the Value the Value argument must include space for the NULL terminatior Otherwise the ODBC cuts out the data In case a fixed length data integer date structure etc are returned the ODBC will ignore max There fore a sufficient buffer size must be allocated Otherwise the ODBC passes through the end of the buf fer and saves the garbage data SOLINTEGER valueLength Input Out Is a pointer for the data length or put Sus NULL SOLFetch function be able pended to return the length of data or SOL NULL DATA SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR The pointer value and ValueLength are suspended output variables for this function Thememory address indicated by this pointer will not be updated until SOLFetch is called The position referred to by this pointer must be valid till SOLFetch is called SQLBindCol binds application variables to the columns of the result set for all data types When SQLFetch is called the data will be sent from the databaseMS to an application An application calls SOLBindCol once for each column When SQLFetch is called the data of each bound column is stored in the address allocated by the value or the ValueLength pointer An application can inquire the a
165. is retuned when Altibase5 inserts data as SOL Type into DATE column with using SOLDescribeCol or SQLColAttribute SOL TYPE TIMESTAMP is similar to Altibase DATE type of ODBC standard and consists of year month day hour and second However if you call SOLColAttribute or SQLDescribeCol SQL DATE is returned as SQL type because DATE type in Altibase4 consists of basic elements such as day and hour and much data such as special characters separating basic elements Therefore when you use ODBC of Altibase 5 SOL TYPE DATE SOL TYPE TIME and SQL TYPE TIMESTAMP as constant numbers for ODBC 3 0 are recommended LOB Data Type In Altibase 4 length of LOB type is limited to page size However it consists of BLOB and CLOB sup porting maximum 2GB Altibase 4 DDL CREATE TABLE T1 I1 BLOB 3 Altibase 5 DDL CREATE TABLE T1 I1 BLOB This precision in brackets disappears 251 Upgrade Data Type LOB Function Use CLI application supports private functions to use LOB Refer to LOB Interface of ODBC Users Manual for details about special functions for LOB You can use functions available to general binary and character type except functions for LOB You can store and search LOB data with standard ODBC in ODBC application cause of these features You can t update and retrieve data partially in ODBC application whereas you can in CLI application with SOLGetLob and SQLPutLob CREATE TABLE T1 11 BLOB 12 CLOB CON
166. k the number of record 71 ODBC Functions SQLExecute If SOL ATTR PARAMSET SIZE statement attribute is higher than 1 and the SQL statement has at least one parameter marker SOLExecute will execute an SOL statement once for a series of the parameters in the array indicated by the Value argument upon calling of SOLBindParameter SQLSTATE Description Comments 07006 Restricted data type attribute viola tion The column data within the result set must not be converted to the data type expressed in cType of SQLBind Col 08003 When stmt is not connected or the connection is released 08S01 Communication channel error The communication link between the driver and the database to which the driver was connected failed before the function completed processing HY000 General error HYO9O Invalid string or buffer length If SOLBindParameter and the related parameters are NULL pointers the parameter length is not 0 or SOL NULL DATA If the parameter designated with SQLBindParameter is not the NULL pointer C data type will be SQL C BINARY or SQL C CHAR and the parameter length will be smaller than O SQLExecute can return all SOLSTATE data that are returned by SOLPrepare SQLBindCol SOLEndTran SQLExecDirect SOLFetch SOLFreeStmt SQLGetData ODBC Users Manual 72 SQLPrepare SOLSetStmtAttr Example See SALTIBASE_HOME sa
167. l Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle 01004 Cutted Source Buffer size of OutStstementText is lesser than the size of returned data SQLNativeSql dbc SOLCHAR INSERT INTO T1 VALUES a 1981 09 27 LR SOL NIS outText 100 amp outTextLen INSERT INTO T1 VALUES TO DATE 1981 09 27 YYYY MM DD is saved in outText ODBC Users Manual 120 SQLNumParams SQLNumParams SQLNumParams returns the number of parameters in an SQL statement Syntax SQLRETURN SQLNumParams SOLHSTMT stmt SOLSMALLINT parameterCounterPtr Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLSMALLINT parameter Output Pointer of the number of the parameters CountPtr Return Values SOL SUCCESS Description This function can be called only after SOLPrepare is called If the stmt does not include parameters SOLNumParams will set O in parameterCountPtr Diagnosis SOLSTATE Description Comments HYO0OO General error Related Functions SQLBindParameter SQLDescribeParam 121 ODBC Functions SOT Num barams Example See SALTIBASE_HOME sample SQLCLI demo_info2 cpp SOLPrepare hstmt Statement SQL NTS Check to see if there are any parameters If so process them SQLNumParams hstmt amp NumParams if NumParams Allo
168. lali Handles s Er e ee 4 Processing of Transactions cere EE ANEN ee 5 Release Handle ad 6 Managing Diagnosis Messages ENEE 6 RESECTION v M 6 A a M 7 Using UNIX ODBC versus Using Windows ODBC EENEG 7 Basic Programming Be issseisisssssassisascasssnsasessssssnessonossaiscsdscasiseasvescasscondsoansscaassnacsiseabinscoadsubasanioeaassdsvetoneaioassoab onassanoasasssdbuetinaassabssiais 9 Step 1 Connectingito a Database esie eerte ber Rag tete oe e se etapa eee abes 10 Step 2 Initializing an application Status EENEG 10 Step 3 Executing an SOL statements EEN 10 Step 4a Fetch the Results ce e ree EES 11 Step 4b Fetch the Affected Row Coumt EENEG 11 Step 5 Commit Rollback a Transaction EENEG 12 Step 6 Disconnect from the Altibase Database EENEG 12 Summary of ODBC Functions serene 3 2 ODBC Functions 17 SQLAllocConnect 18 Syntax 18 Arguments Return Values 18 Description we 18 D To le DC 19 Related Functions RR 19 EX TEE 19 SOLAIIGCEUDV ee ez ds 20 A NA 20 gel in En 20 Return Values os 20 Description m 20 Related F rictlons iei NN 20 EX liinda Recta iria iia EAE E st 21 A NN 22 KLL 22 ee UE e serotonina AA AA AA RARA ons E AAA 22 Return Vales ii atasca 22 Bi ted eji o eM 23 D To le DC 24 Related Ne Led EE 24 Ste 24 lee EE 25 uncus RR RA 25 PTU NS
169. le SQLPOINTER data In Pointer of Data Buffer SQLLEN strLength In Data Size Return Value SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description You can use this with SOLParamData when inserting data while running command Diagnosis SOLSTATE Description Comments HY000 General Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle ODBC Users Manual 140 SQLPutData SQLSTATE Description Comments HY010 Continuous Function Error SQLBindParameter SQLExecDirect SOLExecute SQLParamData 141 ODBC Functions SQLRowCount SQLRowCount SQLRowCount returns the number of rows affected by an UPDATE DELETE or INSERT statement Syntax SOLRETURN SQLRowCount SOLHSTMT stmt SOLINTEGER row Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLINTEGER row Output Pointer to save the number of row Return Values SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description If the most recent statement referred to by the input statement handle is not UPDATE DELETE or INSERT statement or if it is not successfully executed this function returns row as 1 However if no row was affected after UPDATE DELETE or INSERT statement or if SELECT statement is submitt
170. le length data in parts SQLGetData will be called for each column and SQLFetch will be called to retrieve one or more rows SOLRETURN SOLHSTMT SOLSMALLINT SOLSMALLINT SOLPOINTERV SOLINTEGERV SOLINTEGER SQLGetData stmt col cType alue alueMax pcbValue Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLSMALLINT col Input Column sequence Starting with 1 SOLSMALLINT cType Input The type identifier of C data type in the Value buffer SOLPOINTER Value Output Pointer of the buffer to return the data SOLINTEGER ODBC Users Manual ValueMax Input 94 Length of Value buffer in bytesWhen returning the character data to the Value the Value argument must include a NULL terminatior Otherwise the ODBC cuts out the data In case of a fixed length data such as integer date structure etc are returned the ODBC will ignore ValueMax Therefore a sufficient buffer size must be allocated Otherwise the ODBC passes through the end of the buffer and saves the data If ValueMaxis smaller than 0 SOLGetData will return SQLSTATE HY090 If the Value is not set as a NULL pointer ValueMax will be ignored by the ODBC SQLGetData Data Type Argument In Out Description SQLINTEGER pcbValue Output Pointer of buffer that will return the length or indicator variablelf
171. les stmt NULL NULL NULL NULL SQL SUCCESS execute err dbc stmt SQLTables SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindCol stmt 2 SOL C CHAR schem sizeof schem amp schem ind SQL SUCCESS execute err dbc stmt SOLBindCol SOLFreeStmt stmt SOL DROP return SQL ERROR SQLBindCol stmt 3 SQL C CHAR name sizeof name amp name ind SOL SUCCESS execute err dbc stmt SOLBindCol SOLFreeStmt stmt SOL DROP return SQL ERROR SQLBindCol stmt 4 SOL C CHAR type sizeof type amp type ind SOL SUCCESS 171 ODBC Functions SOLTables execute err dbc stmt SOLBindCol SOLFreeStmt stmt SOL DROP return SQL ERROR while rc SQLFetch stmt SQL NO DATA rf Te SOL ERROR execute err dbc stmt SOLFetch break printf 40s 40s s n schem name type ODBC Users Manual 172 SQLTransact SQLTransact SQLTransact requests a commit or rollback operation for all active operations on all statements asso ciated with a connection Normally terminates or cancels all changed in the database made after the connection or before calling of SOLTransact If the transaction is in use in the connection status an application must call SOLTransact before disconnecting the database SQLTransact has been replaced by SQLEndTran Syntax SOLRETURN SQLTransact SOLHENV env SOLHDBC dbc S
172. lt See SALTIBASE_HOME sample SQLCLI demo_plan cpp gt if SQLSetConnectAttr dbc ALTIBASE EXPLAIN PLAN SQLPOINTER 1 0 SQL SUCCESS if SQLGetPlan stmt SQLCHAR amp plan SQL SUCCESS ODBC Users Manual 112 SQLGetStmtAttr SQLGetStmtAttr SOLGetStmtAttr retrieves the attributes related to the current statement handle SQLGetStmtAttrW as a Unicode string supports same execution as SOLGetStmtAttr SOLRETURN SQLGetStmtAttr SOLHSTMT stmt SOLINTEGER Attribute SOLPOINTER param SOLINTEGER StringLength SOLINTEGER StringLengthPtr Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLINTEGER Attribute Input Attribute to set Supported attributes SOL ATTR MAX ROWS SOL ATTR ROW ARRAY SIZE SOL ATTR ROW BIND TYPE SOL ATTR ROW STATUS PTR ALTIBASE STMT ATTR ATOMIC ARRAY SOLPOINTER param Output Pointer of the value related to the attrib uteDepending on the Attribute the param will be a 32 bit integer the pointer of the Null terminator the binary pointer or the value defined in the ODBC If Attri bute is the unique value of the ODBC param is the integral number with a sign SOLINTEGER StringLength Input If the Attribute has been defined in the ODBC and if the param indicates the character string or binary buffer this argument must be the length of param If the Attribute is defined in the ODBC and param is an integer this Argumen
173. mber with Server name n printf Port num gets port 205 Sample Codes Sample of Simple Basic Program else strcpy port tmp printf Enter User Name gets uid printf Enter Password Name gets pwd Make connection String for SQLDriverConnect sprintf constr DSN s UID s PWD s CONNTYPE 1 PORT NO s server uid pwd port Connect to Altibase rc SQLDriverConnect hdbc NULL constr SQL NTS NULL 0 SOL DRIVER COMPLETE if re SOL ERROR db error henv hdbc SOL NULL HSTMT printf Connect Error Program terminated SQLFreeConnect hdbc SQLFreeEnv henv exit 0 Now Processing SQL Query re SQLAllocStmt hdbc amp hstmt1 If xc zs SOL ERROR db error henv hdbc SOL NULL HSTMT printf SQLAllocStmt Error n rc SQLDisconnect hdbc ZE fc SOL ERROR SQLFreeConnect hdbc SQLFreeEnv henv exit 0 printf disconnect error n re SQLAllocStmt hdbc amp hstmt2 rf Tesz SOL ERROR db error henv hdbc SOL NULL HSTMT printf SQLAllocStmt Error WMn ZE re SOL ERROR SQLFreeConnect hdbc SOLFreeEnv henv exit 0 printf disconnect error n AUTO COMMIT MODE False SOLSetConnectAttr hdbc SOL ATTR AUTOCOMMIT void SQL AUTOCOMMIT OFF sprintf query CREATE TABLE EMPLOYEE ID VARCHAR 8 primary key NAME VARCHAR 30
174. meLength amp fileOp tions 16 amp ind SQL SUCCESS execute err dbc stmt SQLBindFileToParam SOLFreeStmt stmt SQL DROP return SOL ERROR if SQLExecute stmt SOL SUCCESS execute err dbc stmt SOLExecute SOLFreeStmt stmt SOL DROP return SQL ERROR Input three LOB s to a table SOLINTEGER i1 3 SOLCHAR fileName 3 10 SQLINTEGER fileNameLength 3 SQLUINTEGER fileOptions 3 SOLINTEGER ind 3 if SQLSetStmtAttr stmt SOL ATTR PARAMSET SIZE SQLPOINTER 3 0 SOL SUCCESS execute err dbc stmt SOLSetStmtAttr SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLSetStmtAttr stmt SQL ATTR PARAM BIND TYPE SOL PARAMETER BIND BY COLUMN 0 SQL SUCCESS execute err dbc stmt SOLSetStmtAttr SOLFreeStmt stmt SOL DROP return SQL ERROR strcpy query INSERT INTO Tl VALUES Prepare a statement and bind a file if SQLPrepare stmt query SQL NTS SQL SUCCESS execute err dbc stmt SOLPrepare SOLFreeStmt stmt SQL DROP return SQL ERROR if SQLBindParameter stmt 1 SQL PARAM INPUT SQL C INTEGER SQL INTEGER 0 0 SQLPOINTER il 0 NULL SQL SUCCESS execute err dbc stmt SQLBindParameter SOLFreeStmt stmt SQL DROP return SOL ERROR ODBC Users Manual 186 SQLBindFileToParam if SOLBindFileToParam stmt 2 SOL BLOB SOLCHAR fileName fileName Lengt
175. mp cbColumnName SOLBindCol stmt 5 SOL C SSHORT amp KeySeq 0 amp cbKeySeq SOLBindCol stmt 6 SOL C CHAR szPkName STR LEN amp cbPkName while rc Tf execute err dbc break printf 20s 20s 3d 20s n szColumnName ODBC Users Manual SQLFetch stmt stmt SQL NO DATA rc SQL ERROR SOLPrimaryKeys SQLFetch szTableName KeySeq szPkName 132 SQLProcedureColumns SQLProcedureColumns SQLProcedureColumns returns the list of input and output parameters as well as the columns that make up the result set for the specified procedures The driver returns the information as a result set on the specified statement SQLProcedureColumnsW as a Unicode string supports same execution as SOLProcedureColumns Syntax SOLRETURN SQLProcedureColumns SOLHSTMT stmt SOLCHAR cName SOLSMALLINT cNameLength SOLCHAR sName SOLSMALLINT sNameLength SOLCHAR pName SOLSMALLINT pNameLength SOLCHAR colName SOLSMALLINT colNameLength Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SQLCHAR cName Input Procedure Catalog Name SOLSMALLINT cNameLength Input The character number of cName SOLCHAR sName Input Procedure Schema Name SQLSMALLINT sNameLength Input Length of character string of sName SQLCHAR pName Input Procedure name Cannot be a NULL pointer pName m
176. mple SQLCLI demo_ex2 cpp See the examples of SQLBindParameter 73 SQLExecute ODBC Functions SOL Fetch SQLFetch SQLFetch fetches the next rowset of data from the result set and returns data for all bound col umns The user can separately get columns by directly receiving the data for the variables specified in SQL BindCol using or by calling SOLGetData to fetch In case SQLFetch is called while conversion is set upon binding of the column the data will be converted Syntax SQLRETURN SQLFetch SOLHSTMT stmt Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR SQL NO DATA FOUND Description SQLFetch can be called only when the recently executed command in stmt is a SELECT statement SQLBindCol and the number of binding variables of the application must not exceed the number of columns in the result set Otherwise SOLFetch will fail Positioning the Cursor When the result set is created the cursor is positioned before the start of the result set SOLFetch returns the next row set in the result set The SOL ATTR ROW ARRAY SIZE statement attribute specifies the number of rows in the rowset For example if the number of rows is 5 when the result set has total 100 rows the result row set of initial SOLFetch is from 1 to 5 Also if the result
177. mple of Procedure test Program printf SUCCESS 2 Bind Parameter n if SOLBindParameter stmt 3 SOL PARAM OUTPUT SOL C SLONG SOL INTEGER 0 O 13 4 amp i3 len SQL ERROR printf ERROR 3 Bind Parameter Mn else printf SUCCESS 3 Bind Parameter n for i 0 i lt 10 i linus i2 i 1 printf BEFORE I1 d I2 d 13 d n il 12 i3 if SOL ERROR SOLExecute stmt printf ERROR Execute Procedure else printf SUCCESS Execute Procedure printf AFTER I1 d d I2 d d I3 d d n il il len i2 i2 len i3 i3 Leni for if SOLFreeStmt stmt SOL DROP SQL ERROR if SQL ERROR SQLDisconnect con printf sql free stmt error n printf disconnect error n if SQL ERROR SQLFreeConnect con printf SQLFreeConnect error n if SQL ERROR SQLFreeEnv env printf SQLFreeConnect error n return 0 ODBC User s Manual 220 Appendix B Data Types This appendix describes the data types of Altibase SOL data types C data types and the data con version SOL Data Types To find which data types the Altibase ODBC supports call SOLGetTypelnfo The following table shows the list of the Altibase SOL data types and the standard SOL type identi fier SOL type ALTIBASE data E Comments identifier types SQL_CHAR CHAR n Character string of fi
178. n Value SOL SUCCESS SQL SUCCESS WITH INFO SQL NO DATA SOL INVALID HANDLE SOL ERROR ODBC Users Manual 98 SOLGetDescField This retrieves one column information with descriptor handle SOLSTATE Description Comments HY000 General Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle HY010 Function Sequence Error 01004 Cutted Resource The size of ValuePtr buffer is lesser than the size of returned data 07009 Invalid Descriptor Index The value of recNumber is incorrect SQLGetDescRec SQLSetDescField SQLSetDescRec 99 ODBC Functions SQLGetDescRec SQLGetDescRec This retrieves multiple number of descriptor attributes Unicode SOLGetDescRecW supports same execution as SOLGetDescRec SOLRETURN SQLGetDescRec SOLHDESC desc SOLSMALLINT recNumber SOLCHAR name SOLSMALLINT bufferLength SOLSMALLINT stringLength SOLSMALLINT type SOLSMALLINT subType SOLLEN lengthPtr SOLSMALLINT precision SOLSMALLINT scale SOLSMALLINT nullable Data Type Argument In Out Description SOLHDESC desc In Descriptor Handle SQLSMALLINT recNumber In This starts from 1 of column number SQLCHAR name Out Pointer recieving column name SQLSMALLINT bufferLength In Size of name buffer SQLSMALLINT stringLength Out Size specified in name SQLSMALLINT type Out P
179. n the value buffer to the fromPosition position of target LOB When this happens the data after the fromPosition position in the original target LOB is shifted backward for valueLength If forLength gt 0 and valueLength 0 it deletes the data for for Length from the fromPosition position of target LOB When this happens the data after the fromPo sition forLength position in the original target LOB is shifted forward for forLength If a target locator is not the LOB locator opened during the current transaction it cannot be used as an argument for this function This is because the LOB locator becomes invalid if a transaction is ter minated If a target LOB locator is not valid the SQLPutLob function will return SOL ERROR If a target locator points NULL LOB the SOLPutLob function works in the same way as when a LOB locator points LOB with length 0 The fromPosition argument should not exceed target LOB at the time of calling If it is larger than tar get LOB the SOLPutLob function will return SOL ERROR agnosis SOLSTATE Description Note 08S01 A communication link fault Data A communication link failed before transmission failure function processing is complete between ODBC and DB HY000 A general error ala Function SQLGetLobLength ODBC Users Manual 196 SOLPutLob SOLGetLob Examples It is assumed that a table has been created with the following DDL CREATE TABLE T1 il INTE
180. nated string That is it has the same effect as if SOL NTS were stored in the memory pointed by this argu ment The max length of a filename is 255 characters SOLINTEGER fileOptions Input Pend A pointer to the buffer that holds a file ing option or an array of file options Upon SQLExecute or SOLExecDirect there should a file option stored in this buf fer The following option is available SQL FILE READ SQLINTEGER fileNameBuf Input The length of the filename buffer ferSize SQLLEN Ind Input Pend A pointer to the buffer that holds an indi ing cator variable or an array of indicator vari ables It cannot be NULL It is used to determine if LOB is NULL The following values can be set for the buffer pointed by this pointer 0 SOL NULL DATA SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR SQLBindFileToParam binds a LOB parameter marker to a file SOLBindParameter can be used to bind a parameter marker to an application variable memory buffer For SOLBindFileToParam and SQLBindParameter only the binding by the most recently called bind function is valid Because the values of fileName fileNameLength fileOptions and ind arguments are referred to upon SOLExecute or SOLExecDirect they should be set before SOLExecute or SOLExecDirect is called When SOLExecute or SOLExecDirect is called data is transferred from the file being bound ODBC U
181. ns the current setting of an environ ing driver attri ment attribute butes 3 7 SOLGetFunctions This returns information about whether a driver supports a specific ODBC function SOLSetConnectAttr Sets the connection attributes SOLSetEnvAttr Sets the environment attributes SQLSetStmtAttr Sets the statement attributes Metadata Process SQLColumns Returns the list of column names in specified ing catalog func tions tables SQLForeignKeys Returns a list of column names that make up for eign keys if they exist for a specified table SQLGetDescField This returns a single field of a descriptor record SQLGetDescRec This returns values of mutiple fields of a descrip tor record SQLGetDiagField Diagnose the result after the function is used SQLGetDiagRec This returns several commonly used fields of a diagnostic record after using the function SQLPrimaryKeys Returns the list of column names that make up the primary key for a table SQLProcedureCol Returns the list of input and output parameters umns as well as the columns that make up the result set for the specified procedures SQLProcedures Returns the list of procedure names stored in a specific database SQLSetDescField This sets the descriptor field SQLSpecialColumns Returns information about the optimal set of columns that uniquely identifies a row in a spec ified table or the columns that are automatically update
182. nts In Out Description SQLHDBC dbc Input Connection Handle SQLHSTMT stmt Output Pointer of statement handle Return Values SOL SUCCESS SOL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR In case SOL ERRORis returned stmt arguments will be set as SOL NULL STMT An application must set stmt arguments as SOL NULL STMT and calls SOLERROR Description The ODBC relates the descriptors results and status data with the processed SOL statements by using each statement handle Each SOL statement must have a statement handle but other com mands can use the handles again When this function is called the database connection used by the databasec must be referred to If the input pointer indicates the valid statement handle allocated by the previous calling of SOLAI locStmt the original value will be changed according to the result of this calling As an application programming error it is not detected by ODBC 25 ODBC Functions SQLAIlocStmt Call SQLAIlocEnv before calling this function This function must be called before other functions that have SQL Prepare SOLExecute SOLExecDirect or statement handle as an input Arguments SOLSTATE Description Comments HYO0OO General error The number of stmt 1024 exceeds HY001 Memory allocation error Failed to allocate the memory for the stmt HY009 Invalid Arguments used null pointer stmt is a NULL pointer HY010
183. ointer recieving column type SQLSMALLINT subType Out Pointer recieving subtype of column SQLLEN lengthPtr Out Pointer recieving column length SOLSMALLINT precision Out Pointer recieving column precision SOLSMALLINT scale Out Pointer recieving column scale SOLSMALLINT nullable Out Pointer recieving whether to specify null in column SQL SUCCESS ODBC Users Manual 100 SOL SUCCESS WITH INFO SOL NO DATA SOL INVALID HANDLE SOL ERROR SQLGetDescRec You can retrieve several information of column with descriptor handle SOLSTATE Description Comments HY000 General Error No error occurs explicitly HY001 Memory Allocation Error This denotes to fail to allocate mem ory for handle HY010 Function Sequence Error 01004 Cutted Resource The size of name buffer is lesser than that of retunred data 07009 Invalid Descriptor Index The value of recNumber is incorrect SQLBindCol SQLBindParameter SQLGetDescFiled 101 ODBC Functions SQLGetDiagField SQLGetDiagField SQLGetDiagField is Used to diagnose the result after an ODBC function is used SQLGetDiagFieldW as a Unicode string supports same execution as SOLGetDiagField SOLRETURN SQLGetDiagField SOLSMALLINT HandleType SOLHANDLE Handle SOLSMALLINT RecNumber SOLSMALLINT DiagIdentifier SOLPOINTER DiagInfoPtr SOLSMALLINT BufferLength SOLSMALLINT StringLengthPtr Arguments Data Type Argument
184. olumns SQLDriverConnect SQLDisconnect SQLERROR SQLFreeEnv SQLFetch SQLFreeStmt ak SQLFreeConnect SQLPrimaryKeys kk SQLStatistics SQLTables HR KK RK RR RK RR RR RRR RRR KK RK k k kk k RK include lt stdlib h gt include lt stdio h gt include lt string h gt include lt sqlicli h gt define SOL LEN 1024 define MSG LEN 1024 define TBL NAME LEN 50 define COL LEN 4001 int db error SQLHENV henv SQLHDBC hdbc SQLHSTMT hstmt int db tables SQLHENV henv SQLHDBC hdbc SQLHSTMT hstmt int db primary SOLHENV henv SOLHDBC hdbc SQLHSTMT hstmt int db fields SQLHENV henv SQLHDBC hdbc SQLHSTMT hstmt int db indices SQLHENV henv SOLHDBC hdbc SQLHSTMT hstmt SQLHSTMT hstmt1 int main SQLHENV henv SQLHDBC hdbc SOLHSTMT hstmt SOLCHAR server 20 uid 10 pwd 10 port 5 constr 100 temp 30 tmp SQLRETURN rc char job 10 Get environment handle rc SOLAllocEnv amp henv af Se sz SOL ERROR Get connection handle rc SQLAllocConnect henv amp hdbc rf re Ez SOL ERROR db error henv hdbc SQL NULL HSTMT db error henv hdbc SQL NULL HSTMT 211 Sample of Using Metadata Sample Codes Sample of Using Metadata Get server name port num uid pwd by user printf Enter Server Name amp Port num server port gets
185. on SQLPutData This is used to supply data at statement execu tion time Retriev SQLBindCol Defines the buffer and the data type to receive ing the columns of the result set SQLColAttribute Defines the attributes about the columns of the result set SQLDescribeCol Checks the metadata about one column in the result set SQLDescribeParam Checks information related to the parameter marker in the result set SQLERROR Checks diagnosis messages related to the recently called ODBC function SQLFetch Returns multiple result rows SQLFetchScroll The result set the cursor to the desired direction of progress and get a column to bind SQLGetConnectAttr Returns the properties setting of connection SQLGetData Returns the data of a specified column in the result set SOLGetStmtAttr Returns the attributes related to the current statement handle SQLGetTypelnfo Returns the information about the data type supported by the database SQLNumParams Returns the number of parameters in an SQL statement SQLNumResultCols Returns the number of columns in the result set SQLRowCount Returns the number of rows affected by an insert update or delete request SQLMoreResults Returns whether there is more result ODBC Users Manual 14 Summary of ODBC Functions Task Function Name Purpose Setting and retriev SOLGetEnvAttr This retur
186. ou execute codes above with ODBC CLI in Altibase5 function sequence error occurs in SQLExecute stmt Because stmt performing SQLExecute first indicates to generate result set Therefore ODBC cursor becomes open and state of stmt indicates S5 Refer to MSDN ODBC specifi cation However error occurs in this state cause of no performing SQLExecute If you want to perform SQLExecute again call SQLCloseCursor clearly as follows and then make stmt have S1 or S3 state 255 Upgrade Other Changes SQLExecute stmt SQLFetch stmt SOLCloseCursor stmt SQLExecute stmt SQLBindParameter ColumnSize Argument ColumnSize of SQLBindParameter as the 6th parameter in Altibase 5 is different from that of previ ous one If you insert O into this argument for previous version no problem However if you insert maximum length of data transmitted to server in Altibase 5 its performance has problem because it checks their information whenever executed SQLBindParameter StrLen or IndPtr Argument CLI library in Altibase 4 references data only if they which StrLen or IndPtr argument indicates have variable length However Altibase 5 references the values in the memory StrLen or IndPtr argument indicates whenever performing SOLExecute or SOLExecDirect because Altibase 5 can implement SOLPut Data and SOLParamData Therefore you need special care in perfectly initializing memory the pointer indicates if sending
187. pen CLI or ODBC specification to the highest degree This appendix explains data types newly added or defined and other changes Data Types Other Changes Data Type This section describes data types newly added to Altibase5 You can resolve the problems derived from compiling the existing applications to firmly keep the standard compared to previous version The previous CLI applications have used SOLCHAR and char together However standard oriented SQLCHAR is defined newly as follows typedef unsigned char SQLCHAR typedef signed char SQLSCHAR Therefore errors occur when you compile the existing applications with the following statements char query SOLPrepare stmt query SOL NTS You have only to modify type casting as follows to solve this problem char query SOLPrepare stmt SOLCHAR query SOL NTS Subsequent releases starting with version 5 support BIT type as standard SQL92 and VARBIT type for your convenience Refer to SQL User s Manual for details about them 243 Upgrade Data Type The following indicates conversion table related to BIT C type id Test TargetValuePtr StrLen_or_IndPtr SOLSTATE SQL C CHAR BufferLength gt 1 Data 0 or 1 1 n a BufferLength lt 1 Undefined Undefined 22003 SQL_C_STINYINT None The values of Data 0 or 1 Size of C type n a SOL C UTINYINT BufferLength have SQL_C_SBIGINT
188. put Statement handle SOLSMALLINT type Input SQL data type Return Values SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description SQLGetTypelnfo converts data type information that Altibase provides into the standard result set type The current result set is sorted by TYPE NAME in ascending orders to be returned Diagnosis SOLSTATE Description Comments 08501 Communication channel error Communication channel failure before the function processing between the ODBC and the database is completed 115 ODBC Functions SQLGetTypelnfo SQLSTATE Description Comments HY000 General error HY001 Memory allocation error Cannot allocate the requested memory for the ODBC to execute the function and com plete execution Related Functions SQLBindCol SQLColAttribute SOLFetch Example See SALTIBASE_HOME sample SQLCLI demo_info1 cpp if SQLGetTypeInfo stmt SOL ALL TYPES SOL SUCCESS execute err dbc stmt SOLGetTypeInfo SOLFreeStmt stmt SOL DROP return SQL ERROR while rc SQLFetch stmt SQL NO DATA if rc SOL ERROR execute err dbc stmt SOLGetTypeInfo SQLFetch break SOLGetData stmt 1 SQL C CHAR szTypeName STR LEN amp cbTypeName SOLGetData stmt 2 SOL C SSHORT amp DataType 0 amp cbDataType SOLGetData stmt 3 SOL C SLONG amp ColumnSize 0 amp cbColumnSize
189. res that the ODBC driver supports There are total three conformance levels To meet the specific confor mance level all the corresponding reguirements for such level should be met The following table shows the conformance level in compliance with ODBC 3 x which is different from ODBC 2 x conformance level Conformance level 1 in compliance with ODBC2 x can be consid ered as the core conformance Altibase ODBC is implemented in compliance with ODBC 2 x so that it can be considered as the core in the following table However it may not support functions of ODBC 3 0 specification Function Name Level pps EE Remarks SQLAllocHandle Core O SOLBindCol Core O SQLBindParameter Core O SOLBrowseConnect Level1 X X SOLBulkOperations Level1 X X SOLCancel Core X O SQLCloseCursor Core O SOLColAttribute Core O SQLColumnPrivileges Level2 X X Privileges about the col umn are not supported by Altibase SQLColumns Core SQLConnect Core O 239 ODBC Conformance Levels Interface Conformance Levels Function Name Level D a Remarks QLCopyDesc Core X O SQLDescribeCol Core O SQLDescribeParam Level2 O Not fully supported SQLDisconnect Core O SQLDriverConnect Core O SQLEndTran Core O SQLExecDirect Core O SQLExecute Core O SQLFetch Core O SQLFetchScroll Core O SQLForeignKeys Lev
190. returns the number of columns in the result set SQLColumns returns the results in the standard result set format sorted by TABLE CAT TABLE_SCHEM TABLE_NAME and ORDINAL_POSITION Some of columns returned by SOL Statistics are not returned by SOLColumns For example SQL Columns does not return index columns created by expressions such as Salary Benefits or DEPT 0012 and the filter The following table lists the columns of the result sets Name No Data Type Description TABLE_CAT VARCHAR Always return NULL TABLE_SCHEM VARCHAR Schema name NULL in case not suitable for the database TABLE_NAME VARCHAR Table Name NOT NULL COLUMN_NAME VARCHAR Column Name As for the unnamed string NOT NULL the ODBC driver returns the empty char acter string DATA_TYPE SMALLINT SQL data type NOT NULL TYPE_NAME VARCHAR Character string representing the name NOT NULL of the data type corresponding to DATA_TYPE COLUMN_SIZE INTEGER String Size NULL will be returned when the string size is not proper BUFFER_LENGTH INTEGER The maximum buffer length to store the data DECIMAL_DIGITS SMALLINT NULL will be returned when the data type cannot apply the decimal points of the string and the decimal points 47 ODBC Functions SOL Columns Name No Data Type Description NUM PREC RAD 10 SMALLINT In case of the numeric data type it is 10 IX For COLUMN_SIZE and DECIMAL_DIGIT
191. rguments Data Type Argument In Out Description SOLHDBC dbc Input Connection Handle SOLINTEGER Attribute Input Attribute to retrieve SQLPOINTER ValuePtr Output Memory pointer to bring the value corre sponding to the attribute SQLINTEGER BufferLength Input If ValuePtr is the pointer of character string this has the byte length of string or the value of SOL NTS If ValuePtr is the pointer of binary buffer its value is the binary length of data lt ValuePtr is the pointer with fixed length data type like integer its value is ignored SQLINTEGER StringLength Output This returns bytes excluding the null ter Ptr mination characater available to return in ValuePtr Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR 91 ODBC Functions SQLGetConnectAttr In case the attribute returns the string ValuePtr will be a pointer indicating the string buffer The maximum length of the returned string including the NULL terminatior will be the BufferLength bytes Depending on the attribute an application must establish connections before calling SQLGetCon nectAttr Attribute Contents SQL_ATTR_AUTOCOMMIT 32 bit value to set reflection for the connec tion SQL_AUTOCOMMIT_ON Each SQL statement is automatically committed SOL_AUTOCOMMIT_OFF Not automatically committed SQL_ATTR_CONNECTION_TIMEOUT Set timeout value to prevent blocking that may occur in select or poll in an unstable
192. riables indicated by starting with 1 SOL PARAM INOUT Indicates in out and inout SOL C CHAR c type of the variable to bind SOL CHAR Data type of the corresponding column in the database char 8 8 0 precision of the column type upon creation of the table Scale of the column type upon creation of the table id Pointer of the buffer to be bound sizeof id Size of the buffer to be bound amp id ind indicator if 1 SOL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindParameter stmt 2 SOL PARAM INOUT SQL C CHAR SQL VARCHAR 20 varchar 20 0 name sizeof name amp name ind SOL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindParameter stmt 3 SOL PARAM INOUT SOL C SLONG SQL INTEGER 0 0 amp age 0 Not used when the buffer to be bound is the fixed size type NULL SOL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindParameter stmt 4 SOL PARAM INOUT SQL C TYPE TIMESTAMP SQL DATE 0 0 amp birth 0 NULL SOL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SOL DROP return SQL ERROR SOLBindParameter stmt 5 SOL PARAM INOUT SOL C SSHORT SOL SMALLINT 0 0 amp sex 0 NULL SQL SUCCESS execute err dbc stmt query S
193. ror henv hdbc hstmt 215 amp len Sample Codes Sample of Using Metadata return SOL ERROR if SOL ERROR SOLBindCol hstmt 17 SOL C SLONG order 0 amp len printf SQLBindCol error gt 8 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 18 SOL C CHAR is nullable 5 amp len printf SQLBindCol error gt 13 db error henv hdbc hstmt return SQL ERROR printf Table s n table while SQLFetch hstmt SOL SUCCESS printf Column Name s n column name printf Type s n type name printf Size 1dWMn column size printf Scale d n scale printf Precision d n precision printf Default Value s n default val printf Order ld n order printf NULLable s n is nullable return SQL SUCCESS int db indices SQLHENV henv SOLHDBC hdbc SQLHSTMT hstmt SOLCHAR table TBL NAME LEN column name COL LEN index name TBL NAME LEN SOLINTEGER len SOLSMALLINT nonunique indextype indexno printf Type Table Name gets table 1f SOL ERROR SQLStatistics hstmt NULL 0 NULL O table SQL NTS SOL INDEX ALL 0 SQL INDEX UNIQUE printf SQLExecute SQLExecDirect In db error henv hdbc hstmt return SQL ERROR if SQL ERROR SOLBindCol hstmt 4 SOL C SSHORT amp nonunique 0 amp len print
194. rr dbc SQLFreeStmt stmt return SOL ERROR stmt SQLFreeLob SOL DROP SQLPutLob js Insert a record with the CLOB column value being Ver 0 9a SOLCHAR buf 8 SOLINTEGER lobInd SOLUBIGINT lobLoc strcpy query INSERT INTO T1 VALUES 5 l if SQLPrepare stmt query SOL NTS execute_err dbc stmt SQLPrepare SQLFreeStmt stmt SOL DROP return SOL ERROR if SQLBindParameter stmt 1 SOL PARAM OUTPUT SQL SUCCESS vs SQL C CLOB LOCATOR SOL CLOB LOCATOR 0 0 amp lobLoc 0 amp lobInd SQL SUCCESS execute err dbc stmt SOLBindParameter Ue SOLFreeStmt stmt SQL DROP return SOL ERROR if SQLExecute stmt SOL SUCCESS execute err dbc stmt SOLExecute ka fi SOLFreeStmt stmt SOL DROP return SOL ERROR memcpy buf Ver 0 9a 8 if SQLPutLob stmt SOL SUCCESS execute err dbc stmt SOLPutLob SOLFreeStmt stmt SOL DROP return SQL ERROR In Ver 0 9a replace 0 9 with memcpy buf 1 1 if SQLPutLob stmt SOL SUCCESS SQL C CLOB LOCATOR bai SQL C CLOB LOCATOR lobLoc 0 0 SOL C CHAR buf 7 yas lobLoc 4 3 SQL C CHAR buf 1 ys s execute err dbc stmt SOLPutLob SOLFreeStmt stmt SOL DROP return SQL ERROR if SOLFreeLob stmt lobLoc SQL SUCCESS execute err dbc stmt SOLFreeLob SOLFreeStmt stmt SOL DROP 199 LOB Interface SOLPutLob return SOL ERROR
195. s SQLPrimaryKeys returns the column names that make up the primary key for a table The driver returns the information as a result set This function does not support returning primary keys from multiple tables in a single call SQLPrimarykeysW as a Unicode string supports same execution as SOLPrimarykey Syntax SOLRETURN SQLPrimaryKeys SOLHSTMT stmt SOLCHAR cName SOLSMALLINT cNameLength SOLCHAR sName SOLSMALLINT sNameLength SOLCHAR tName SOLSMALLINT tNameLength Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SQLCHAR cName Input Catalog Name SOLSMALLINT cNameLength Input The character number of cName SOLCHAR sName Input Schema Name SQLSMALLINT sNameLength Input Length of character string of sName SQLCHAR tName Input The table name Cannot be a NULL pointer tName cannot contain a string search pattern SQLSMALLINT tNameLength Input Length of character tName Return Values SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR ODBC Users Manual 130 SQLPrimaryKeys SQLPrimaryKeys returns the results in the format of standard result set which is sorted in order byTABLE CAT TABLE_SCHEM TABLE NAME and KEY SEQ The search type cannot be used to define the schema defining arguments or the table name In many cases calling of SOLPrimaryKeys is mapped on the search that is complex and cost
196. s of 00 to 61 SOL TYPE TIMES DATE Year month day hour minute and second fields with TAMP valid values as defined for the DATE and TIME data types SOL INTERVAL The result type of the DATE DATE SQL BYTES BYTE n Binary data type with the fixed length as long as the specified size 1 byte lt n lt 32000 bytes SOL NIBBLE NIBBLE n Binary data type with the fixed length as long as the changeable size n 1 byte lt n lt 255 bytes SOL_GEOMETRY GEOMETRY See Altibase Spatial Temporary SOL document C Data Types C data types refer to the data type of C buffer used to store the data in an application C data type is specified with the type argument in SOLBindCol and SOLGetData and in SOLBind Parameter with cType The following table is the list of valid type identifiers for C data type Also the table lists the defini tions of C data type of the ODBC and the data types corresponding to each identifier C Type Identifier ODBC C typedef Ctype SQL C CHAR SOLCHAR unsigned char SQL C BIT SQLCHAR unsigned char SQL_C_WCHAR SQLWCHAR short SQL_C_STINYINT SQLSCHAR signed char SQL_C_UTINYINT SOLCHAR unsigned char SOL C SBIGINT SOLBIGINT _int64 SQL_C_UBIGINT SQLUBIGINT unsigned _int64 SQL_C_SSHORT SQLSMALLINT short int SQL_C_USHORT SQLUSMALLINT unsigned short int SQL_C_SLONG SQLINTEGER int SQL_C_ULONG SQLUINTEGER unsigned int ODBC User s Manual 222
197. scription SQLHDBC dbc Input Connection Handle Pointer Return Values SQL SUCCESS SOL INVALID HANDLE SOL ERROR Description When this function is called in the connected status SOL_ERROR will be returned but the connec tion handle is still valid Related Functions SQLDisconnect SOLFreeEnv Example See SALTIBASE_HOME sample SQLCLI demo_ex1 cpp gt if conn flag 1 SQLDisconnect dbc ODBC Users Manual 84 SQLFreeConnect if dbc NULL SOLFreeConnect dbc if env NULL SOLFreeEnv env 85 ODBC Functions SQLFreeEnv SOLFreeEnv SQLFreeEnv frees resources associated with a specific environment SOLFreeEnv has been replaced by SQLFreeHandle Syntax SQLRETURN SQLFreeEnv SQLHENV env Arguments Data Type Argument In Out Description SQLHENV env Input Environment Handle Return Values SQL SUCCESS SQL INVALID HANDLE SOL ERROR Description In case this function is called in a valid connection handle SOL_ERROR will be returned but the envi ronment handle is still valid SOLFreeConnect must be called before this function Related Functions SQLFreeConnect Example See SALTIBASE_HOME sample SQLCLI demo_ex1 cpp gt SQLFreeConnect gt See example of SQLFreeConnect ODBC Users Manual 86 SQLFreeHandle SQLFreeHandle SQLFreeHandle frees resources associated with a specific environment connect
198. sers Manual 184 SQLBindFileToParam to DBMS If LOB is NULL the buffer pointed by the ind pointer should be set to SOL NULL DATA and then SQLExecute or SOLExecDirect should be called If LOB is not NULL the buffer pointed by the ind pointer should be set to 0 The ind argument cannot be a NULL pointer To bind an array of files to a parameter marker all of the fileName fileNameLength fileOptions and ind arguments should be arrays SOLSTATE Description Note 08S01 A communication link fault Data A communication link failed before transmission failure function processing is complete between ODBC and DB HY000 A general error ions SOLBindCol SOLBindFileToCol SOLExecute SQLExecDirect SQLDescribeParam Evamnlac Examples It is assumed that a table has been created with the following DDL CREATE TABLE T1 il INTEGER PRIMARY KEY i2 BLOB Input one LOB to a table SOLCHAR fileName 16 SOLINTEGER fileNameLength 15 SQLUINTEGER fileOptions SOL FILE READ SOLINTEGER ind 0 strcpy query INSERT INTO T1 VALUES 1 Prepare a statement and bind a file if SOLPrepare stmt query SQL NTS SQL SUCCESS 185 LOB Interface SQLBindFileToParam execute err dbc stmt SOLPrepare SOLFreeStmt stmt SOL DROP return SQL ERROR strcpy fileName Terminator2 avi if SQLBindFileToParam stmt 1 SQL BLOB fileName amp fileNa
199. specified as greater than 1 odbc defaultbinmode 0 You must specify this as 0 for using LOB because this can be executed without allocating additional memory odbc ini is as follows Altibase ODBC User s Manual 252 Data Type Driver AltibaseODBCDriver Description Altibase DSN ServerType Altibase UserName SYS Password MANAGER Server i27 0 0 17 Port 20073 LongDataCompat on NLS USE US7ASCII php program Connection Godbc connect Altibase SYS MANAGER if Connection echo ConnectFail n exit Godbc exec Connection DROP TABLE T2 if G0dbc exec Connection CREATE TABLE T2 I1 INTEGER B2 BLOB C3 CLOB TABLESPACE SYS TBS DATA echo create test table Fail n exit query INSERT INTO T2 VALUES SResult1 Godbc prepare Connection query if SResult1 msg odbc errormsg Connection echo prepare insert msg Wn exit for Si 0 i lt 10 i 253 Upgrade Data Type fileno2 i 1 Sfilename2 aSfileno2 txt print filename filename2 n Sfp fopen filename2 r blob fread fp 1000000 fclose fp Sfileno3 10 Si Sfilename3 aSfileno3 txt print filename filename3 n Sfp fopen filename3 r clob fread fp 1000000 fclose fp SResult2 odbc_execute Result1 array i blob clob print inserting i filename2 and fil
200. sscssescscssessscssescssseeses 203 Programing Bolo 3 o 37 Mo Tuch EEGENEN 203 Muted O MM Mec MM p D tM Ma 203 Statement Handles RR Re RP er ones 203 Binding Parameters aa ce ERR ERRORI REI ERR ARR PG REN 203 Transaction Commit Mode EEN 204 Using SQLFreeStMtO TURCON is 204 Sample of Simple Basic Program use aii 204 Sample of Using Metadata nas 210 Example of Procedure test Program EEN 217 AppendixB Data Tvpes ARR 221 SOL Data KE 221 EECHER 222 Converting SOL Data into C Data Tvpes ENEE 223 Converting C Data into SOL Data types EEN 224 AppendixC ODBC Error Codes eere eerte eere ette etta eet tos eaa sense ease tease ean ease eaae eaae e ease aeos eae ense ense tease ene e eoa eeS 227 ODBC Error Codes t c ec er e e e E o e PA e ER A Cite e re E o Re E ERAN 227 Database Connection related Error Codes EENEG 229 Network related Error Codes Statement State Transition related Errors EENEG 230 SOLA di ID S 232 SOUBINdCO Mirian ia dad da 232 SOEBindPararmieter EENS EAEE ETIE EASE EE a ee en Pe OD Bebe T HER ONT Ate Le Ee Coe uae 232 SOL Columns SOLGetTypelnfo SOLPrimaryKeys SOLProcedureColumns SOLProcedures SQLStatistics SO Td did 232 SOLConnect 233 SQLDisconnect 233 See SQLDriverConnect SQLConnect 233 SOU ds 233 SU ia 234 SOl Fetcher CN PD O 234 A E aa 234 SOLFreeStmt 234 SOLGetData 235 SOLGetTypelnfo See SOLColumns 235 S
201. sult values of Select strcpy fileName 0 Cube avi strcpy fileName 1 Movie avi strcpy fileName 2 Term avi for i 0 i c 3 i fileNameLength i strlen fileName i fileOptions i SQL FILE CREATE 181 LOB Interface SQLBindFileToCol if SQLBindFileToCol stmt 1 SQLCHAR fileName fileNameLength fileOp tions 10 valueLength SQL SUCCESS execute err dbc stmt SQLBindFileToCol Ny SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLFetch stmt SOL SUCCESS printf SQLFetch success n else execute err dbc stmt SOLFetch SL Write n LOBS to a file SOLCHAR fileName 11 SOLINTEGER fileNameLength 10 SOLUINTEGER fileOptions SOL FILE OVERWRITE SOLINTEGER valueLength strcpy query SELECT i2 FROM T1 if SQLExecDirect stmt query SQL NTS SQL SUCCESS execute err dbc stmt SOLExecDirect Datz SOLFreeStmt stmt SOL DROP return SQL ERROR if SQLBindFileToCol stmt 1 fileName amp fileNameLength amp fileOptions 11 amp valueLength SQL SUCCESS execute err dbc stmt SQLBindFileToCol vw SOLFreeStmt stmt SQL DROP return SQL ERROR for i 0 i sprintf fileName Term 02d avi i 1 rc SQLFetch stmt if xc SOL SUCCESS printf SQLFetch of file 02 success im i 1 else if rc SQL NO DATA break else execute err dbc break ODBC Users Manual stmt SQLFetch 182 SOLBindFileToParam
202. t 4 db error henv hdbc hstmt return SQL ERROR printf 25s t 15s n TABLE name type name while SOLFetch hstmt SOL SUCCESS printf 25s t 15s n TABLE name type name return SQL SUCCESS int db primary SOLHENV henv SOLHDBC hdbc SOLHSTMT hstmt SOLCHAR table TBL NAME LEN column name COL LEN type name TBL NAME LEN SOLINTEGER order len printf Type Table Name gets table if SOL ERROR SQLPrimaryKeys hstmt NULL 0 NULL O table SOL NTS printf error SQLPrimaryKeys Mn db error henv hdbc hstmt1 return SQL ERROR if SOL ERROR SOLBindCol hstmt 4 SOL C CHAR column name COL LEN amp len printf SQLBindCol error gt 4 db error henv hdbc hstmt return SQL ERROR 1f SOL ERROR SQLBindCol hstmt 5 SOL C SLONG amp order 0 amp len printf SQLBindCol error gt 5 db error henv hdbc hstmt return SQL ERROR if SOL ERROR SOLBindCol hstmt 6 SOL C CHAR type name TBL NAME LEN amp len printf SQLBindCol error 6 db error henv hdbc hstmt return SQL ERROR printf Table s n table while SQLFetch hstmt SOL SUCCESS printf Column Name s n column name printf Type s n type name printf Order ld n order ODBC User s Manual 214 Sample of Using Metadata return SOL SUCCESS int db fields SQLHENV henv SQLHDBC hdbc
203. t apply any returned data to this result string NUM RESULT SETS N A Reserved for future use An application must not apply any returned data to this string REMARKS VARCHAR Procedure description PROCEDURE TYPE SMALLINT Definition of the procedure typeSQL PT UNKNOWN It cannot be determined whether the procedure returns a value SQL PT PROCEDURE The returned object is a procedure that is it does not have a return value SQL PT FUNCTION The returned object is a function that is it has a return value ODBC Users Manual 138 SQLProcedures SOLSTATE Description Comments 08501 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error HY009 Invalid Arguments used null pointer CName is a NULL pointer sNme pName are NULL pointer SQLBindCol SOLFetch SOLProcedureColumns See SALTIBASE_HOME sample SQLCLI demo_meta5 cpp if SQLProcedures stmt NULL 0 NULL 0 NULL 0 SQL SUCCESS execute err dbc stmt SOLProcedures SOLFreeStmt stmt SOL DROP return SQL ERROR 139 ODBC Functions SQLPutData SQLPutData You can use this when inserting data while running command Syntax SOLRETURN SQLPutData SOLHSTMT stmt SOLPOINTER data SOLLEN strLength Argument Data Type Argument In Out Description SOLHSTMT stmt In Command Hand
204. te el tee e esit eet tee eret ee esc eer 148 SGLSGtEFIVAELE RNA 149 c 149 le len 149 Return Vales EE 149 Description p t s 149 DN GC 150 Related EUNCtiONS vacia SEENEN 150 KRIER un E 151 np M 151 te UE e 151 Return Valt es 4 e ER Eed 153 DieeerEIE re DITE o le cipe ra RTT Example SQLSpecialColumns SYNTAX Arguments Return Values Description Diagnosis Related Eupectiong TS RN 160 EEI O Sz na OO LOA IR eae verd 160 E ERN 162 UE 162 e len 162 A ee e e ese ee eet esee ets 162 NS RN 163 BIEN Ile DC 164 Related ENCON ec e 165 iS oo NEED 165 SOLTablePrivileges stitit iater ii inicias 166 A E 166 ALUMNES sani nnna A RAA aiaa TA AA E AAS 166 Return Values bis 166 Description uch 167 Ne ue DEEN 168 Related A ee e ied esit eee er e ese eee ns 168 Su 168 K EE 169 EK 169 leie VE 169 RUI E MUS ee 169 Deen aia 170 Dia NOS tii iia 171 RET at ENCINAS iia aiii 171 acu 171 UA peD MS 173 SUE EE 173 e Ui EC 173 Return Val s geseet Occ 173 DescriptiOTi AE 173 STT 174 AAA RID EN 175 LOB Data TY c 176 FUNCION ee 177 A A OS 178 te UE CR 178 Res lt Val thes AO 17
205. temp tmp strtok temp if tmp NULL printf You must specify Server name n SOLFreeConnect hdbc SQLFreeEnv henv exit 0 strcpy server tmp tmp strtok NULL if tmp NULL printf You don t specify Port Number with Server name n printf Port num gets port else strcpy port tmp printf Enter User Name gets uid printf Enter Password Name gets pwd Make connection String for SQLDriverConnect sprintf constr DSN s UID s PWD s CONN TYPE 1 NLS USE US7ASCII PORT_NO s server uid pwd port Connect to Altibase re SQLDriverConnect hdbc NULL constr SOL NTS NULL 0 NULL SQL DRIVER _NOPROMPT if rc SQL ERROR Now Using Metadata db error henv hdbc SQL NULL HSTMT Get Statment handle rc SQLAllocStmt hdbc amp hstmt ifo re e SOL ERROR db error henv hdbc SOL NULL HSTMT printf SQLAllocStmt Error n rc SQLDisconnect hdbc if Lg SOL ERROR printf disconnect error n SQLFreeConnect hdbc SOLFreeEnv henv exit 0 ODBC User s Manual 212 Sample of Using Metadata while 1 printf Select Job t tables f fields p primary key i indices q exit gets job 0 fflush stdin switch job case p db primary henv hdbc hstmt break case t db tables henv hdbc hstmt break c
206. ter SOLExecute or SOLExecDirect The ODBC data type will be inspected when the command is executed in case not all parameters 127 ODBC Functions SQLPrepare are bound For maximum inter operation an application must unbound all parameters applied to the previous SQL statement before the same command prepares a new SOL statement This pre vents errors that occur due to pervious parameters applied to new information SOLSTATE Description Comments 08003 When stmt is not connected or the con nection is released 08501 Communication channel error Communication channel failure before the function processing is completed between the ODBC and the database HY000 General error HY001 Memory allocation error Cannot allocate the requested memory for the ODBC to execute the function and complete execution HY009 Use an invalid pointer null pointer sql is a NULL pointer SOLAllocHandle SOLBindCol SQLBindParameter SQLEndTran SQLExecDirect SOLExecute SQLRowCount See SALTIBASE HOME sample SQLCLI demo ex2 cpp sprintf query INSERT INTO DEMO EX2 VALUES 2 Prepare for a statement and bind the variable if SQLPrepare stmt query SQL NTS execute err dbc stmt query SOLFreeStmt stmt SOL DROP ODBC Users Manual 128 SOL SUCCESS SQLPrepare return SQL ERROR 129 ODBC Functions SQLPrimaryKeys SQLPrimaryKey
207. the returned data NOT NULL SQL_TABLE_STAT Indicates whether the sta tistical data for the table are displayed SQL_INDEX_BTREE Indicates B Tree index SQL_INDEX_HASHED Indicates the hashed index SOL INDEX OTHER Indicates other index types T Tree ORDINAL_POSITION SMALLINT Position of the columns in order in the index Starting with 1 NULL data will be returned when the TYPE is SQL_TABLE_STAT 163 ODBC Functions SQLStatistics Column Name No Data Type Description COLUMN_NAME VARCHAR Column name If the column is expression e g SALARY BENEFITS the expression will be returned If the expression cannot be determined the empty character string will be returned Null data will be returned when the TYPE is SQL_TABLE_STAT ASC_OR_DESC CHAR 1 Column sorting order A In ascending orders D In descending orders If the database does not support the sorting orders and the TYPE is SQL_TABLE_STAT NULL data will be returned CARDINALITY INTEGER Table or index order When the TYPE is SQL_TABLE_STAT the row number will be returned If the TYPE is not SQL_TABLE_STAT the unique number of the index will be returned If the database does not support the TYPE NULL data will be returned PAGES INTEGER Page number used to store data in the index or table If the TYPE is SQL_TABLE_STAT this column will include the number of pages used to define the tabl
208. this row What an idiot unsigned char 6666666666666 SQLPutData test is well under way unsigned char 7777777777777 The length of this line is well over 50 characters unsigned char 8888888888888 Hehehe unsigned char 9999999999999 Can you see this SOLLEN i2ind SQLINTEGER i SQLINTEGER sMarker 0 ilind SQL DATA AT EXEC i2ind SQL DATA AT EXEC sRetCode SQLAllocHandle SQL HANDLE STMT gHdbc amp sStmt check error SQL HANDLE DBC gHdbc STMT handle allocation sRetCode sRetCode SQLBindParameter sStmt 1 SQL PARAM INPUT SOL C SLONG SQL INTEGER 0 0 SQLPOINTER 1 0 amp ilind sRetCode SQLBindParameter sStmt 2 SQL PARAM INPUT SQL C CHAR SQL CHAR 60 0 SOLPOINTER 2 0 amp i2ind sRetCode SQLPrepare sStmt SOLCHAR insert into t2 char values SOL NTS for i 0 i lt 10 i il i 1000 printf An printf gt gt gt gt gt gt gt gt row d inserting d s n i il 12 1 sRetCode SQLExecute sStmt if sRetCode SQL NEED DATA sRetCode SQLParamData sStmt void amp sMarker while sRetCode SOL NEED DATA printf SQLParamData gave dWMn sMarker if sMarker 1 sRetCode SQLPutData sStmt amp il 0 else if sMarker 2 int unitsize 20 int size int pos int len 257 Upgrade Other Changes len strlen char i2 i for pos
209. this variable is a NULL pointer no length or indicator will be returned When the fetched data is NULL this variable will return the error SQL_SUCCESS_WITH_INFO SQLGetData will return the following to the length indicator buffer SQL_NULL_DATA alues SQL SUCCESS SQL SUCCESS WITH INFO SQL NO DATA FOUND SOL ERROR SOL INVALID HANDLE SQLGetData returns the data of a specified column SOLGetData can be called only after one or more rows are fetched by SQLFetch Although there are some exceptions the user can bind a sev eral columns in the row and call SOLGetData for the other columns This function returns only the data of unbound columnsWhen SQLGetData is called the col value must be higher than or the equal to previously called column In other words the data must be searched in ascending order To return the data to a specified column SQLGetData must execute the following series of proce dures Returns SOL NO DATA if it has already returned all of the data for the column If the data is NULL SOL NULL DATA will be set in pcbValue If the data for the corresponding column is not NULL SOLGetData will proceed to the next phase If the data is converted into flexible data types such as character type or binary type SOLGetData will check whether the data length exceeds ValueMax If the length of the data including NULL ter minatior exceeds ValueMax SOLGetData will cut t
210. tion SOLHSTMT stmt Input A handle for the found results SQLSMALLINT locatorCType Input The C data type of a target LOB locator SQL_C_BLOB_LOCATOR SQL_C_CLOB_LOCATOR SQLUBIGINT targetLocator Input A target LOB locator SOLLEN fromPosition Input The start point to update data in LOB byte It begins at 1 SOLLEN forLength Input The length of a segment in LOB to be updated byte SOLSMALLINT sourceCType Input The C data type identifier of the value buffer SOL C BINARY for BLOB SOL C CHAR for CLOB SOLPOINTER value Input A pointer to the buffer that holds data SOLLEN valueLength Input The length of a buffer that holds data byte It should be set with 0 or a larger value It cannot be set with SOL NULL DATA If the value is O the data for forLength from fromPosition in a target LOB is deleted 0 does not mean SOL NTS 195 LOB Interface SOLPutLob SOL SUCCESS SOL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Inserts or updates data stored in an application data buffer to the LOB pointed by a target LOB loca tor It can also delete a part or all of the data in the LOB pointed a target LOB locator It replaces the data for forLength from fromPosition with the data for valueLength in the value buf fer If forLength gt valueLength the length of target LOB decreases and if forLength c valueLength the length increases If forLength 0 and valueLength gt 0 it inserts data i
211. tion commit mode is in non auto commit mode If the transaction commit mode is auto commit the transaction will be automatically reflected immedi ately when an SQL statements are successfully executed To execute an SQL statement in the new transaction an application shoult to return to Step 3 An application goes to Step 6 to disconnect from the database Step 6 Disconnect from the Altibase Database STEP 6 DISCONNECT SQLFreeHandle SQLDisconnect SQLFreeConnect SQLFreeEnv In the final step an application disconnects from the database An application calls SQLFreeHandle and release the handles and resources Then an application disconnects from the database by using SOLDisconnect and returns the con nection handle by using SQLFreeConnect Lastly an application returns the environment handle by using SQLFreeEnv and ends the program ODBC Users Manual 12 Task Summary of ODBC Functions Function Name Summary of ODBC Functions Purpose Managing environ ments and connec tions SOLAllocConnect Obtains an environment connection statement or descriptor handle SOLAllocEnv Allocates an environment connection state ment or descriptor handle SQLAllocStmt Obtains statement handles and Allocates mem ory SOLAllocHandle Initializes of resources environments and state ment handles and allocates memory SQLCloseCursor This closes
212. tion state must be connected connection S1 Allocated statement S2 Prepared statement A possibly empty result set will be created S6 Cursor positioned with SOLFetch The entry values in the conversion table are as follows ODBC User s Manual 230 Statement State Transition related Errors When the status is not converted after the function is executed Sn When the command status is converted into a specified status IH Invalid Handle HY010 Function sequence error 24000 Invalid Cursor State Note S Success In this case the function returns one of the following values SOL SUCCESS WITH INFO or SOL SUCCESS E Error In this case the function returns SOL ERROR R Results There is result set when Result command is executed There is possibility that the result set is empty set NR No Results No result set when the command is executed NF No Data Found The function returns SOL NO DATA RD Receive Done P Prepared A statement was prepared NP Not Prepared A statement was not prepared The following example shows how to view a statement state transition table for SOLPrepare func tion SOUnallocated S1Allocated S2Prepared S6Infetch 1H S gt S1 S gt S2 24000 E gt S1 If SQLPrepare function is called when the handle type is SQL_HANDLE_STMT and the command sta tus is SO the ODBC administrator will return SOL INVALID Handle IH If SQL
213. tor indicator indicator aray array array array ama array 4 Example define DESC LEN 51 define ARRAY SIZE 10 SQLCHAR Statement INSERT INTO Parts PartID Description Price VALUES SOLUINTEGER PartIDArray ARRAY SIZE SOLCHAR DescArray ARRAY SIZE DESC LEN SOLREAL PriceArray ARRAY SIZE SOLINTEGER PartIDIndArray ARRAY SIZE DescLenOrIndArray ARRAY SIZE PriceIndArray ARRAY SIZE SQLUSMALLINT i ParamStatusArray ARRAY SIZE SQLUINTEGER ParamsProcessed ODBC Users Manual 36 SQLBindParameter Set the SOL ATTR PARAM BIND TYPE statement attribute to use column wise binding SOLSetStmtAttr hstmt SOL ATTR PARAM BIND TYPE SQL PARAMETER BIND BY COLUMN 0 Specify the number of elements in each parameter array SOLSetStmtAttr hstmt SOL ATTR PARAMSET SIZE ARRAY SIZE 0 Specify an array in which to return the status of each set of parameters SOLSetStmtAttr hstmt SOL ATTR PARAM STATUS PTR ParamStatusArray 0 Specify an SQLUINTEGER value in which to return the number of sets of parameters processed SOLSetStmtAttr hstmt SOL ATTR PARAMS PROCESSED PTR amp ParamsProcessed 0 Bind the parameters in column wise fashion SOLBindParameter hstmt 1 SOL PARAM INOUT SQL C ULONG SQL INTEGER 5 0 PartIDArray 0 PartIDIndArray SOLBindParameter hstmt 2 SQL PARAM INOUT SQL C CHAR SQL CHAR DESC LEN 1 0 DescArray DESC LEN DescL
214. ts will be ignored SQLINTEGER StringLength Output Returns the length excluding the NULL Ptr terminatior of the value returned to Val uePtr 113 ODBC Functions SQLGetStmtAttr Return Values SQL SUCCESS SQL SUCCESS WITH INFO SOL ERROR SOL INVALID HANDLE Description SQLGetStmtAttr returns the attribute related to the statement handle For the statement attribute or more information see SOLSetStmtAttr Diagnosis SOLSTATE Description Comments HY090 Invalid string or buffer length StringLength is smaller than 0 HY092 Invalid attribute or option The value specified in the attribute argument is not supported by this driver HYCOO Option not implemented The value specified in the attribute argument of ODBC is valid but not supported by this driver Related Functions SQLGetConnectAttr SQLSetConnectAttr SOLSetStmtAttr Example See SALTIBASE_HOME sample SQLCLI demo_plan cpp SOLGetStmtAttr stmt SOL ATTR EXPLAIN PLAN plan sizeof plan amp plan ind ODBC Users Manual 114 SQLGetTypelnfo SQLGetTypelnfo SQLGetTypelnfo returns information related to the data types that the database supports The driver returns the information in the form of an SOL result set The data type is used in the DDL statement Syntax SOLRETURN SQLGetTypeInfo SOLHSTMT stmt SQLSMALLINT type Arguments Data Type Argument In Out Description SOLHSTMT stmt In
215. ttributes such as the data type or length of the column by calling SQLDescribeCol or SOLColAttribute This information can be used to indicate the proper data type or to convert the data into another data type The columns are identified in a series of numbers from the left to the right The number of columns in the result set can be decided by setting SOL DESC Count in SOLNumResultCols or fieldldenti fier argument and by calling SOLColAttribute An application may not bind any column The data in unbound column can be searched by SOLGet ODBC Users Manual 28 SQLBindCol Data after SOLFetch is called In usuall case SOLBindCol is more efficient than SOLGetData To get the data from the buffer identified by this function SOLBindCol must be called before SQLFetch SOLSTATE Description Comments 07009 Invalid column number col Arguments exceeds the maximum number of columns in the result set HY000 General error HY001 Memory allocation error Failed to allocate the memory for the explicit handle HY003 An application buffer type is not valid cType argument is not valid Functions SQLDescribeCol SOLFetch SOLFreeStmt SOLGetData SQLNumResultCols See SALTIBASE_HOME sample SQLCLI demo_ex2 cpp sprintf query SELECT id name age FROM DEMO EX2 WHERE id if SQLPrepare stmt query SQL NTS SQL SUCCESS execute err dbc stmt query
216. ty export LD PRELOAD lib libdemangle so In addition if iODBC manager fails to provide an ODBC driver for AIX you should specify additional setting after checking the following You should extract iodbcinst so from iodbcinst a after searching for a path where iODBC library is installed ar x libiodbcinst a You should change so 2 into so as file extension gt mv libiodbcinst so 2 libiodbcinst so iODBC shared library search path should be specified by setting the value of the environment variable LIBPATH ex Shared library path is usr local lib export LIBPATH usr local lib SLIBPATH 7 ODBC Introduction Using ODBC Windows After installing ODBC Driver you should specify data source name registered in Setting gt Adminis trative Tools gt Data Source as DSN datasource name ODBC Users Manual 8 Basic Programming Steps Basic Programming Steps STEP 1 CONNECT SQLAllocHandle ENV SQLSetEnvAttr SQLAllocHandle DBC SQLDriverConnect S LSetConnectAttr STEP 2 INITIALIZE SQLAllocHandle STMT SQLSetStmtAttr STEP 3 EXECUTE Catalog function or SQLBindParam eter SQLExecDirect Statement Tune lt 1 Select or Catalog 2 Update DBiete Insert 3 Other STEP 4a FETCH RESULTS SQLNumResultCols SOLDescribeCol Ge SQLBindCol Ere SQLFetch SG m STEP 5 TRANSACT SQLEndTran STEP 6 DISCONNECT SQLFreeHandle STMT SQLDisconnect SQLFreeHandle
217. uffer length The identified nameMax is smaller than 0 If SQLDescribeCol is called after SOLPrepare and before SQLExecute all SOLSTATE that can be returned by SQLPrepare or SQLExecute can be returned 53 ODBC Functions SQLDescribeCol Related Functions SQLBindCol SOLColAttribute SQLFetch SQLNumResultCols SQLPrepare Example See SALTIBASE_HOME sample SQLCLI demo_meta2 cpp sprintf query SELECT FROM DEMO EX1 if SQLExecDirect stmt query SOL NTS SQL SUCCESS execute err dbc stmt query SOLFreeStmt stmt SQL DROP return SQL ERROR SOLNumResultCols stmt amp columnCount for i20 i lt columnCount i SOLDescribeCol stmt i 1 columnName sizeof columnName amp columnNameLength amp dataType amp columnSize amp scale amp nullable ODBC Users Manual 54 SOLDescribeParam SOLDescribeParam SOLDescibe retur ns the SQL data types of the columns related to the parameter marker of the dynamic SQL statements size data types expressions of the corresponding parameter markers number of decimal values and the NULLability Syntax SOLRETURNSQLDescribeParam SOLHSTMT stmt SOLSMALLINT iparam SOLSMALLINT type SOLINTEGER size SOLSMALLINT decimaldigit SOLSMALLINT nullable Arguments Data Type Argument In Out Description SOLHSTMT stmt Input Statement handle SOLSMALLINT iparam Input Order of the paramet
218. umn SOLINTEGER precision Output Pointer of column size in databaseThe ODBC returns O when pointer column size cannot be decided SOLSMALLINT scale Output Pointer of the number of decimal values in databaself the number of decimal val ues in the database cannot be decided or is not proper the ODBC will return 0 ODBC Users Manual 52 SQLDescribeCol Data Type Argument In Out Description SOLSMALLINT NULLable Output The pointer of the value that indicates whether the column allows NULL SOL NO NULLS The column does not allow NULL data SQL_NULLABLE The column allows NULL data SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SQL ERROR An application usually calls SOLPrepare and calls SOLDescribeCol before SOLExecute An application can call also SOLDescribeCol after calling SOLExecDirect SQLDescribeCol searches names types and lengths of the columns created by SELECT statements If the column is an expression name will be also an expression SOLSTATE Description Comments 01004 String data right truncated If the buffer name is not long enough to return the entire column name the length of the full column name will be returned as nameLength 07009 Invalid descriptor index The col value is 0 The identified col value is higher than the number of columns in the result set HYO0OO General error HY090 Invalid string or b
219. ure before the function processing is completed between the ODBC and the database HYO0OO General error In case of the statement attribute SOLSetConnectAttr can return any SOL state returned by SOL SetStmtAttr SOLAllocHandle 145 ODBC Functions SQLSetConnectAttr Example lt See SALTIBASE_HOME sample SQLCLI demo_tran1 cpp gt if SOLSetConnectAttr dbc SOL ATTR AUTOCOMMIT void SQL AUTOCOMMIT OFF 0 SQL SUCCESS execute err dbc SOL NULL HSTMT Autocommit OFF return SQL ERROR ODBC Users Manual 146 SQLSetDescField SQLSetDescField This specifies an attribute of descriptor Unicode SOL SetDescFieldW supports same execution as SQLSetDescField Syntax SQLRETURN SQLSetDescField SQLHDESC desc SQLSMALLINT recNumber SQLSMALLINT fieldIdentifier SOLPOINTER value SOLINTEGER bufferLength Argument Data Type Argument In Out Description SOLHDESC desc In Descriptor Handle SOLSMALLINT renNumber In This starts from 1 of column number SOLSMALLINT fieldldentifier In This specifies the attribute of column to retrieve SQLPOINTER value In Buffer pointer specifying attributes SQLINTEGER bufferLength In Value size Return Value SOL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Description This specifies an attribute of descriptor 147 ODBC Functions SQLSetDescField
220. use 0 bit is appended CD 80 00 1100 1101 1000 0000 gt gt Varbit Length 8 Precision 27 gt Precision indicates 27 because VARBIT doesn t perform pad ding 38 A8 93 60 0011 1000 1010 1000 1001 0011 011 If BUFFER SIZE is less than required SQLFetch returns SOL SUCCESS WITH INFO and wirtes its data in the memory bound as BUFFER_SIZE BIT VARBIT to SQL C BIT SQL C BIT of ODBC requires special care because it is the unsigned 8bit integer whose value is O or 1 In other words bound variables don t have 0x64 but 0x01 even though BIT 011001 is stored on the table of server when you bind them with SOL C BIT and fetch them BIT to SQL C CHAR If you bind BIT column with SOL C CHAR when fetching it the result always has 0 or 1 following ODBC type conversion rules CREATE TABLE T1 I1 BIT 12 INSERT INTO T1 VALUES BIT 110011000010 INSERT INTO T1 VALUES BIT 010011000010 SQLCHAR sData 128 ODBC User s Manual 246 Data Type SOLLEN sLength sQuery SQLCHAR SELECT I1 FROM T1 SOLBindCol stmt 1 SOL C CHAR sData sizeof sData sLength SOLExecDirect stmt sQuery SOL NTS while SQLFetch stmt SOL NO DATA printf bit value Sa sData printf sLength dMn sLength If you execute program above the following is displayed on the screen 1 sLength 1 0 sLength 1 n VARBIT to SQL_C_CHAR All data in the column are fetched when you f
221. ust not include the character string search pattern SQLSMALLINT pNameLength Input Character string of pName SQLCHAR colName Input Column Name SQLSMALLINT colName Input Character string of colName Length Return Values SOL SUCCESS 133 ODBC Functions SQLProcedureColumns SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR This function is used before a statement is executed to retrieve the procedure parameters and the columns that form the result sets returned by the procedure SQLProcedureColumns returns the results in the standard result set sorted in order by PROCEDURE CAT PROCEDURE SCHEM PROCEDURE NAME and COLUMN TYPE The column names will be returned for each procedure in the following order Name of returned value each parameter names to call the procedures or calling order and column names of the result set returned by the procedure or column order An application must bind the unique columns which contains the ODBC driver information to the last data of the result set Name No Data Type Description PROCEDURE CAT VARCHAR Returns NULL always PROCEDURE SCHEM VARCHAR Procedure schema name NULL if not applicable to the database PROCEDURE NAME VARCHAR Procedure name NOT NULL COLUMN NAME VARCHAR Procedure column name The driver NOT NULL returns an empty string for a procedure column that does not have a name COLUMN TYPE SMALLINT Defines the
222. xed string length n SQL_VARCHAR VARCHAR n Variable length character string with a maximum string length n SOL WCHAR NCHAR n Unicode character data type with fixed length n N means the number of characters SOL WVARCHAR NVARCHAR n Unicode character data type with variable length If declared as fixed SOL WVARCHAR has a fixed length If declared as variable SOL WVARCHAR has a variable length N means the number of characters SOL DECIMAL DECIMAL p s See NUMERIC p s SOL NUMERIC NUMERIC p s Signed exact numeric value with a precision p and scale s 1 lt p lt 38 84 lt s lt 126 SOL SMALLINT SMALLINT 2 byte integer data type 2 154 1 2415 1 SQL INTEGER INTEGER 4 byte integer data type 2431 1 2431 1 SOL BIGINT BIGINT 8 byte integer data type 2 634 1 2463 1 SOL REAL REAL The same data type as Float of C SQL FLOAT FLOAT p Fixed decimal numeric type data from 1E 120 to 1E 120 1 lt p lt 38 SOL DOUBLE DOUBLE The same data type with DOUBLE of C SOL BINARY BLOB n Binary data type size of n SOL TYPE DATE DATE Year month and day fields conforming to the rules of the Gregorian calendar 221 Data Types C Data Types SOL type ALTIBASE data eher identifier types SOL TYPE TIME DATE Hour minute and second fields with valid values for hours of 00 to 23 valid values for minutes of 00 to 59 and valid values for second
223. y binding NTS SOL ROW COUNTS ON Returns the number of records changed by each array element In other words if there are changed records the number of records will be returned If there is no record changed 0 will be returned In case an error occurs SOL USHRT MAX 65534 will be returned SQL ROW COUNTS OFF Existing behaviors of attri bute SOL ATTR PARAM STATUS PTR will be maintained SOL ATTR PARAMSET SIZE Necessary for array binding SQLUINTEGER value that indicates the number of val ues for each parameter SQL ATTR ROW ARRAY SIZE Necessary setting value atthe time of the array fetch in the SELECT statement SQLUINTEGER that indicates the number of rows returned by calling each SQLFetch SQL ATTR ROW BIND TYPE Necessary setting value at the time of the array fetch in the SELECT statement SQLUINTEGER that sets the direction of the binding to be used upon calling of SOLFetch The column wise binding is searched by setting SQL BIND BY COLUMN The row wise binding searches the data by setting the length of the structure or the length of the buffer to which the results columns will be bound In case the length is specified the space for the col umns to be bound must be included 155 ODBC Functions SQLSetStmtAttr Attribute Contents SOL ATTR ROW STATUS PTR Necessary setting value at the time of the array fetch in the SELECT statement The size of the arra
224. y is same as the number of rows of the row set In this attribute the NULL pointer can be set In this case the ODBC does not return the column status value SOL ATTR ROWS FETCHED PTR Necessary setting value at the time of the array fetch in the SELECT statement SQLUINTEGER value indicating the buffer that returns the number of fetched rows after SQLFetch is called ALTIBASE_STMT_ATTR_ATOMIC_ARR AY This is Altibase only attribute indicating to execute Atomic Array Insert Array Insert can execute the entire statements respectively whereas Atomic Array Insert can execute several statements at one execution and this results in them executed as a single statement in other words You may specify ALTIBASE_STMT_ATTR_ATOMIC_ARRAY in Attribute and SQL_TRUE SQL_FALSE in the param argument If you choose SQL_TRUE you can execute Atomic Array Insert However you must specify Array Size in order that Atomic Array Insert has better performance than the existing Array Insert does SQL_ATTR_PARAMSET_SIZE And you can save result values with using the following attributes SQL_ATTR_PARAM_STATUS_PRT Real result values are saved only in the first row and the rest is successfully processed SQL_ATTR_PARAMS_PROCESSED_ PTR Real result val ues are saved only in the first row and the rest of them are ignored SQLSTATE Description Comments HY000 General error See SALTIBASE_HOME sample S
225. ys SQLProcedureColumns SQLProcedures SQLRowCount SQLSetAttribute SQLSetConnectAttr SQLSetEnvAttrS QLStatistics SQLTables HY001 Memory allocation error Cannot allo cate the requested memory for the ODBC to execute and complete the function SQLAllocConnect SQLAllocStmt SQLBindCol SQLBindParameter SQLConnect SQLDriverConnect SQLExecDirect SQLGetTypelnfo SQLPrepare HY003 An application buffer type is not valid cType Argument value is not a valid C data type SQLBindCol SQLBindParameter ODBC User s Manual 228 ODBC Error Codes SQLSTATE Error Can be returned from HY009 Used an invalid pointer null pointer SOLAllocConnect SOLAllocStmt SQLBindParameter SQLExecDirect SQLForeignKeys SQLPrimaryKeys SQLProcedureColumns SQLProcedures SQLSpecialColumns SQLStatistics SQLTablePrivileges HY010 Function sequence error SQLAllocStmt SQLDescribeParam SQLGetData HY090 Invalid character string or buffer SQLBindParameter SQLDescribeCol SQLExecute SQLForeignKeys SQLGetData SQLGetStmtAttr SQLTablePrivileges HY092 Invalid attribute or option SOLGetStmtAttr HY105 Invalid parameter type SQLBindParameter HYCOO Used an attribute not supported SOLGetConnectAttr SOLGetStmtAttr SQLSTATE Code Error EE from HY000 0x51001 The character set does not exist SQLConnect SQLDriverConnect 0x5003b The communication buffer is insuffi SQLExecute
226. yte It begins at 1 SOLLEN forLength Input The length of data to transfer from LOB byte SOLSMALLINT targetCType Input The C data type identifier of the value buffer It can have the following values SQL C BINARY SQL C CHAR If the user reads BLOB data into the SQL C CHAR buffer BINARY is con verted to CHAR and the result value is stored in an application buffer SQLPOINTER Value Output A pointer to the buffer that holds data SOLLEN bufferSize Input The size of the value buffer byte 191 LOB Interface SOL Gett ob Data Type Argument In Out Description SOLLEN valueLength Output A pointer to the buffer to which the length of data stored in the value buffer is returned This argument cannot be NULL SQL SUCCESS SQL SUCCESS WITH INFO SOL INVALID HANDLE SOL ERROR Gets a part of data in the LOB pointed by the source locator to an application data buffer It is used to get LOB data in parts The total length of LOB can be obtained by calling SQLGetLobLength If a source locator is not the LOB locator obtained during the current transaction it cannot be used as an argument for this function This is because a LOB locator becomes invalid if a transaction is ter minated If a source LOB locator is not valid the SOLGetLob function will return SOL ERROR and the buffer pointed by the value and valueLength arguments will not be changed If a source locator points NULL LOB th
Download Pdf Manuals
Related Search
Related Contents
CubeSuite Ver.1.40 Integrated Development Environment User`s McCulloch 96011024401 Lawn Mower User Manual Manuel d`instructions radio jbl mr-145 A2 – A4P Dynamode USB-HDK-E Weber 89795 User's Manual SYBA SY-ADA24040 Air King 4C630P/9012P Fan User Manual Copyright © All rights reserved.
Failed to retrieve file