Skip to Content
0

SAP HANA ODBC 292 error wrong number of arguments with CREATE LOCAL TEMPORARY TABLE AS (... ? ...)

Sep 07, 2017 at 01:01 PM

156

avatar image
Former Member

When doing SQLPrepareW() + SQLBindParameter() + SQLExecute() of

CREATE LOCAL TEMPORAY TABLE AS ( SELECT * FROM t1 WHERE pk = ? )

I get the following error:

[SAP AG][LIBODBCHDB SO][HDBODBC] General error;292 wrong number of arguments

Is there some limitation with this kind of SQL statement or is this a bug?

I will provide the ODBC API trace in subsequent comment.

Seb

10 |10000 characters needed characters left characters exceeded
Former Member

Attached the ODBC API trace... am I doing something wrong?!?

<html><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head><body><PRE><PLAINTEXT>
libSQLDBCHDB 2.2.23.1499440855
SYSTEM: Linux / X64
BUILD AT: 2017-07-07 18:15:01
BRANCH: unknown
APPLICATION: fglrun


SQLAllocHandle 2017-09-07 14:54:02.697746
HandleType       [in]    : SQL_HANDLE_ENV
InputHandle      [in]    : 0x0000000000000000
OutputHandlePtr  [out]   : 0x000060d00000ac90
SQLRETURN                : SQL_SUCCESS


SQLSetEnvAttr 2017-09-07 14:54:02.697772
EnvironmentHandle[in]    : 0x000060d00000ac90
Attribute        [in]    : SQL_ATTR_ODBC_VERSION
ValuePtr         [in]    : SQL_OV_ODBC3
StringLength     [in]    : -5
SQLRETURN                : SQL_SUCCESS


SQLAllocHandle 2017-09-07 14:54:02.697844
HandleType       [in]    : SQL_HANDLE_DBC
InputHandle      [in]    : 0x000060d00000ac90
OutputHandlePtr  [out]   : 0x000061a000010e89
SQLRETURN                : SQL_SUCCESS


SQLConnect 2017-09-07 14:54:02.697902
ConnectionHandle [in]    : 0x000061a000010e89
ServerName       [in]    : HANADB1
NameLength1      [in]    : SQL_NTS
UserName         [in]    : hdbuser
NameLength2      [in]    : SQL_NTS
enc                      : ASCII
ODBC connect properties:
        # LOCALE        : ISO-8859-15
        DATABASENAME    : TEST1
SQLRETURN                : SQL_SUCCESS


SQLSetConnectAttr 2017-09-07 14:54:02.704993
ConnectionHandle [in]    : 0x000061a000010e89
Attribute        [in]    : SQL_ATTR_AUTOCOMMIT
StringLength     [in]    : 0
enc                      : ASCII
ValuePtr         [in]    : SQL_AUTOCOMMIT_OFF
SQLRETURN                : SQL_SUCCESS


SQLAllocHandle 2017-09-07 14:54:02.705015
HandleType       [in]    : SQL_HANDLE_STMT
InputHandle      [in]    : 0x000061a000010e89
OutputHandlePtr  [out]   : 0x000061400000e460
SQLRETURN                : SQL_SUCCESS


SQLExecDirect 2017-09-07 14:54:02.705042
StatementHandle  [in]    : 0x000061400000e460
StatementText    [in]    : 'SELECT version FROM m_database;'
TextLength       [in]    : SQL_NTS
enc                      : ASCII
SQLRETURN                : SQL_SUCCESS


SQLBindCol 2017-09-07 14:54:02.705760
StatementHandle  [in]    : 0x000061400000e460
ColumnNumber     [in]    : 1
TargetType       [in]    : SQL_C_CHAR
TargetValue      [in/out]: 0x00007ffdf999e7a0
BufferLength     [in]    : 100
StrLen_or_IndPtr [in/out]: 0
SQLRETURN                : SQL_SUCCESS


SQLFetch 2017-09-07 14:54:02.705783
 --> SQLExtendedFetch
SQLExtendedFetch 2017-09-07 14:54:02.705788
StatementHandle  [in]    : 0x000061400000e460
FetchOrientation [in]    : SQL_FETCH_NEXT
FetchOffset      [in]    : 0
RowCountPtr      [out]   : 0x0000000000000000
RowStatusArray   [out]   : 0x0000000000000000
SQLRETURN                : SQL_SUCCESS
 <-- SQLExtendedFetch


