<?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: Native SQL Update statement error when more than one field used in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699357#M625041</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What database are you using? MSSQL?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Tue, 28 Aug 2007 20:09:53 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-08-28T20:09:53Z</dc:date>
    <item>
      <title>Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699356#M625040</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, I would make it simple. I update directly to a SQL server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;1-&lt;/P&gt;&lt;P&gt;When I update only one field works.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT IT_MAT.
 EXEC SQL.
 UPDATE Articulos SET PrecioSinImp = :IT_MAT-PRECIOSINIMP        WHERE Modelo = :IT_MAT-MODELO 
 ENDEXEC.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;This give me sy-subrc = 0&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;When I Try to update several fields doesnt works, any would can help me ?.&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
LOOP AT IT_MAT.
 EXEC SQL.
  UPDATE Articulos SET PrecioSinImp = :IT_MAT-PRECIOSINIMP
                       Descripcion = :IT_MAT-DESCRIPCION
  WHERE Modelo = :IT_MAT-MODELO 
 ENDEXEC.
ENDLOOP.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This give me dump SQL error 170.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;2- BTW, I have to leave this report program in a job so the data would be updated once a day in a job, so I have to update the existing data and add new one.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I Was thinking doing something like this.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_table.&lt;/P&gt;&lt;P&gt;UPDATE DQL TABLE&lt;/P&gt;&lt;P&gt;IF sy-subrc &amp;lt;&amp;gt; 0.&lt;/P&gt;&lt;P&gt;INSERT DQL TABLE&lt;/P&gt;&lt;P&gt;ENDIF.&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This may works ??? because if this not work, I have to select single each one of the data in the SQL table, if it was founded UPDATE otherwise INSERT. And I dont like this aproach.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2007 19:42:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699356#M625040</guid>
      <dc:creator>Rodrigo-Giner</dc:creator>
      <dc:date>2007-08-28T19:42:38Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699357#M625041</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;What database are you using? MSSQL?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2007 20:09:53 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699357#M625041</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-28T20:09:53Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699358#M625042</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Rodrigo,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I feel that your requirement is as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Depending on the criteria in the where clause, check whether the record exists or not.. If it does, then update the record with new values, else, create a new record..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can do the same as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;LOOP AT it_mat INTO e_mat. (e_mat of same structure as it_mat)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MOVE : xxx TO e_mat-yyy... and so on (Only change the non-key values)&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;MODIFY dbtable FROM e_mat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;ENDLOOP.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;This code will create a new record if a record with the given key values in e_mat is not found, else, it will update the existing record with the new non-key values in the structure e_mat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks and Best Regards,&lt;/P&gt;&lt;P&gt;Vikas Bittera.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;&amp;lt;REMOVED BY MODERATOR&amp;gt;&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Message was edited by: &lt;/P&gt;&lt;P&gt;        Alvaro Tejada Galindo&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Tue, 28 Aug 2007 22:12:30 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699358#M625042</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-28T22:12:30Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699359#M625043</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi, Vikas. The thing is that I have to do this using Native SQL, not with OPEN SQL.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And yes Rob, Im using a SQL server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What I need is the Exact syntax for the UPDATE statement using Native SQL with a SQL server.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thx&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 12:39:32 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699359#M625043</guid>
      <dc:creator>Rodrigo-Giner</dc:creator>
      <dc:date>2007-08-29T12:39:32Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699360#M625044</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Native SQL is dependent on your database, not ABAP, so I would find an MS SQL forum and ask your question there (or better yet, find an MS SQL manual).&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 13:37:13 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699360#M625044</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T13:37:13Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699361#M625045</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi Rob, I have found the syntax.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&amp;lt;b&amp;gt;Update several Columns in a Row&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;We want to change the address and add the name of the city:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE Person&lt;/P&gt;&lt;P&gt;SET Address = 'Stien 12', City = 'Stavanger'&lt;/P&gt;&lt;P&gt;WHERE LastName = 'Rasmussen'&amp;lt;/b&amp;gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;each field is separated by "," but doesnt work either, now it throw me a dump with "SQL error 156".&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;any ideas ?&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 14:24:58 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699361#M625045</guid>
      <dc:creator>Rodrigo-Giner</dc:creator>
      <dc:date>2007-08-29T14:24:58Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699362#M625046</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Same as before - it should be in the manual.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Rob&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 15:05:06 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699362#M625046</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-08-29T15:05:06Z</dc:date>
    </item>
    <item>
      <title>Re: Native SQL Update statement error when more than one field used</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699363#M625047</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I was doing something wrong&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE Person&lt;/P&gt;&lt;P&gt;SET Address = 'Stien 12', City = 'Stavanger',&lt;/P&gt;&lt;P&gt;WHERE LastName = 'Rasmussen'&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Instead of -_-&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;UPDATE Person&lt;/P&gt;&lt;P&gt;SET Address = 'Stien 12', City = 'Stavanger'&lt;/P&gt;&lt;P&gt;WHERE LastName = 'Rasmussen'&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 29 Aug 2007 18:09:05 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/native-sql-update-statement-error-when-more-than-one-field-used/m-p/2699363#M625047</guid>
      <dc:creator>Rodrigo-Giner</dc:creator>
      <dc:date>2007-08-29T18:09:05Z</dc:date>
    </item>
  </channel>
</rss>

