on 11-08-2013 6:10 PM
Hello,
I am trying to connect to Oracle DB from ABAP by using the following
select single dbms from dbcon into dbtype
where con_name = 'CON1'.
if sy-subrc = 0.
TRY.
IF sy-host EQ 'sapxxxxxx'.
EXEC SQL.
connect to 'CON1' as 'CON'
ENDEXEC.
ENDIF.
IF sy-subrc <> 0.
RAISE EXCEPTION TYPE cx_sy_native_sql_error.
ENDIF.
EXEC SQL.
set connection 'CON'
ENDEXEC.
CATCH cx_sy_native_sql_error INTO exc_ref.
LEAVE PROGRAM.
ENDTRY.
endif.
This is resulting in SQL error ORA-00900.
invalid SQL statement.
I am not sure what is wrong as the connection in DBCON is working fine.
Any idea.
Can some one give me any hint.
thanks,
Hi Hasnain,
Follow the command what ever deepak mention & for more clarification pls check this link
http://www.dba-oracle.com/sf_ora_00900_invalid_sql_statement.htm
Regards
Nayeem
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Hasnain,
Refer the sample below
First define connection to your Oracle database using transaction DBCO the you can use in your ABAP program something like this:
DATA: CONNECTION LIKE DBCON-CON_NAME VALUE 'TEST_DW'.
EXEC SQL.
CONNECT TO :CONNECTION
ENDEXEC.
IF SY-SUBRC = 0.
EXEC SQL.
SET CONNECTION :CONNECTION
ENDEXEC.
EXEC SQL.
INSERT INTO ORA_TAB(FIELD1, FIELD2)
VALUES (:VALUE1, :VALUE2)
ENDEXEC.
EXEC SQL.
SET CONNECTION DEFAULT
ENDEXEC.
EXEC SQL.
DISCONNECT :CONNECTION
ENDEXE
ENDIF.
where ORA_TAB s Oracle table name, FIELD1, FIELD2 are table fields, VALUE1, VALUE2 are ABAP variables...
Hope this helps.
Regards,
Deepak Kori
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.