错误:INTO在“ INTO”附近或附近多次指定。 [英] Error: INTO specified more than once at or near "INTO"

查看:390
本文介绍了错误:INTO在“ INTO”附近或附近多次指定。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在一个postgresql函数中,我试图将从表中选择的两个值转换为两个变量,但出现此错误:

Inside a postgresql function I'm trying to get two values selected from a table into two variables, but I get this error:

INTO specified more than once at or near "INTO"

这是(伪)代码:

CREATE OR REPLACE FUNCTION func() RETURNS TRIGGER AS
$$ 
DECLARE
    a numeric;
    b varchar(20);
    c numeric;
BEGIN
    IF ... THEN
        ...

        SELECT x INTO a FROM t1 WHERE y = 1

        IF a > 5 THEN
            SELECT m, n INTO b, c FROM t2 WHERE ...;
            ...
        END IF;
    END IF;
END
$$ LANGUAGE plpgsql;


推荐答案

...我已经弄清楚了一些几分钟后,问题就是(一如既往)缺少分号。

...and I've figured out a few minutes later that the problem was just (as always) a missing semicolon.

INTO多次指定了错误错误是从第二个 SELECT 语句生成的(当它找到第二个 INTO 时),它并没有太多建议发现问题;所以我决定将其放在此处,因为我没有在网上找到与此错误有关的任何信息。

The INTO specified more than once error is generated from the second SELECT statement (when it finds a second INTO) and it doesn't suggest much about where to find the problem; so I've decided to put it here because I didn't found nothing online about this error.

编辑:

只需在第一个 SELECT 语句

...

    SELECT x INTO a FROM t1 WHERE y = 1; #missing semicolon

    IF a > 5 THEN
        SELECT m, n INTO b ...;
...

这篇关于错误:INTO在“ INTO”附近或附近多次指定。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