I am trying to update multiple rows in a PLSQL block. Is it possible to update several rows with a single UPDATE statement.
For example, could I use the following code:
UPDATE ORDERTABLE
SET COST = 400 AND SHIPPING = 8, AND TAX = .06;
Is this acceptable?
The syntax of your update is wrong. But it is possible to update more than one row with one statement.
UPDATE ordertable SET
cost = 400, shipping = 8, tax = .06;
This will update all rows in table ordertable. Add some restrictions to change only some rows.
UPDATE ordertable SET
cost = 400, shipping = 8, tax = .06
WHERE cost < 100 OR shipping >9;
Most tools report rows updated as output or feedback. You can check which rows are updated prior running the update, by using the restriction in a select statement.
SELECT * FROM ordertable
WHERE cost < 100 OR shipping >9;
More than one rows cant be updated in a single update statement. Once the update statement is executed you will get output as
n Rows Updated
where n -is the no of rows for which the update statement is executed successfully.
Below code update all the rows of the table
UPDATE ORDERTABLE
SET COST = 400,
SHIPPING = 8,
TAX = .06;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.