Hello
2011/6/18 David Fetter <dfetter@vmware.com>:
>
> The following bug has been logged online:
>
> Bug reference: =C2=A0 =C2=A0 =C2=A06067
> Logged by: =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0David Fetter
> Email address: =C2=A0 =C2=A0 =C2=A0dfetter@vmware.com
> PostgreSQL version: 9.0.4
> Operating system: =C2=A0 Linux
> Description: =C2=A0 =C2=A0 =C2=A0 =C2=A0In PL/pgsql, EXISTS(SELECT ... IN=
TO...) fails
> Details:
>
> Here's some example code that reproduces the problem:
>
> CREATE OR REPLACE FUNCTION foo()
> RETURNS void
> LANGUAGE plpgsql
> AS $$
> DECLARE
> =C2=A0 =C2=A0i int;
> BEGIN
> =C2=A0 =C2=A0IF EXISTS (SELECT 1 INTO STRICT i) THEN
> =C2=A0 =C2=A0 =C2=A0 =C2=A0RAISE NOTICE '%', a;
> =C2=A0 =C2=A0END IF;
> =C2=A0 =C2=A0RETURN;
> END;
> $$;
> ERROR: =C2=A0syntax error at or near "i"
> LINE 8: =C2=A0 =C2=A0 IF EXISTS (SELECT 1 INTO STRICT i) THEN
You cannot to use PLpgSQL's addition "INTO" inside SQL statement. This
is not bug. INTO and STRICT are not SQL keywords, so they cannot be
used inside SQL expression.
Regards
Pavel Stehule
> =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=
=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =
=C2=A0^
>
> This came up in a case where there was an IF block that checked some
> conditions before checking whether there was a row. =C2=A0If it found a r=
ow, it
> was supposed to use it in an EXCEPTION. =C2=A0Instead, I had to do the qu=
ery
> unconditionally, check the FOUND block in a separate nested IF statement,
> and generally uglify the code.
>
> Not everybody in IRC agreed that this is a bug, though.
>
> --
> Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-bugs
>