21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

DML statements<br />

Description: A DELETE statement removing at most one row may optionally include a RETURNING clause in<br />

order to return values from the deleted row. The clause, if present, need not contain all of the relation's columns<br />

and may also contain other columns or expressions.<br />

Examples:<br />

Notes:<br />

delete from Scholars<br />

where firstname = 'Henry' and lastname = 'Higgins'<br />

returning lastname, fullname, id<br />

delete from Dumbbells<br />

order by iq desc<br />

rows 1<br />

returning lastname, iq into :lname, :iq;<br />

• In DSQL, a statement with a RETURNING clause always returns exactly one row. If no record was actually<br />

deleted, the fields in this row are all NULL. This behaviour may change in a later version of <strong>Firebird</strong>. In PSQL,<br />

if no row was deleted, nothing is returned, and the receiving variables keep their existing values.<br />

ROWS<br />

Available in: DSQL, PSQL<br />

Added in: 2.0<br />

Description: Limits the amount of rows deleted to a specified number or range.<br />

Syntax:<br />

ROWS [TO ]<br />

, ::= Any expression evaluating to an integer.<br />

With a single argument m, the deletion is limited to the first m rows of the dataset defined by the table or view<br />

and the optional WHERE and ORDER BY clauses.<br />

Points to note:<br />

• If m > the total number of rows in the dataset, the entire set is deleted.<br />

• If m = 0, no rows are deleted.<br />

• If m < 0, an error is raised.<br />

With two arguments m and n, the deletion is limited to rows m to n inclusively. Row numbers are 1-based.<br />

Points to note when using two arguments:<br />

• If m > the total number of rows in the dataset, no rows are deleted.<br />

• If m lies within the set but n doesn't, the rows from m to the end of the set are deleted.<br />

• If m < 1 or n < 1, an error is raised.<br />

• If n = m-1, no rows are deleted.<br />

• If n < m-1, an error is raised.<br />

58

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!