Re: problems with variabiles in plpgsql

From: "Gregory Wood" <gregw(at)com-stock(dot)com>
To: "Diana Cionoiu" <diana(at)softwaresolutions(dot)ro>
Cc: "PostgreSQL-General" <pgsql-general(at)postgresql(dot)org>
Subject: Re: problems with variabiles in plpgsql
Date: 2001-04-04 14:27:37
Message-ID: 006e01c0bd13$66cd1b00$7889ffcc@comstock.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

To the best of my knowledge, you can't use parameters for table names. But
if you have 7.1, you can use the EXECUTE command to dynamically generate
(and execute) any SQL statement. Check out:

http://postgresql.readysetnet.com/devel-corner/docs/programmer/plpgsql-descr
iption.html

Specifically: 24.2.5.3. Executing dynamic queries

Greg

----- Original Message -----
From: "Diana Cionoiu" <diana(at)softwaresolutions(dot)ro>
To: <pgsql-general(at)postgresql(dot)org>
Sent: Wednesday, April 04, 2001 2:27 AM
Subject: problems with variabiles in plpgsql

> Good day everybody,
>
> My problem is that i can't use a variabile to name a table, like this:
>
> select INTO id,domeniu idp,nume FROM $2 where idc=$1;
> ^^
> I was having the same problem with creating a table:
>
> create table $1(id serial,stuff text);
> ^^
> was give me the same error:
>
> 010404.09:17:45.062 [767] ERROR: parser: parse error at or near "$1"
> 010404.09:17:45.063 [767] DEBUG: Last error occured while executing
> PL/pgSQL function domenii
> 010404.09:17:45.063 [767] DEBUG: line 8 at select into variables
>
> Is there any problem naming tables with variabiles????
>
> I haven't find anything in the manual.
>
> Thanks very much.
>
> Diana Cionoiu
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 2: you can get off all lists at once with the unregister command
> (send "unregister YourEmailAddressHere" to majordomo(at)postgresql(dot)org)
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Partyka Robert 2001-04-04 14:30:50 an error while pg_dumpall
Previous Message Marcin Wasilewski 2001-04-04 14:26:47 Startup script