This question and answer seem like a good candidate to add to the FAQ...<br><br><div class="gmail_quote">On Mon, Sep 14, 2009 at 8:45 PM, James Henstridge <span dir="ltr">&lt;<a href="mailto:james@jamesh.id.au">james@jamesh.id.au</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"><div class="im">On Mon, Sep 14, 2009 at 7:16 PM, Eduardo Willians&lt;<a href="mailto:edujurista@gmail.com">edujurista@gmail.com</a>&gt; wrote:<br>

&gt; Did I say something wrong or stupid?<br>
<br>
</div>Nope. No one got round to answering the question though :(  I&#39;ll<br>
rectify that now.<br>
<div class="im"><br>
&gt;<br>
&gt; 2009/9/9 Eduardo Willians &lt;<a href="mailto:edujurista@gmail.com">edujurista@gmail.com</a>&gt;:<br>
&gt;&gt; Is there a stormic way to execute the following SQL statement?<br>
&gt;&gt;<br>
&gt;&gt; store.execute(&quot;&quot;&quot;SELECT MAX(id) FROM gear.op WHERE CAST(id AS<br>
&gt;&gt; character) LIKE &#39;9%&#39;;&quot;&quot;&quot;).get_one()<br>
&gt;&gt;<br>
&gt;&gt; I&#39;m using postgres.<br>
<br>
</div>There isn&#39;t anything in Storm to generate the WHERE clause you&#39;ve used<br>
here.  However, you can insert arbitrary SQL into an expression using<br>
the SQL() operator.  Something like this:<br>
<br>
    result = store.find(GearOp, SQL(&quot;CAST(<a href="http://gear.op.id" target="_blank">gear.op.id</a> AS character) LIKE &#39;9%&#39;&quot;))<br>
    maximum = result.max(GearOp.id)<br>
<br>
You can combine SQL() with other Storm expression objects in pretty<br>
much any situation.  The one downside is that they won&#39;t give you the<br>
&quot;auto tables&quot; behaviour where Storm guesses what tables need to be<br>
used for a given query.  It wasn&#39;t required in the above, because the<br>
table used in the SQL() expression is already referenced.<br>
<br>
If you want to keep the &quot;auto tables&quot; behaviour in other cases, you<br>
can manually specify what tables the expression uses.  Something like:<br>
<br>
    SQL(&quot;...&quot;, tables=[GearOp])<br>
<br>
I hope this helps,<br>
<font color="#888888"><br>
James.<br>
</font><div><div></div><div class="h5"><br>
--<br>
storm mailing list<br>
<a href="mailto:storm@lists.canonical.com">storm@lists.canonical.com</a><br>
Modify settings or unsubscribe at: <a href="https://lists.ubuntu.com/mailman/listinfo/storm" target="_blank">https://lists.ubuntu.com/mailman/listinfo/storm</a><br>
</div></div></blockquote></div><br><br clear="all"><br>-- <br>ZeOmega<br>Open Minds&#39; Open Solutions<br>3010 Gaylord Parkway, Ste. 210<br>Frisco TX, 75034<br><a href="http://www.zeomega.com">http://www.zeomega.com</a><br>
<br>Brad Allen<br>214-618-9880 (ext. 8006)<br>