X-Original-To: pgsql-admin-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 57B7ED1B503 for ; Wed, 28 Apr 2004 13:06:48 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 20985-04 for ; Wed, 28 Apr 2004 13:06:46 -0300 (ADT) Received: from linux012.intern.cityweb.de (linux012.intern.cityweb.de [195.71.215.252]) by svr1.postgresql.org (Postfix) with ESMTP id 090BBD1B50F for ; Wed, 28 Apr 2004 13:06:45 -0300 (ADT) Received: from zahedi.intern.cityweb.de (zahedi.intern.cityweb.de [193.189.226.198]) by linux012.intern.cityweb.de (8.12.8/8.12.8) with ESMTP id i3SG6KJc002304; Wed, 28 Apr 2004 18:06:21 +0200 From: Andreas Schmitz Reply-To: a.schmitz@cityweb.de Organization: Cityweb Network To: Ben Kim , pgsql-admin@postgresql.org Subject: Re: parametrized query Date: Wed, 28 Apr 2004 18:06:20 +0200 User-Agent: KMail/1.5 References: In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Content-Disposition: inline Message-Id: <200404281806.20203.a.schmitz@cityweb.de> X-Virus-Scanned: by amavisd-new at postgresql.org X-Spam-Status: No, hits=0.0 tagged_above=0.0 required=5.0 tests= X-Spam-Level: X-Archive-Number: 200404/334 X-Sequence-Number: 13307 Put it into a shell script like echo "select * from mytable where id = $1;" | psql $DBNAME That can be executed using the shell function in psql \! [COMMAND] execute command in shell or start interactive shell regards, -Andreas On Wednesday 28 April 2004 17:46, Ben Kim wrote: > I tried but couldn't find an answer if this is possible in psql. > > Create a file named test.sql > select * from mytable where id = ? (or use $1, $2...) > Then in psql do > \i test.sql 337 > > to achieve the same effect "select * from mytable where id=337" > > as I would in perl > $sth = $dbh -> prepare ("insert into mytable values (?, ?, ?)") > > Is writing a function the only way? Is there another way that can be done > without writing a function? > > Thanks, > Ben Kim > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org --