| From: | Michael Fuhr <mike(at)fuhr(dot)org> |
|---|---|
| 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 07:40:46 |
| Message-ID: | 20050224074045.GA30413@winnie.fuhr.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On Wed, Feb 23, 2005 at 11:12:47PM -0700, 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.
I don't know about pgAdmin, but in psql you can use \set:
\set id 1
SELECT * FROM foo WHERE id = :id;
\set name '\'Some Name\''
SELECT * FROM foo WHERE name = :name;
--
Michael Fuhr
http://www.fuhr.org/~mfuhr/
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Richard Huxton | 2005-02-24 08:05:16 | Re: Postgres performance |
| Previous Message | Steve - DND | 2005-02-24 06:12:47 | Junk queries with variables? |