Hi,
currently I am trying to switch from static Native SQl to dynamic one with ADBC.
When I try to execute the same SELECT Statement with cl_sql_statement_>execute_query I receive
"Error: Ressource unavailable"
That was the old code:
CONSTANTS: c_con_name TYPE dbcon_name VALUE 'SAP2PWS'. "Defined in DBCO
EXEC SQL.
connect TO :c_con_name
ENDEXEC.
EXEC SQL .
OPEN dbcur FOR SELECT
PERSID,
PERSNR,
FROM TEST_DB0T.TS$$004.VEPSS_SAP_MIA
ENDEXEC.<br>
Statement is working, Result set looks fine.
Now with the dynamic SQL, i am receiving above named Error:
TRY.
DATA(conn) = cl_sql_connection=>get_connection( c_con_name ).
DATA(query) = NEW cl_sql_statement( )->execute_query(
EXPORTING
statement = 'SELECT * FROM TEST_DB0T.TS$$004.VEPSS_SAP_MIA'
).
CATCH cx_sql_exception "
cx_parameter_invalid "
INTO DATA(error).
MESSAGE error->get_text( ) TYPE 'E'.
ENDTRY.
Has anyone got a clue how to resolve this?
Database to connect is DB2 (IBM).

Request clarification before answering.
Hi, found the Solution by myself.
I forgot to pass the Connection Object to the Statement, without that it generates a new Connection which is not the intended one.
After the call I then have to bind a workarea to access the Result Set:
TRY.
DATA(conn) = cl_sql_connection=>get_connection( c_con_name ).
DATA(result_set) = NEW cl_sql_statement( con_ref = conn )->execute_query(
EXPORTING
hold_cursor = 'X'
statement = | SELECT | &&
| PERSID, PERSNR, GVON | &&
| FROM X-X-X |
).
result_set->set_param_struct( struct_ref = REF #( wa_pws ) )." Referenz auf Ausgabevariable
WHILE result_set->next( ) > 0.
"Do sth
ENDWHILE.
conn->close( ).
CATCH cx_sql_exception " Ausnahmeklasse für SQL Fehler
cx_parameter_invalid " Oberklasse für Parameterfehler
INTO DATA(error).
MESSAGE error->get_text( ) TYPE 'E'.
ENDTRY.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Look at report ADBC_DEMO (also execute it)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The reason code 00D31020 would be
The type of resource 00001000 is
| User | Count |
|---|---|
| 5 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.