![]() Thus, inspecting columns computed by triggers is another common use-case for RETURNING. If there are triggers ( Chapter 39) on the target table, the data available to RETURNING is the row as modified by the triggers. In a DELETE, the data available to RETURNING is the content of the deleted row. Returns the ROWID of the last row INSERT in the database for the current. In an UPDATE, the data available to RETURNING is the new content of the modified row. ![]() The RETURNING clause is also very useful with INSERT. INSERT INTO users (firstname, lastname) VALUES ('Joe', 'Cool') RETURNING id If no rows have been inserted since the database connection was opened, this function. For example, when using a serial column to provide unique identifiers, RETURNING can return the ID assigned to a new row:ĬREATE TABLE users (firstname text, lastname text, id serial primary key) This function returns the ROWID of the last successfully inserted row. But it can be very handy when relying on computed default values. This is not so useful in trivial inserts, since it would just repeat the data provided by the client. /rebates/&.com252flibrary252fview252fusing-sqlite252f9781449394592252fre284. In an INSERT, the data available to RETURNING is the row as it was inserted. A common shorthand is RETURNING *, which selects all columns of the target table in order. lastinsertrowid() returns the ROWID for the last insert operation on this connection. ![]() It can contain column names of the command's target table, or value expressions using those columns. The allowed contents of a RETURNING clause are the same as a SELECT command's output list (see Section 7.3). Use of RETURNING avoids performing an extra database query to collect the data, and is especially valuable when it would otherwise be difficult to identify the modified rows reliably. The INSERT, UPDATE, and DELETE commands all have an optional RETURNING clause that supports this. Sometimes it is useful to obtain data from modified rows while they are being manipulated. Since version 3.35.0 (), SQLite supports the RETURNING clause, which allows you to return a result row (or specific columns) for each modified database row by a DELETE, UPDATE or INSERT statement.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |