On Mon, Jun 17, 2013 at 11:11 PM, Stefan Drees wrote:
>
> pg924=# SELECT CASE WHEN 1 != 1 THEN 1/0 ELSE ((SELECT 1)=1)::integer END;
> case
> --
> 1
> (1 row)
>
> here the 1/0 is happily ignored.
>
It gets even stranger:
template1=# SELECT CASE WHEN (SELECT 0)=0 THEN 0 ELSE 1/(select
ny subexpressions that are not needed
to determine the result."
Did I miss anything? Or is this really a bug?
Thanks,
Andrea Lombardoni
> You need to use EXECUTE for the INSERT statement as well per error:
>
> CONTEXT: SQL statement "INSERT INTO idmap (oldid, type, newid) VALUES(1,
> 1, 1)" PL/pgSQL function "test" line 16 at SQL statement
Thanks, this works and solves my problem.
Still, I find this behaviour to be rather quirk
>> Am I doing something wrong or is this a bug?
>
> The plan is cached, to avoid this problem, use dynamic SQL. In your
> case:
>
> EXECUTE 'CREATE TEMPORARY TABLE idmap ...'
Nice idea, but the problem persists, see log below.
I am beginning to mentally place this into the 'bug' area :)
CREATE
Hello.
I am trying to use temporary tables inside a stored procedure, but I
get a rather puzzling error.
I am currently using PostgreSQL 8.2.7 and this is my stored procedure:
CREATE OR REPLACE FUNCTION test() RETURNS bigint AS $$
DECLARE
v_oid bigint;
BEGIN
-- create tmp-table used to ma