Skip site navigation (1) Skip section navigation (2)

Re: Destination table by variable?

From: Afton & Ray Still <rastill(at)shaw(dot)ca>
To: pgsql-novice(at)postgresql(dot)org, Erik Dahlstrand <df03daer(at)ing(dot)hj(dot)se>
Subject: Re: Destination table by variable?
Date: 2005-03-18 15:39:52
Message-ID: 002e01c52bd0$ba0d8f90$7c884146@rayshome (view raw or flat)
Thread:
Lists: pgsql-novice
Hello Erik,
What front end are you using? I primarily use PHP, and this procedure is 
simple. You just use string operations to put together your query however 
you want. Use variables, math, concactanation, or ... .
The question you need to ask is: I'm using ______ as a front end and "I want 
to choose the destination table by a variable." "Is it possible?
"
Ray
----- Original Message ----- 
From: "Erik Dahlstrand" <df03daer(at)ing(dot)hj(dot)se>
To: <pgsql-novice(at)postgresql(dot)org>
Sent: Friday, March 18, 2005 7:35 AM
Subject: [NOVICE] Destination table by variable?


Hi!

I want to choose the destination table by a variable. Something like this:

CREATE FUNCTION insert_this(int4, varchar, varchar) RETURNS void AS $$
    DECLARE
        destTable text;
    BEGIN
        SELECT INTO destTable get_table_name($1);

        INSERT INTO destTable VALUES ($2, $3);
    END;
$$ LANGUAGE plpgsql;

Is it possible?

/Erik

---------------------------(end of broadcast)---------------------------
TIP 3: if posting/reading through Usenet, please send an appropriate
      subscribe-nomail command to majordomo(at)postgresql(dot)org so that your
      message can get through to the mailing list cleanly


-- 
No virus found in this incoming message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 3/15/2005




-- 
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.7.3 - Release Date: 3/15/2005


In response to

Responses

pgsql-novice by date

Next:From: Andreas KretschmerDate: 2005-03-18 15:45:26
Subject: Re: [despammed] Destination table by variable?
Previous:From: Erik DahlstrandDate: 2005-03-18 14:35:37
Subject: Destination table by variable?

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group