Everything's in the title.
I am Looping on a cursor and would like to have the
EXIT WHEN curs%NOTFOUND
when there is no more row, what is the equivalent of %NOTFOUND under PostgreSQL ?
Edit
Or the other开发者_高级运维 cursors attributes %ISOPEN, %EMPTY, etc...
Can't test this right now but what if you try this? Check out section title 37.7.3.2. EXIT at this link http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html
IF NOT FOUND THEN
EXIT;
END IF;
OR
EXIT WHEN NOT FOUND;
The FOUND variable
Implicit cursor
SELECT * INTO myrec FROM emp WHERE empname = myname;
IF NOT FOUND THEN
RAISE EXCEPTION 'employee % not found', myname;
END IF;
With an explicit cursor
...
LOOP
FETCH cursor INTO whatever;
EXIT IF NOT FOUND;
do something with whatever
end LOOP;
精彩评论