in postresql function we can list table by FOR i IN (SELECT …)
CREATE OR REPLACE FUNCTION f()
RETURNS trigger AS
$BODY$
DECLARE
table_to_row RECORD;
BEGIN
<<for_loop>>
FOR table_to_row IN SELECT id FROM table1
LOOP
//do something
END LOOP for_loop;
RETURN NULL;
END;
$BODY$
LANGUAGE plpgsql VOLATILE
COST 100;
How can we do such thing in Oracle 11g?
I need this part
FOR table_to_row IN SELECT id FROM table1
LOOP
//do something
END LOOP;
In Oracle you do not have to explicitly declare a cursor loop variable. It implicitly will be of
table_name%rowtypedata type.Here is an example:
Demonstration: