X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id DEA5054F98 for ; Thu, 24 Feb 2005 07:40:54 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 25340-03 for ; Thu, 24 Feb 2005 07:40:45 +0000 (GMT) Received: from tigger.fuhr.org (tigger.fuhr.org [63.214.45.158]) by svr1.postgresql.org (Postfix) with ESMTP id F087754D24 for ; Thu, 24 Feb 2005 07:40:44 +0000 (GMT) Received: from winnie.fuhr.org (winnie.fuhr.org [10.1.0.1]) by tigger.fuhr.org (8.13.1/8.13.1) with ESMTP id j1O7ekMZ040017 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Thu, 24 Feb 2005 00:40:48 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: from winnie.fuhr.org (localhost [127.0.0.1]) by winnie.fuhr.org (8.13.1/8.13.1) with ESMTP id j1O7ekDS030456; Thu, 24 Feb 2005 00:40:46 -0700 (MST) (envelope-from mfuhr@winnie.fuhr.org) Received: (from mfuhr@localhost) by winnie.fuhr.org (8.13.1/8.13.1/Submit) id j1O7ek5I030455; Thu, 24 Feb 2005 00:40:46 -0700 (MST) (envelope-from mfuhr) Date: Thu, 24 Feb 2005 00:40:46 -0700 From: Michael Fuhr To: Steve - DND Cc: pgsql-sql@postgresql.org Subject: Re: Junk queries with variables? Message-ID: <20050224074045.GA30413@winnie.fuhr.org> References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.003 tagged_above=0 required=5 tests=AWL X-Spam-Level: X-Archive-Number: 200502/291 X-Sequence-Number: 20401 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/