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"
This is the (pseudo)code:
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;
The problem is just (as always) a missing semicolon.
Just add the missing semicolon on the first SELECT
statement
[...]
SELECT x INTO a FROM t1 WHERE y = 1; #missing semicolon
IF a > 5 THEN
SELECT m, n INTO b ...;
[...]
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With