Re: dynamic SQL

From: "Scott Marlowe" <scott(dot)marlowe(at)gmail(dot)com>
To: davyd <davydky(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: dynamic SQL
Date: 2008-09-11 01:35:13
Message-ID: dcc563d10809101835p612698d0t5b402e518f57de52@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

On Wed, Sep 10, 2008 at 9:45 AM, davyd <davydky(at)gmail(dot)com> wrote:
> Hi list,
> I need to create a sql where the name of a tabla is on a variable..
>
> vbuffer varchar;
>
> SELECT buffer
> INTO vbuffer
> FROM rutas r, unidades u
> WHERE r.codigo_ruta = u.codigo_ruta AND
> u.codigo_uni = 'B15_AFF666';
>
>
> SELECT within(the_geom,(SELECT geomunion(the_geom) from var vbuffer)) as
> inside

You'll need to do it by building the query as a string in a plpgsql
function and then execute it.

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Aftab Alam 2008-09-11 04:09:48 replica of database
Previous Message Stephen Frost 2008-09-10 23:50:45 Re: Postgres 8.3.3, GSSAPI, and Windows XP