<?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: Inserting a duplicate row in SQL table not giving any exception in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724037#M1580373</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Forget the secondary key...that's meaningless in this case.... if your values duplicate an entry of the entire primary key you should indeed get an error....are you supplying exact duplicate values, including client/mandt?  Probably not....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suggest you provide forum with primary key details, your data values and your code, if unable to resolve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Mon, 14 Mar 2011 13:36:08 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-03-14T13:36:08Z</dc:date>
    <item>
      <title>Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724035#M1580371</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I am inserting into an SQL table through my abap program. If i try to insert any duplicate entries into SQL table ideally it should give "Violation of PRIMARY KEY constraint" error. But my program is ending with sy-subrc = 0. I have placed the insert statement inside the try catch block. Please help me solve this problem.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Devaiah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2011 13:03:48 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724035#M1580371</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-14T13:03:48Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724036#M1580372</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;Which table ru trying to insert duplicate rows? there might be a possibility tht u might hve define secondary indexes and it is taking precedence over ur primary indexes.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please chk in SE11 wht r ur primary keys nd wht r ur secondary keys?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also if possibel try to provide the exact data which ur tring to insert.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anil N.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;SPAN __default_attr="red" __jive_macro_name="color"&gt;Moderator message: check your keyboard or fingers, please do not use SMS speak.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Thomas Zloch on Mar 14, 2011 3:30 PM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2011 13:20:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724036#M1580372</guid>
      <dc:creator>former_member438956</dc:creator>
      <dc:date>2011-03-14T13:20:08Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724037#M1580373</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Forget the secondary key...that's meaningless in this case.... if your values duplicate an entry of the entire primary key you should indeed get an error....are you supplying exact duplicate values, including client/mandt?  Probably not....&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Suggest you provide forum with primary key details, your data values and your code, if unable to resolve.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2011 13:36:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724037#M1580373</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-14T13:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724038#M1580374</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;Is there really a primary key on that table? Not only being defined but existing in the database? Are the inserted lines really duplicates (client? some kind of timestamp?) and are they really written to the database? I&lt;/P&gt;&lt;P&gt;If a primary key is existing on the database and the database is still accepting duplicate entries without an error message you are facing a severe database issue. But this kind of issues are quite rare, so I would check first if this is really the case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;/Jan&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2011 14:32:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724038#M1580374</guid>
      <dc:creator>JanStallkamp</dc:creator>
      <dc:date>2011-03-14T14:32:41Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724039#M1580375</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Devaiah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This is a real F1 question. Please put cursor on INSERT staement in the program and press F1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You will get a SY-SUBRC = 4 if the record is not inserted because it already exists in the database. This is not an Exception.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Probably the program will contnue to process other statements that result in SY-SUBRC = 0.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The TRY .. CATCH Block is completelly useless in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;If you insert FROM TABLE &amp;lt;itab&amp;gt; then you will get an exception that may be caught or causes a dump if not caught. Here the addition ACCEPTING DUPLICATE KEYS will prevent the exception and also give a SY-SUBRC = 4. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Clemens&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 14 Mar 2011 14:53:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724039#M1580375</guid>
      <dc:creator>Clemenss</dc:creator>
      <dc:date>2011-03-14T14:53:08Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724040#M1580376</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi all,&lt;/P&gt;&lt;P&gt;Thank you all for your reply.&lt;/P&gt;&lt;P&gt;I am trying to insert into a MS SQL table through DBCON. I am really sorry as i forgot to mention this.&lt;/P&gt;&lt;P&gt;I am using the following code.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
try.
    EXEC SQL
        insert into TABLENAME
         ( 
           COLUMN1
           COLUMN2
         )
           VALUES
         (
            :VALUE1
            :VALUE2
          )  

    ENDEXEC.
catch cx_sy_native_sql_error into gv_oref.
   gv_txterror = gv_oref-&amp;gt;get_text( ). 
   message gv_txterror type 'I'.
endtry.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I know that one of the option is to put a select query and check if the entry exists, but it will lead to serious performance&lt;/P&gt;&lt;P&gt;issue as the number are entries to be inserted are very high. We will be running this in the background, so if any error comes i want to show to the user in the log. Right now its not inserting the duplicate row, only problem is its not giving any kind of error. Please help me with this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Devaiah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2011 05:06:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724040#M1580376</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-15T05:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724041#M1580377</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Try to raise exception on MS SQL level like this:&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
try.
    EXEC SQL
      begin try
        insert into TABLENAME ...
      end try
      begin catch
         raiserror('insert failed',11,1)
      end catch
    ENDEXEC.
catch cx_sy_native_sql_error into gv_oref.
   gv_txterror = gv_oref-&amp;gt;get_text( ). 
   message gv_txterror type 'I'.
endtry.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This way the caller will be informed about insertion error.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2011 07:45:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724041#M1580377</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-15T07:45:09Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724042#M1580378</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hello Devaiah,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I would ask you to take a look at ADBC classes CL_SQL* in this case.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;The method EXECUTE_UPDATE of class CL_SQL_PREPARED_STATEMENT propagates the exceptions CX_SQL_EXCEPTION &amp;amp; &lt;/P&gt;&lt;P&gt;CX_PARAMETER_INVALID.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I think you can make use of these exception objects to log the errors, if any. You can refer to the program ADBC_DEMO to know how the ADBC classes have been implemented.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;BR,&lt;/P&gt;&lt;P&gt;Suhas&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2011 08:33:08 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724042#M1580378</guid>
      <dc:creator>SuhaSaha</dc:creator>
      <dc:date>2011-03-15T08:33:08Z</dc:date>
    </item>
    <item>
      <title>Re: Inserting a duplicate row in SQL table not giving any exception</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724043#M1580379</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Kovalev,&lt;/P&gt;&lt;P&gt;Thank you for your reply. I did as you said and it worked perfectly.&lt;/P&gt;&lt;P&gt;Awarded you with full points.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Once again thank you all for your inputs.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Devaiah&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 15 Mar 2011 08:45:54 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/inserting-a-duplicate-row-in-sql-table-not-giving-any-exception/m-p/7724043#M1580379</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-03-15T08:45:54Z</dc:date>
    </item>
  </channel>
</rss>

