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: 

Can we use native sql select statements of sybase database in abap program using exec Sql. endexec.

dhawal5
Discoverer
0 Kudos

hello Gurus ,

I am new to using of native sql queries in abap proram , I have requirement to fetch data from standard ekko table in to internal table using native sql select query in exec sql. endexec. but it is trowing CX_SY_NATIVE_SQL_ERROR exception , I am using sybase database.

1 ACCEPTED SOLUTION

matt
Active Contributor
0 Kudos

"I have requirement to fetch data from standard ekko table in to internal table using native sql select query in exec sql. endexec."

No. You don't. You have a requirement to read EKKO from ABAP. You're choosing, for some reason, to try this via EXEC SQL. Why are you not using normal ABAP SELECT?

8 REPLIES 8

nabheetscn
Active Contributor

You can use. Is your backend database sybase or a remote one(via dbcon)? Secondly you can use ADBC(provided you are on right version) classes for native SQL. Thirdly use try catch statement to identify the exact exception, read this for more help.

Nabheet

Sandra_Rossi
Active Contributor
0 Kudos

You should prefer using ABAP SQL, are you sure you can't use it? Moreover, you may use the native SQL editors to find out the right query syntax, either the editor via transaction code ST04 or the one via program RSDU_EXEC_SQL.

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Using native SQL statements from SAP standard tables like EKKO isn't a good idea anyway. You should either use existing API's that have appropriate authorization checks implemented or have a look at creating a CDS view together with an appropriate DCL.

If one or more answers have answered your question please click on " Accept".

ceterum censeo RAP esse utendam

matt
Active Contributor
0 Kudos

Tag issue reported to mods and fixed.

"If one or more answers have answered your question please click on " Accept"." Bit premature - since yours was the first answer!

matt
Active Contributor
0 Kudos

"I have requirement to fetch data from standard ekko table in to internal table using native sql select query in exec sql. endexec."

No. You don't. You have a requirement to read EKKO from ABAP. You're choosing, for some reason, to try this via EXEC SQL. Why are you not using normal ABAP SELECT?

Andre_Fischer
Product and Topic Expert
Product and Topic Expert

Hi Matthew,

I do not like to add this kind of comment to my answers but I am just annoyed that quite a number of SCN users do not mark any answer as "accepted" though they have received one and more correct answers.

And unfortunately SCN does remind SCN users that have received answers but have not marked or upvoted any of them automatically.

(I have been told that this would not be possible due to data protection regulations).

I have thus started adding this phrase like Cato ended all of his speeches with the phrase "ceterum censeo …" https://en.wiktionary.org/wiki/ceterum_censeo

But I agree that it sounds a bit premature if I am the first one giving an answer.

I will thus from now on use one of the following two standard answers.

If my answer has answered your question please click on " Accept".

Regards,

Andre

ceterum censeo RAP esse utendam

matt
Active Contributor
0 Kudos

I think I prefer the first one. I know.. .there's no pleasing some people! 😄

😄 :D.. I was actually noticing your answers and comments with that phrase and wondered that I am not the only one who is triggered to people who just don't care if someone took sometime to answer their query 😄

BR,
Mahesh