Application Development and Automation 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: 

Dynamic 'from' Clause in Native SQL

Former Member
0 Kudos
383

Hi All,

While running a select query in ORACLE, we can put the table name in '<i>from</i>' clause at the runtime-Seletion Screen Parameter .

But I am not able to do so in SAP using Native Sql. Does SAP has any restrictions regarding this?

It might be possible that ,by using Embedded SQL (C/C++ precompiler ),we may be able to achive this.

Can any body please throw light on this.

Its Urgent.

Thanks in Advance.

Regards,

Gaurav

3 REPLIES 3

Former Member
0 Kudos
210

Hello Gaurav,

I don't know much about native SQL, but with open SQL this is possible with a statement like "<u>select * from (p_table)</u>" where p_table is the parameter which takes table name on the selection screen.

Thank you,

Aravind.

VXLozano
Active Contributor
0 Kudos
210

Have you tried macroes?

DEFINE ....

SELECT * FROM &1

....

(I will become a macroes' fan)

ssimsekler
Active Contributor
0 Kudos
210

Hi

<u>Assuming you can also use Open SQL.</u>

Macroman's suggestion is OK. in Open SQL (this is SQL of ABAP platform) but a query statement can be constituted using some dynamic clauses. Although macro coding has some restrictions it will be less time consuming using it than a dynamic query.

<u>An example SELECT statement with dynamic clauses:</u>

SELECT (fields) FROM (table_name_variable)
INTO <target_fields>
WHERE (conditions_tab) .

For more information:

<a href="http://help.sap.com/saphelp_47x200/helpdata/en/fc/eb3983358411d1829f0000e829fbfe/frameset.htm">Open SQL -Reading Data</a>

*--Serdar