| From: | will trillich <will(at)serensoft(dot)com> | 
|---|---|
| To: | pgsql-general(at)postgresql(dot)org | 
| Subject: | Re: Var substitution in SELECT statements | 
| Date: | 2001-04-24 07:15:16 | 
| Message-ID: | 20010424021516.I27356@serensoft.com | 
| Views: | Whole Thread | Raw Message | Download mbox | Resend email | 
| Thread: | |
| Lists: | pgsql-general pgsql-interfaces | 
On Mon, Apr 23, 2001 at 09:41:51PM -0400, Randall Perry wrote:
> on 4/23/01 9:20 PM, Randall Perry at rgp(at)systame(dot)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(at)serensoft(dot)com
http://sourceforge.net/projects/newbiedoc -- we need your brain!
http://www.dontUthink.com/ -- your brain needs us!
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Konstantin Borchert | 2001-04-24 08:20:56 | Problem with postgreSQL (number of backends) | 
| Previous Message | will trillich | 2001-04-24 07:08:50 | Re: Re: BETWEEN clause | 
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Andy Champion | 2001-04-24 15:31:55 | libpq/INSERT | 
| Previous Message | Randall Perry | 2001-04-24 01:41:51 | Re: Var substitution in SELECT statements |