From: | Richard Huxton <dev(at)archonet(dot)com> |
---|---|
To: | Steve - DND <postgres(at)digitalnothing(dot)com> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: Junk queries with variables? |
Date: | 2005-02-24 08:23:39 |
Message-ID: | 421D8F0B.1060409@archonet.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Steve - DND wrote:
> I really have to be missing something here and this probably a *really* noob
> question. I don't have a problem running little junk queries in the pgAdmin
> query window(SELECT blah FROM blah, INSERT INTO blah, etc...), but I can't
> figure out how to run queries with variables outside of a function. I just
> want to use variables without having to go about creating and dropping a
> function for every stupid little query I need to write. Example:
>
> amount int4 := 1000;
> earliest_date timestamp := current_timestamp;
Michael's given you one option - another to look at is PREPARE/EXECUTE
PREPARE my_query(int4) AS INSERT INTO foo VALUES ($1);
EXECUTE my_query(1);
EXECUTE my_query(7);
...
--
Richard Huxton
Archonet Ltd
From | Date | Subject | |
---|---|---|---|
Next Message | KÖPFERL Robert | 2005-02-24 09:08:48 | Re: Junk queries with variables? |
Previous Message | Richard Huxton | 2005-02-24 08:21:58 | Re: Advanced SELECT |