23.10.2012 Views

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

Openedge Data Management: SQL Reference - Product ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

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

UPDATE<br />

UPDATE<br />

Syntax<br />

68<br />

Updates the rows and columns of the specified table with the given values for rows that satisfy<br />

the search_condition.<br />

UPDATE table_name<br />

SET assignment [, assignment ] , ...<br />

[ WHERE search_condition ] ;<br />

assignment:<br />

This is the syntax for assignment:<br />

Syntax<br />

column = { expr | NULL }<br />

| ( column [, column ] , ... ) = ( expr [, expr ] )<br />

| ( column [, column ] , ... ) = ( query_expression )<br />

Notes • If you specify the optional WHERE clause, only rows that satisfy the search_condition are<br />

updated. If you do not specify a WHERE clause, all rows of the table are updated.<br />

• If the expressions in the SET clause are dependent on the columns of the target table, the<br />

expressions are evaluated for each row of the table.<br />

• If a query expression is specified on the right-hand side of an assignment, the number of<br />

expressions in the first SELECT clause of the query expression must be the same as the<br />

number of columns listed on the left-hand side of the assignment.<br />

• If a query expression is specified on the right-hand side of an assignment, the query<br />

expression must return one row.<br />

• If a table has check constraints and if the columns to be updated are part of a check<br />

expression, then the check expression is evaluated. If the result of the evaluation is FALSE,<br />

the UPDATE statement fails.<br />

• If a table has primary or candidate keys and if the columns to be updated are part of the<br />

primary or candidate key, <strong>SQL</strong> checks to determine if there is a corresponding row in the<br />

referencing table. If there is a corresponding row the UPDATE operation fails.<br />

• Column names in the SET clause do not need a table_name qualifier. Since an UPDATE<br />

statement affects a single table, columns in the SET clause are implicitly qualified to the<br />

table_name identified in the UPDATE clause.<br />

The following is an example of an UPDATE statement:

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

Saved successfully!

Ooh no, something went wrong!