Dear Vadim,

IMHO, it should go in the implementation and should not be visible to the
SOCI user. Whether you implement it using templates or virtuals, the
optimization should be automatically selected at compile-time or run-time.
I mean, when DB is DB2 then compiler selects template specialization
related to DB2 and when DB is Oracle then Oracle-specific specialization
gets selected resulting in generation of code doing both steps in a single
trip. If this cannot be done then, IMHO, the feature should be incorporated
as a back-end-specific feature only and should also be documented in those
back-ends' documentation so that the user can take advantage of it when
using those back-ends.

BR / Asif

On 10 June 2015 at 17:41, Vadim Zeitlin <vz-s...@zeitlins.org> wrote:

>  Hello,
>
>  Several RDBMS provide a way to update a row[0] and retrieve the values
> from the same row in a single query. This is much better than issuing one
> UPDATE and one SELECT if only because you save a round-trip to the database
> server, which can carry a pretty significant cost when using a remote
> database. The trouble is that the way they do it is not the same, I've
> tried summarizing what I could find in the respective manuals at
>
>
> https://en.wikibooks.org/wiki/SQL_Dialects_Reference/Write_queries/Update_returning
>
> and, as you can see, while all rows in this table are similar, no two of
> them are identical (DB2 and Oracle use the same syntax but I'm not sure
> about Oracle semantics, I'll have to test whether it returns the old or new
> values).
>
>
>  So I'm thinking about wrapping support for this functionality in SOCI to
> make it simpler to use. The questions are:
>
> 0. Do you agree that this would be useful? Or, IOW, does anybody object to
>    including this in SOCI?
>
> 1. What form should the API take? I am thinking of adding
>    statement::add_returning_clause(expressions, parameters) but I'm not
>    sure if I like it very much. Any better suggestions?
>
> 2. What to do for the backends that don't support this (MySQL, SQLite,
>    ODBC)? I'm tempted to just return false from add_returning_clause()
>    to let people handle fallback in their own code but this feels a little
>    like a cop out. OTOH silently implementing this as UPDATE+SELECT doesn't
>    seem like a good idea neither.
>
> 3. Last but not least: does anybody here have any experience using this SQL
>    construct? Any hints/things to look out for?
>
>  Thanks in advance,
> VZ
>
> [0] In some of them this works even for multiple rows, but let's keep
>     things simple for now.
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> soci-users mailing list
> soci-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/soci-users
>
>


-- 
Best regards,

-Asif
------------------------------------------------------------------------------
_______________________________________________
soci-users mailing list
soci-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/soci-users

Reply via email to