Received: from server (client-sp03-85.speedex.net [208.33.90.85]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3O7FJ385407 for ; Tue, 24 Apr 2001 03:15:27 -0400 (EDT) (envelope-from will@serensoft.com) Received: from will by server with local (Exim 3.12 #1 (Debian)) id 14rx2a-0007RX-00 for ; Tue, 24 Apr 2001 02:15:16 -0500 Date: Tue, 24 Apr 2001 02:15:16 -0500 From: will trillich To: pgsql-general@postgresql.org Subject: Re: Var substitution in SELECT statements Message-ID: <20010424021516.I27356@serensoft.com> Mail-Followup-To: pgsql-general@postgresql.org References: Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: ; from rgp@systame.com on Mon, Apr 23, 2001 at 09:41:51PM -0400 X-Archive-Number: 200104/999 X-Sequence-Number: 8213 On Mon, Apr 23, 2001 at 09:41:51PM -0400, Randall Perry wrote: > on 4/23/01 9:20 PM, Randall Perry at rgp@systame.com wrote: > > > This works: > > $res = $conn->exec("select cust, contact, user_name, email from $t where > > user_name = a1a"); > > > > This doesn't: > > $c = "a1a"; > > $res = $conn->exec("select cust, contact, user_name, email from $t where > > user_name = $c"); > > > > and returns the error: > > Attribute 'a1a' not found > > > > > > How do you do var substitution with the Pg module in Perl? > > Whoops! Needed to quote the var as so (for $c above): > > $c = "\'$c\'"; > > Works now. also try $sth = $dbh->prepare("select fields from tbl where f1 = ? and f2 = ?") $sth->execute($val1,$val2); while ($ref = $sth->fetchrow_hashref()) { ... } $sth->finish(); -- don't visit this page. it's bad for you. take my expert word for it. http://www.salon.com/people/col/pagl/2001/03/21/spring/index1.html will@serensoft.com http://sourceforge.net/projects/newbiedoc -- we need your brain! http://www.dontUthink.com/ -- your brain needs us!