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"><<a href="mailto:james@jamesh.id.au">james@jamesh.id.au</a>></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<<a href="mailto:edujurista@gmail.com">edujurista@gmail.com</a>> wrote:<br>
> Did I say something wrong or stupid?<br>
<br>
</div>Nope. No one got round to answering the question though :( I'll<br>
rectify that now.<br>
<div class="im"><br>
><br>
> 2009/9/9 Eduardo Willians <<a href="mailto:edujurista@gmail.com">edujurista@gmail.com</a>>:<br>
>> Is there a stormic way to execute the following SQL statement?<br>
>><br>
>> store.execute("""SELECT MAX(id) FROM gear.op WHERE CAST(id AS<br>
>> character) LIKE '9%';""").get_one()<br>
>><br>
>> I'm using postgres.<br>
<br>
</div>There isn't anything in Storm to generate the WHERE clause you'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("CAST(<a href="http://gear.op.id" target="_blank">gear.op.id</a> AS character) LIKE '9%'"))<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't give you the<br>
"auto tables" behaviour where Storm guesses what tables need to be<br>
used for a given query. It wasn'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 "auto tables" behaviour in other cases, you<br>
can manually specify what tables the expression uses. Something like:<br>
<br>
SQL("...", 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' 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>