Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

Native SQL

Former Member
0 Kudos

Hi Friends,

Can we access table that is created in native sql by using open sql ?

Regards,

Rushi.

3 REPLIES 3

alejandro_bindi
Active Contributor
0 Kudos

No. With Open SQL you access the Data Dictionary layer (SAP side), the runtime links that layer to the real DB. If you create a table using CREATE TABLE from Native SQL, the Data Dictionary definition doesn't exist, so Open SQL cannot "see" that table.

However, i think you shouldn't use DDL SQL from ABAP (using Native SQL).

Regards.

Please reward points if helpful.

0 Kudos

we can access database using both OPEN SQL and NATIVE SQL but there is problem if use NATIVE SQL because while transporting form one system to another system you have to write some extra coding. For example you are using ORACLE data base in your R/3 system and used NATIVE SQL and in future your management changed made a decision to change the data base to DB2.in these case you have to write extra logic and also you may face some problems using NATIVE SQL you should know the prier knowledge of which database your client using and no F1 help while coding these are the probles you face if you code using NATIVE SQL.It's better to use OPENSQL.

To use NATIVE SQL write the code in EXEC and ENDEXEC block.

<b>

reward points if helpful.</b>

che_eky
Active Contributor
0 Kudos

Use Native SQL commands for this purpose, for example:

TRY.

EXEC SQL.

INSERT INTO scarr

(MANDT, CARRID, CARRNAME, CURRCODE, URL)

VALUES ('000', 'FF', 'Funny Flyers', 'EUR',

'http://www.ff.com');

INSERT INTO scarr

(MANDT, CARRID, CARRNAME, CURRCODE, URL)

VALUES ('000', 'EF', 'Easy Flyers', 'EUR',

'http://www.ef.com');

ENDEXEC.

CATCH cx_sy_native_sql_error INTO exc_ref.

error_text = exc_ref->get_text( ).

MESSAGE error_text TYPE 'I'.

ENDTRY.