oracle PL/pgSQL 中 PL/SQL %NOTFOUND 的等价物是什么?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3873514/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 21:39:28  来源:igfitidea点击:

What is the equivalent of PL/SQL %NOTFOUND in PL/pgSQL?

oraclepostgresqlplsqlcursorplpgsql

提问by Spredzy

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 ?

当没有更多行时,PostgreSQL 下 %NOTFOUND 的等价物是什么?

Edit

编辑

Or the other cursors attributes %ISOPEN, %EMPTY, etc...

或者其他游标属性 %ISOPEN、%EMPTY 等...

回答by Kuberchaun

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

现在无法测试这个,但是如果你尝试这个怎么办?查看章节标题 37.7.3.2。在此链接退出 http://www.postgresql.org/docs/8.2/static/plpgsql-control-structures.html

IF NOT FOUND THEN
    EXIT;
END IF;

OR

或者

EXIT WHEN NOT FOUND;

回答by TTMAN

The FOUNDvariable

FOUND变量

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;