<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-982209592351846019</id><updated>2011-09-16T22:16:39.093-07:00</updated><title type='text'>App Engine Tips</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://patroranjan.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/982209592351846019/posts/default'/><link rel='alternate' type='text/html' href='http://patroranjan.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Ranjan Patro</name><uri>http://www.blogger.com/profile/03994419899220205739</uri><email>noreply@blogger.com</email></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>2</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-982209592351846019.post-7072539956231124158</id><published>2011-09-13T22:53:00.000-07:00</published><updated>2011-09-13T22:53:35.813-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='NoQuotes'/><title type='text'></title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;Dynamic SQL in App Engine&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;Some time we need to run a dynamic sql in App Enigne.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;Some would prefer creating the entire query in a string and run it in PeopleCode.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;But SQL is much faster than PeoleCode.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;i&gt;How do we achieve this functionality in SQL?&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;We could have an AET record field hold the value and use it in SQL.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;i&gt;How to implement this?&lt;/i&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;We need to push the required condition in the AET record field value and use %SQL and %BIND to implement this.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;/span&gt;&lt;/div&gt;&lt;span style="font-size: small;"&gt;Though your SQL might be complicated, done with many if, else, case, etc,&amp;nbsp; Lets say the SQL is a simple condition.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;If condition Then&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; AET_REC.SQL_FIELD= "AND T1.FLD1 = T2.FLD1 AND T1.FLD2 = T3.FLD2";&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;Else&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;&amp;nbsp;&amp;nbsp; AET_REC.SQL_FIELD.Value = ":&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;End-If; &lt;/span&gt;&lt;/div&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Now in AE Action SQL we can use as follows&lt;/span&gt;&lt;br /&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;UPDATE TBL4&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;SET FLDX = 'VAL'&lt;/span&gt;&lt;/div&gt;&lt;div style="background-color: yellow; font-family: Verdana,sans-serif;"&gt;&lt;span style="font-size: x-small;"&gt;WHERE FLDX IS NULL&lt;/span&gt;&lt;/div&gt;&lt;span style="background-color: yellow; font-family: Verdana,sans-serif; font-size: x-small;"&gt;%SQL(%bind(&lt;/span&gt;&lt;span style="background-color: yellow; font-family: Verdana,sans-serif; font-size: x-small;"&gt;SQL_FIELD&lt;/span&gt;&lt;span style="font-size: small;"&gt;&lt;span style="background-color: yellow; font-size: x-small;"&gt;&lt;span style="font-family: Verdana,sans-serif;"&gt;),&lt;b&gt;NOQUOTES&lt;/b&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;&lt;span style="background-color: yellow; font-size: x-small;"&gt;&lt;span style="font-family: Verdana,sans-serif;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-size: small;"&gt;Why to we need NOQUOTES in my next post...&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/982209592351846019-7072539956231124158?l=patroranjan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://patroranjan.blogspot.com/feeds/7072539956231124158/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://patroranjan.blogspot.com/2011/09/dynamic-sql-in-app-engine-some-time-we.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/982209592351846019/posts/default/7072539956231124158'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/982209592351846019/posts/default/7072539956231124158'/><link rel='alternate' type='text/html' href='http://patroranjan.blogspot.com/2011/09/dynamic-sql-in-app-engine-some-time-we.html' title=''/><author><name>Ranjan Patro</name><uri>http://www.blogger.com/profile/03994419899220205739</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-982209592351846019.post-8846630871416811036</id><published>2011-09-12T22:37:00.000-07:00</published><updated>2011-09-12T22:37:58.949-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='write space in csv'/><category scheme='http://www.blogger.com/atom/ns#' term='write space instead of null in csv'/><category scheme='http://www.blogger.com/atom/ns#' term='UseSpaceForNull'/><category scheme='http://www.blogger.com/atom/ns#' term='Use Space For Null'/><title type='text'></title><content type='html'>&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;b&gt;How to write spaces instead of null into a file while using CSV FileLayout and PeopleCode?&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;It is some times necessary to write spaces instead of nulls into CSV files.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;By default CSV FileLayout writes "" (no content) instead of " " (space) where " is qualifier.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;To avoid this we can use the property UseSpaceForNull.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;Local File &amp;amp;MYFILE;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&amp;amp;MYFILE.SetFileLayout(FileLayout.FileLayoutName);&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&amp;amp;FILE1.UseSpaceForNull = True;&lt;/span&gt;&lt;/pre&gt;&lt;pre style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&amp;nbsp;&lt;/span&gt;&lt;/pre&gt;&lt;pre&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace; font-size: small;"&gt;This is False by default. &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/982209592351846019-8846630871416811036?l=patroranjan.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://patroranjan.blogspot.com/feeds/8846630871416811036/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://patroranjan.blogspot.com/2011/09/how-to-write-spaces-instead-of-null.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/982209592351846019/posts/default/8846630871416811036'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/982209592351846019/posts/default/8846630871416811036'/><link rel='alternate' type='text/html' href='http://patroranjan.blogspot.com/2011/09/how-to-write-spaces-instead-of-null.html' title=''/><author><name>Ranjan Patro</name><uri>http://www.blogger.com/profile/03994419899220205739</uri><email>noreply@blogger.com</email></author><thr:total>0</thr:total></entry></feed>