<?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 DELETE  &amp; INSERT with native SQL in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762488#M1305111</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;Can someone give me an example for :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   ---&amp;gt; DELETE all from a specific table.&lt;/P&gt;&lt;P&gt;   ---&amp;gt; INSERT a lot of records in a specific table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 23 Jun 2009 19:53:09 GMT</pubDate>
    <dc:creator>MusAbaper</dc:creator>
    <dc:date>2009-06-23T19:53:09Z</dc:date>
    <item>
      <title>DELETE  &amp; INSERT with native SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762488#M1305111</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;Can someone give me an example for :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   ---&amp;gt; DELETE all from a specific table.&lt;/P&gt;&lt;P&gt;   ---&amp;gt; INSERT a lot of records in a specific table&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;&lt;P&gt;Best regards&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 19:53:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762488#M1305111</guid>
      <dc:creator>MusAbaper</dc:creator>
      <dc:date>2009-06-23T19:53:09Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE  &amp; INSERT with native SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762489#M1305112</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey..&lt;/P&gt;&lt;P&gt;try these..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;DELETE FROM &amp;lt;database table &amp;gt;  WHERE &amp;lt;sql_cond &amp;gt;.&lt;/P&gt;&lt;P&gt;DELETE FROM &amp;lt;database table &amp;gt;  WHERE &amp;lt;sql_cond &amp;gt;   FROM &amp;lt; source internal table&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INSERT INTO &amp;lt;database table&amp;gt; VALUES &amp;lt;sourcetable&amp;gt; .&lt;/P&gt;&lt;P&gt;INSERT &amp;lt;database table&amp;gt;  FROM   &amp;lt;sourcetable&amp;gt;. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;KC&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 23 Jun 2009 20:02:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762489#M1305112</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-06-23T20:02:12Z</dc:date>
    </item>
    <item>
      <title>Re: DELETE  &amp; INSERT with native SQL</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762490#M1305113</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;the statement :  insert into &amp;lt;TableName&amp;gt; values (Source)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;how can I know if the data have already insert to the database table?&lt;/P&gt;&lt;P&gt;now I have a program have this problem:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;data: dbs like dbcon-con_name value 'HRGK',
        dbtype type dbcon_dbms.
data: sqlerr_ref type ref to cx_sql_exception,
         exc_ref    type ref to cx_sy_native_sql_error,
         error_text type string.
data: cnt type i,
        i(2) type c.
set locale language 'E'.
EXEC SQL.
  CONNECT TO :DBS
ENDEXEC.
EXEC SQL.
  SET CONNECTION :DBS
ENDEXEC.
EXEC SQL.
  SELECT COUNT(*) from org_unit into :cnt
ENDEXEC.
write: / cnt.
*do.
i = 'A'.                
try.
    EXEC SQL.
      BEGIN
       insert into ORG_UNIT ( ORGAN_ID, UNIT_NO, UNIT_NAME, PARENT_ID)
                     values ( 'A', '123412', 'SDFSG', 'DDS');                     " ORGAN_ID is primary key
"If the data 'A' has already exist in database ORG_UNIT, it will show error message
" But if I use :I instead 'A', it will not show error message.

        IF SQL%FOUND THEN
           COMMIT;
        END IF;
      END;
    endexec.

    EXEC SQL.
      SELECT COUNT(*) from ORG_UNIT into :cnt
    ENDEXEC.

    write: / cnt.

 catch cx_sy_native_sql_error into exc_ref.
    error_text = exc_ref-&amp;gt;get_text( ).
    write: / error_text.

  catch cx_sql_exception into sqlerr_ref.
    perform handle_sql_exception using sqlerr_ref.

endtry.

EXEC SQL.
  disconnect :DBS
ENDEXEC.

*enddo.

*&amp;amp;---------------------------------------------------------------------*
*&amp;amp;      Form  handle_sql_exception
*&amp;amp;---------------------------------------------------------------------*
form handle_sql_exception
  using p_sqlerr_ref type ref to cx_sql_exception.

  format color col_negative.
  if p_sqlerr_ref-&amp;gt;db_error = 'X'.
    write: / 'SQL error occured:', p_sqlerr_ref-&amp;gt;sql_code,
           / p_sqlerr_ref-&amp;gt;sql_message.                     "#EC NOTEXT
  else.
    write:
      / 'Error from DBI (details in dev-trace):',
        p_sqlerr_ref-&amp;gt;internal_error.                       "#EC NOTEXT
  endif.

endform.                    "handle_sql_exception&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;please help to see the words:&lt;/P&gt;&lt;P&gt;&lt;EM&gt;*&lt;STRONG&gt;" If the data 'A' has already exist in database ORG_UNIT, it will show error message&lt;/STRONG&gt;*&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;&lt;EM&gt;*&lt;STRONG&gt;" But if I use :I instead 'A', it will not show error message.&lt;/STRONG&gt;*&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;in the program.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks a lot!&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: hshteld on Jul 1, 2009 2:49 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 01 Jul 2009 00:36:33 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/delete-insert-with-native-sql/m-p/5762490#M1305113</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-07-01T00:36:33Z</dc:date>
    </item>
  </channel>
</rss>

