<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://inaplex.com/cs/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Knowledge Base</title><link>http://inaplex.com/cs/forums/13.aspx</link><description>Detailed answers for common issues.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Updating source database during an import</title><link>http://inaplex.com/cs/forums/thread/158.aspx</link><pubDate>Fri, 31 Oct 2008 19:06:59 GMT</pubDate><guid isPermaLink="false">0bcc6b5f-b0ab-407f-89a4-9cdcea95353a:158</guid><dc:creator>admin</dc:creator><slash:comments>0</slash:comments><comments>http://inaplex.com/cs/forums/thread/158.aspx</comments><wfw:commentRss>http://inaplex.com/cs/forums/commentrss.aspx?SectionID=13&amp;PostID=158</wfw:commentRss><description>&lt;p&gt;Occassionally, it is necessary to update the source or target&amp;nbsp;database during an import operation. For example, it may be necessary to flag a source record as processed. Inaport supports this using the &amp;quot;dbexecupdate()&amp;quot; function, that allows you to perform an arbitrary SQL UPDATE statement against either the source or the target database.&lt;/p&gt;
&lt;p&gt;The general format of the function is:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;dbexecupdate(&amp;quot;S&amp;quot; or &amp;quot;T&amp;quot;, &amp;quot;UPDATE table SET field = &amp;#39;value&amp;#39; WHERE key = &amp;#39;keyvalue&amp;#39;&amp;quot;)&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;The &amp;quot;S&amp;quot; or &amp;quot;T&amp;quot; specifies the source or target database respectively.&lt;/p&gt;
&lt;p&gt;The second parameter is a string that needs to resolve to a legal SQL UPDATE statement for the database. The string can be built up using stanard inaport expressions. For example, if the time is 10:22:34 and the field keyfield has the value &amp;quot;aa123&amp;quot;, then the string:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;dbexecupdate(&amp;quot;S&amp;quot;, &amp;quot;UPDATE table SET field = &amp;#39;&amp;quot; &amp;amp; nowstr(&amp;quot;HH:mm:ss&amp;quot;) &amp;amp; &amp;quot;&amp;#39; WHERE key = &amp;#39;&amp;quot; &amp;amp; #keyfield &amp;amp; &amp;quot;&amp;#39;&amp;quot;)&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;will produce a SQL UPDATE that looks like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;&amp;quot;UPDATE table SET field = &amp;#39;10:22:34&amp;#39; WHERE key = &amp;#39;aa123&amp;#39;&amp;quot;&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;
&lt;p&gt;&lt;strong&gt;NOTE&lt;/strong&gt;: It is important to note the sequence of single and double quotes. There are two things going on:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;div&gt;The single quotes need to be positioned to produce legal SQL&lt;/div&gt;&lt;/li&gt;
&lt;li&gt;
&lt;div&gt;The double quotes are marking the boundaries of strings that are joined together by the expression evaluator to produce the SQL.&lt;/div&gt;&lt;/li&gt;&lt;/ol&gt;
&lt;p&gt;So the piece of text:&amp;nbsp; key = &amp;#39;&amp;quot; &amp;amp; #keyfield &amp;amp; &amp;quot;&amp;#39;&amp;quot; &lt;br /&gt;is really:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; key = SQ DQ &amp;amp; #keyfield &amp;amp; DQ SQ DQ&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;NOTE FOR EXCEL&lt;/strong&gt;: Excel requires that the worksheet name end in &amp;quot;$&amp;quot;, and be surrounded by the &amp;quot;`&amp;quot; character - this is NOT a single quote. So the above example for Excel would be:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;dbexecupdate(&amp;quot;S&amp;quot;, &amp;quot;UPDATE `table$` SET field = &amp;#39;&amp;quot; &amp;amp; nowstr(&amp;quot;HH:mm:ss&amp;quot;) &amp;amp; &amp;quot;&amp;#39; WHERE key = &amp;#39;&amp;quot; &amp;amp; #keyfield &amp;amp; &amp;quot;&amp;#39;&amp;quot;)&lt;/strong&gt;&lt;/p&gt;&lt;/blockquote&gt;</description></item></channel></rss>