[sr-dev] SQLOPS / sql_xquery & $dbr(result=>rows)
Alex Hermann
alex at speakup.nl
Fri Nov 30 09:58:17 CET 2012
On Monday 26 November 2012 21:29:10 Brandon Armstead wrote:
> Is there any reason to use sql_xquery vs sql_query?
>
> Looking through the source it seems they both now handle the same or
> similar data types?
It's not about datatypes, its about how you access the results.
sql_query() returns a resultset which can only be accessed by row and column
_numbers_. Further, the resultset is gone after processing the message.
sql_qxuery() stores the resultset in named xavp's. The columns can be accessed
by _name_. Because the resultset is in xavp's, it is stored in the transaction
and can be (re)used in onreply_route and failure_route.
To be complete, there is also sql_pvquery(), which is like avp_db_query() on
steroids. It allows the results to be assigned to arbitrary PV's instead of
just avp's.
Which one you use depends on your use-case.
--
Alex Hermann
More information about the sr-dev
mailing list