Quick Search:
 
 The Oracle CURRENT Keyword      [Return To Index] Jump to:  

Term: CURRENT

Definition:
The Oracle CURRENT Keyword is used in the WHERE CURRENT OF clause in an UPDATE or DELETE statement. This statement causes the most recent row retrieved from the table to be updated or deleted. The CURSOR must be declared with the FOR UPDATE clause to use the WHERE CURRENT OF feature.

WHERE (CURRENT OF cursor_name | search_expression);


This example goes through all of the prices in the Items table and sets prices under 10.00 to 10.00:

DECLARE
thisPrice Price%ROWTYPE;

CURSOR The_Price IS
SELECT * FROM Items
FOR UPDATE;

BEGIN
OPEN The_Price;
LOOP
FETCH The_Price INTO thisPrice;
EXIT WHEN (The_Price%NOTFOUND);
IF (The_Price.price < 10.00) THEN
UPDATE Items SET price = 10.00
WHERE CURRENT OF The_Price;
END IF;
END LOOP;

CLOSE The_Price;
END;


Related Code Snippets:
 
   Home |    Search |    Code Library |    Sponsors |    Privacy |    Terms of Use |    Contact Us © 2003 - 2024 psoug.org