SQLite Forum

INSERT INTO ... RETURNING
Login

INSERT INTO ... RETURNING

(1) By ddevienne on 2021-09-15 07:44:49

Hi. Does 3.4 from [RETURNING](https://www.sqlite.org/lang_returning.html) apply even to *multi-row* inserts?

I mean, surely the literal row values will be processed in order, no?  
I can understand 3.4 for other DMLs, but in that particular case, isn't it *special*?  
The non-scientific example below supports that, but that's not saying much :)

Otherwise I'll have to also return something identifying the row from one of the inputs,  
to know which row the ID was assigned to, and maintain a mapping in the calling code.

Just want to be 100% clear on this. Thanks, --DD

```
C:\Users\ddevienne>sqlite3
SQLite version 3.36.0 2021-06-18 18:36:39
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
sqlite> create table t(id integer primary key, name text UNIQUE);
sqlite> insert into t (name) values ('one') returning id;
1
sqlite> insert into t (name) values ('two'), ('three') returning id;
2
3
sqlite> insert into t (name) values ('four'), ('five') returning id, name;
4|four
5|five
sqlite>
```