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: 
Read only

Native SQL using variables?

Former Member
0 Likes
684

Hi folks,

Is it possible to assign a SQL query to a variable, and then using an OPEN statement to read the variable?

E.g.,

query TYPE STRING VALUE 'SELECT * FROM mytable'.

EXEC SQL.

OPEN c1 FOR :query

ENDEXEC.

3 REPLIES 3
Read only

Former Member
0 Likes
471

Host variables are for transferring data from database table to abap program.So i don't think so that we can use for reading the variables

Read only

0 Likes
471

Hi, thanks for the quick reply.

So do you have any idea how to do to open using a variable? This is because my SQL statement needs to be constructed dynamically depending on other data (I am doing string processing before the statement is finalized).

Or is there another way to do this instead of using cursor processing in Native SQL?

Thanks in advance.

Read only

0 Likes
471

OK, I've tried to narrow this length of string down to the following:

data mystring type string.

"SELECT ... ... ... WHERE" ... and then "mystring" needs to be appended to the end of the SQL statement.

E.g., mystring could be " field1 = '1234' AND field2 = 'XYZ' "

Is this possible? Thanks in advance for reading.