Skip to content

SQLNativeSql

SQLNativeSql#

This coverts SQL statements to statements supported by Altibase CLI driver.

Unicode SQLNativeSqlW() supports same execution as SQLNativeSql().

Syntax#

SQLRETURN SQLNativeSql (
        SQLHDBC dbc,
        SQLCHAR *InstatementText,
        SQLINTEGER textLength,
        SQLCHAR *OutStstementText,
        SQLINTEGER bufferLength,
        SQLINTEGER textLength);

Argument#

Data Type Argument In/Output Description
SQLHDBC dbc Input Connection handle
SQLCHAR * InstatementText Input SQL statements to convert
SQLINTEGER textLength Input The length, in bytes, of the contents of the InstatementText argument
SQLCHAR * OutStstementText Output Buffer Pointer recieving the converted SQL statements
SQLINTEGER bufferLength Input Size of OutStstementText
SQLINTEGER textLength Output Size specified in OutStstementText

Return Values#

SQL_SUCCESS
SQL_SUCCESS_WITH_INFO
SQL_INVALID_HANDLE
SQL_ERROR

Description#

This converts SQL statements to statements supported by Altibase CLI driver.

Altibase supports the following syntaxes:

  • {d, '1981-09-27'} → TO_DATE('1981-09-27', 'YYYY-MM-DD')

  • {t, '07:23:56'} → TO_DATE('07:23:56', 'HH:MI:SS')

  • {ts, '1981-09-27 07:23:56'} → TO_DATE('1981-09-27 07:23:56', 'YYYY-MM-DD HH:MI:SS')

  • {? = call PROC1(a, ?, c)} → EXECUTE ? := PROC1(a, ? ,c)

Diagnosis#

SQLSTATE Description Comments
HY000 General error No error occurs explicitly.
HY001 Memory allocation error This denotes to fail to allocate memory for handle.
01004 Data is cut off Buffer size of OutStstementText is lesser than the size of returned data.

Example#

SQLNativeSql(  dbc, 
               (SQLCHAR*)"INSERT INTO T1 VALUES( {d '1981-09-27'} )",
               SQL_NTS,
               outText,
               100,
               &outTextLen);
  • outText에 INSERT INTO T1 VALUES( TO_DATE('1981-09-27', 'YYYY-MM-DD'))가 저장된다.