Quick Search:
CODE
Oracle PL/SQL Code Library
JOBS
Find Or Post Oracle Jobs
FORUM
Oracle Discussion & Chat
 The Oracle CURRENT Keyword      [Return To Index] Jump to:  
  Looking for the original pages? (formerly called "Morgan's Library") You can find them here.

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      :      Code Library      :      Sponsors      :      Privacy      :      Terms of Use      :      Contact Us 58 users online    © 2009 psoug.org
PSOUG LOGIN
Username: 
Password: 
Forgot your password?