Skip to Content

TRY ... CATCH doesn't work with EXEC SQL?

When I created a native SQL statement, I knew before, that it would take a few tries to get it working. I decided to use exception classes to avoid short dumps, but it didn't work.

Following code causes a short dump because of the dot after :xp_stras in the native SQL SELECT statement:

try.

EXEC SQL PERFORMING list.

SELECT LIFNR, NAME1, STRAS

INTO :xsl

FROM LFA1

WHERE UPPER( NAME1 ) LIKE :xp_name1

AND UPPER( STRAS ) LIKE :xp_stras.

ENDEXEC.

catch CX_SY_NATIVE_SQL_ERROR.

write: /1 'CX_SY_NATIVE_SQL_ERROR'.

catch CX_SY_SQL_ERROR.

write: /1 'CX_SY_SQL_ERROR'.

catch CX_DYNAMIC_CHECK.

write: /1 'CX_DYNAMIC_CHECK'.

catch CX_ROOT.

write: /1 'CX_SY_ROOT'.

endtry.

In ST22 you can see

Name of runtime error: DBIF_DSQL2_SQL_ERROR

Exception:

The name of the exception is empty, in other short dumps you can find there the name of the exception class. Maybe that's the reason for CATCH does'nt work, but I don't understand it.

Online help for EXEC SQL says:

Catchable Exceptions

CXSY_NATIVE_SQL_ERROR_

...

Cause: SQL-Error at the execution of a Native SQL-command.

Runtime Error: DBIF_DSQL2_SQL_ERROR

We have SAP ECC 6.0 with SAP_BASIS rel. 700 lvl. 0013.

If You have an idea why CATCH doesn't work, please tell me!

Regards,

Klaus

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • avatar image
    Former Member
    Oct 20, 2008 at 06:10 PM

    You can start by not putting extra spaces between NAME1 and the parentheses. Try:

    WHERE UPPER(NAME1)  =  :NAME

    (and STRAS as well).

    Also check that the declaration of XSL corresponds to what you are selecting.

    Rob

    Edited by: Rob Burbank on Oct 20, 2008 2:11 PM

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 20, 2008 at 06:53 PM

    Hi,

    Catch should work with Native SQL....

    Change your SQL , to remove period at the end of statement.

    EXEC SQL PERFORMING list.

    SELECT LIFNR, NAME1, STRAS

    INTO :xsl

    FROM LFA1

    WHERE UPPER( NAME1 ) LIKE :xp_name1

    AND UPPER( STRAS ) LIKE :xp_stras

    ENDEXEC.

    Refer to this thred:

    native-sql

    Add comment
    10|10000 characters needed characters exceeded

    • Thanks, I followed Your link, but the thread didn't help me to find out, why CATCH doesn't work.

      I also tried out CATCH ... INTO ..., but there was no difference.

      Maybe it's database dependent, why CATCH works or works not. We are using ORACLE 10.2.0.2.0.