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 in ABAP - dynamic Where clause not working

sagar_pawar14
Explorer
0 Kudos

Hi,

I am facing a strange issue with NAtive SQL statement.

I have a DB connection set up from SAP to Oracle and i am writing a query to fetch data from that oracle table.

Issue is when i use value in 'single quotes' in where clause, its fetching correct data but when i give dynamic where clause, its not fetching any data . please see examples below -

Working -

EXEC SQL.
OPEN dbcur FOR Select STYLE_NUMBER,
SERIAL_NUMBER
FROM <VIEW_name> WHERE SERIAL_NUMBER = '1234'

ENDEXEC.

Not working -

data : p_serial_num type string.

p_serial_num = '1234'.

EXEC SQL.
OPEN dbcur FOR Select STYLE_NUMBER,
SERIAL_NUMBER
FROM <VIEW_name> WHERE SERIAL_NUMBER = :p_serial_num

ENDEXEC.

It used to work previously, but we have recently upgraded ho HANA, so not sure if anything causing the issue.

If anyone of you experienced this kind of issue, please post your suggestions .

Thanks in advance!

Sagar

1 REPLY 1

matt
Active Contributor
0 Kudos

Just use ADBC (cl_sql_statement) instead of EXEC SQL. Or even better, create an AMDP and write the whole thing in HANA SQL Script. All nicely modern and up to date technology.