Skip to Content
0

Native SQL in ABAP - dynamic Where clause not working

May 18, 2017 at 08:29 PM

187

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

1 Answer

Matthew Billingham
May 19, 2017 at 05:45 AM
0

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.

Share
10 |10000 characters needed characters left characters exceeded