Re: create temp view from function inside plpgsql function.

From: Pavel Stehule <pavel(dot)stehule(at)gmail(dot)com>
To: Tjibbe Rijpma <tjibbe(at)rijpma(dot)org>
Cc: PostgreSQL mailing lists <pgsql-general(at)postgresql(dot)org>
Subject: Re: create temp view from function inside plpgsql function.
Date: 2014-04-04 10:23:12
Message-ID: CAFj8pRBoLWjQUVhM9GMDhdb9pNbnhN0Zr=7_ek8SfA5nh-AWOQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Hello

2014-04-04 11:43 GMT+02:00 Tjibbe <tjibbe(at)rijpma(dot)org>:

> I have a plpgsql function with:
>
>
> PERFORM * FROM answers(_h); --works fine.
> CREATE TEMP VIEW answers AS SELECT * FROM answers(_h); --gives error...
>

Inside view definition should not be plpgsql variable - this statement has
no plan - CREATE VIEW

probably you can do with dynamic SQL

EXECUTE 'CREATE TEMP VIEW answers AS SELECT * FROM answers(' ||
quote_literal(_h) || ')';

Regards

Pavel Stehule

> Why I get this error:
> ERROR: column \"_h\" does not exist\nLINE 1: ...TEMP VIEW answers AS
> SELECT * FROM antwoorden_view(_h)
>
> --
> +31 6 29401726
> tjibbe(at)rijpma(dot)org
> Jacobusstraat 185
> 3012 JM Rotterdam
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Kohler Manuel (ID SIS) 2014-04-04 11:24:51 Indices and Foreign Tables
Previous Message Tjibbe 2014-04-04 09:43:01 create temp view from function inside plpgsql function.