Re: dynamic table/col names in plpgsql

From: Michael Glaesemann <grzm(at)seespotcode(dot)net>
To: gary jefferson <garyjefferson123(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: dynamic table/col names in plpgsql
Date: 2007-06-24 04:04:02
Message-ID: B3DF8968-0266-443B-82DA-B225D8E08217@seespotcode.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general


On Jun 23, 2007, at 22:47 , gary jefferson wrote:

> Is there a way to use a variable as the name of a table or column
> in plpgsql?

AIUI, you need to use EXECUTE and build the query string yourself.

http://www.postgresql.org/docs/8.2/interactive/plpgsql-
statements.html#PLPGSQL-STATEMENTS-EXECUTING-DYN

Take a look at the quote_ident function as well:

http://www.postgresql.org/docs/8.2/interactive/functions-string.html

Hope this helps you get started.

Michael Glaesemann
grzm seespotcode net

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Steve Atkins 2007-06-24 04:04:54 Re: dynamic table/col names in plpgsql
Previous Message gary jefferson 2007-06-24 03:47:14 dynamic table/col names in plpgsql