SQLCloseCursor 2017-09-07 14:54:02.705821
StatementHandle  [in]    : 0x000061400000e460
SQLRETURN                : SQL_SUCCESS


SQLFreeHandle 2017-09-07 14:54:02.705843
HandleType       [in]    : SQL_HANDLE_STMT
Handle           [in]    : 0x000061400000e460
SQLRETURN                : SQL_SUCCESS


SQLAllocHandle 2017-09-07 14:54:02.705973
HandleType       [in]    : SQL_HANDLE_STMT
InputHandle      [in]    : 0x000061a000010e89
OutputHandlePtr  [out]   : 0x000061400000e440
SQLRETURN                : SQL_SUCCESS


SQLSetCursorName 2017-09-07 14:54:02.705994
StatementHandle  [in]    : 0x000061400000e440
CursorName       [in]    : scu1
NameLength       [in]    : SQL_NTS
SQLRETURN                : SQL_SUCCESS


SQLSetStmtAttr 2017-09-07 14:54:02.706128
StatementHandle  [in]    : 0x000061400000e440
Attribute        [in]    : SQL_ATTR_NOSCAN
StringLength     [in]    : SQL_NTS
ValuePtr         [in]    : SQL_NOSCAN_ON
SQLRETURN                : SQL_SUCCESS


SQLPrepare 2017-09-07 14:54:02.706154
StatementHandle  [in]    : 0x000061400000e440
StatementText    [in]    : 'create local temporary table #tt2 as (select * from   t1 where pk = ? )'
TextLength       [in]    : SQL_NTS
enc                      : UCS2 (LE) (native)
SQLRETURN                : SQL_SUCCESS


SQLBindParameter 2017-09-07 14:54:02.708007
StatementHandle  [in]    : 0x000061400000e440
ParameterNumber  [in]    : 1
InputOutputType  [in]    : SQL_PARAM_INPUT
ValueType        [in]    : SQL_C_LONG
ParameterType    [in]    : SQL_INTEGER
ColumnSize       [in]    : 0
DecimalDigits    [in]    : 0
ParameterValPtr  [in]    : 0x000060200001e030
BufferLength     [in/out]: 0
StrLen_or_IndPtr [in]:     0x000060600000c350
SQLRETURN                : SQL_SUCCESS


SQLExecute 2017-09-07 14:54:02.708047
StatementHandle  [in]    : 0x000061400000e440
SQLRETURN                : SQL_ERROR


SQLGetDiagRec 2017-09-07 14:54:02.714404
HandleType       [in]    : SQL_HANDLE_STMT
Handle           [in]    : 0x000061400000e440
RecNumber        [in]    : 1
BufferLength     [in]    : 513
enc                      : ASCII
SQLState         [out]   : S1000
NativeErrorPtr   [out]   : 292
MessageText      [out]   : [SAP AG][LIBODBCHDB SO][HDBODBC] General error;292 wrong number of arguments
TextLengthPtr    [out]   : 76
SQLRETURN                : SQL_SUCCESS
<CURRENT WRITE POSITION><br>
0
Former Member

I meet the same issue with

procedure "my_proc" ( in i_var nvarchar(10) ) 
...
begin

...
create local TEMPORARY TABLE #my_buff AS ( select * from "sometable" where "somefield" = i_var );

...

end;

i'v got a message "...wrong number of arguments"

but if i change statement to

create local TEMPORARY TABLE #my_buff AS ( select * from "sometable" where "somefield" = :i_var );<br>

when activate i'v got a message "Could not create catalog object: cannot use parameter variable.."

and one more, if select return no values then local table will created, else there will be a message "...wrong number of arguments"

0
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Best Answer
Jeff Albion
Oct 11, 2017 at 05:07 PM
2

Hello Sebastien,

This is actually a server issue as the server reply informs the ODBC driver about how many arguments to expect, which currently replies with 0 parameters. I've filed a bug for this issue.

Best regards,

Jeff

Show 1 Share
10 |10000 characters needed characters left characters exceeded
Former Member

(Back to the project sorry for the late answer)
Thank you guys for considering this, much appreciated.

Seb

1