On Fri, Jun 8, 2018 at 5:25 AM Rowan Worth <row...@dug.com> wrote:

> On 3 June 2018 at 07:28, Scott Robison <sc...@casaderobison.com> wrote:
>
> > I've encountered a feature that I think would be awesome:
> > https://www.postgresql.org/docs/9.3/static/dml-returning.html
> >
> > Example: INSERT INTO blah (this, that, another) VALUES (x, y, z)
> RETURNING id;
>
> > my thoughts are just that this could greatly simplify a lot of sql
> > code that currently has to prepare and execute at least two statements
> > to accomplish what is conceptually an atomic task.
> >
>
> For most use cases you only need a single query:
>
>     if (sqlite3_exec(db, "INSERT INTO blah (this, that, another) VALUES
> (x,y, z)") == SQLITE_OK) {
>         long id = sqlite3_last_insert_rowid(db);
>         ...
>     }


{{RETURNING c1, c2, ... INTO :1, :2, ...} also exists in Oracle
(nightmares, really? :) In OCI, you do an out-bind for those),
and another use case is returning the LOB locator for incrementally writing
the blob content (after inserting empty_blob()).
The equivalent in SQLite is zeroblob(N) on insert, then
sqlit3_blob_open(db, tab, col, rowid), and _write(, N), and _close(). --DD
_______________________________________________
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to