<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Error handling in Native SQL for ORACLE in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511245#M1066909</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look on this: &lt;A href="http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA instr TYPE char4.

EXEC SQL.

SELECT INSTRUMENTO INTO :instr FROM DATOSMAESTROS

ENDEXEC.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look that I put : inside the native SQL before the intr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To catch if no data was recovered try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA instr TYPE char4.

EXEC SQL PERFORMING no_data.

SELECT INSTRUMENTO INTO :instr FROM DATOSMAESTROS

ENDEXEC.

FORM no_data.
  IF instr IS INITIAL.
    MESSAGE ...
  ENDIF.
ENDFORM.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 26 Sep 2008 12:36:20 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2008-09-26T12:36:20Z</dc:date>
    <item>
      <title>Error handling in Native SQL for ORACLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511244#M1066908</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have the next code:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA instr TYPE char4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXEC SQL.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    SELECT INSTRUMENTO INTO instr FROM DATOSMAESTROS&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;END EXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And I want to control if the select has no results. Is it possible with the statement EXCEPTION inside EXEC SQL? Something like that:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DATA instr TYPE char4.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;EXEC SQL.&lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt;    SELECT INSTRUMENTO INTO instr FROM DATOSMAESTROS WHERE id_inst = '01'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;    EXCEPTION &lt;/P&gt;&lt;P&gt;         WHEN NO_DATA_FOUND THEN&lt;/P&gt;&lt;P&gt;                  :err = SQLCODE&lt;/P&gt;&lt;P&gt;                  INSERT INTO error( field, code_err) VALUES ( 'instrumento',:err)&lt;/P&gt;&lt;P&gt;END EXEC.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is this a correct code? If not, how can I do it?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you all,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cris.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 12:33:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511244#M1066908</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-26T12:33:12Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling in Native SQL for ORACLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511245#M1066909</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Take a look on this: &lt;A href="http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm" target="test_blank"&gt;http://help.sap.com/saphelp_nw04s/helpdata/en/fc/eb3b8b358411d1829f0000e829fbfe/frameset.htm&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA instr TYPE char4.

EXEC SQL.

SELECT INSTRUMENTO INTO :instr FROM DATOSMAESTROS

ENDEXEC.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Look that I put : inside the native SQL before the intr.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;To catch if no data was recovered try this:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
DATA instr TYPE char4.

EXEC SQL PERFORMING no_data.

SELECT INSTRUMENTO INTO :instr FROM DATOSMAESTROS

ENDEXEC.

FORM no_data.
  IF instr IS INITIAL.
    MESSAGE ...
  ENDIF.
ENDFORM.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 12:36:20 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511245#M1066909</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-26T12:36:20Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling in Native SQL for ORACLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511246#M1066910</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello David,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I tought in the solution you propose, but this is only an example, I must handle other errors like insert a null value into a not null column, inconsistent datatypes, etc... and I find the Oracle errors for every case. Is there any way to handle Oracle Exceptions? It would be the ideal solution.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks!!!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Cris.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 26 Sep 2008 12:45:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511246#M1066910</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-26T12:45:49Z</dc:date>
    </item>
    <item>
      <title>Re: Error handling in Native SQL for ORACLE</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511247#M1066911</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Cristina,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;you may check cx_sy_native_sql_error and it's messages for the error number&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Example :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;try .

* your statements


CATCH cx_sy_native_sql_error INTO my_err.
errtext = my_err-&amp;gt;get_text( ).

MESSAGE errtext TYPE 'I'. 

endtry.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;bye&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;yk&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 30 Sep 2008 07:49:59 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/error-handling-in-native-sql-for-oracle/m-p/4511247#M1066911</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2008-09-30T07:49:59Z</dc:date>
    </item>
  </channel>
</rss>

