Re: Var substitution in SELECT statements

From: Randall Perry <rgp(at)systame(dot)com>
To: <pgsql-general(at)postgresql(dot)org>, <pgsql-interfaces(at)postgresql(dot)org>
Subject: Re: Var substitution in SELECT statements
Date: 2001-04-24 01:41:51
Message-ID: B70A521F.A291%rgp@systame.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-interfaces

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.

--
Randy Perry
sysTame
Mac Consulting/Sales

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Lincoln Yeoh 2001-04-24 01:46:20 Re: installing DBD::Pg without installing postgres
Previous Message Randall Perry 2001-04-24 01:20:35 Var substitution in SELECT statements

Browse pgsql-interfaces by date

  From Date Subject
Next Message will trillich 2001-04-24 07:15:16 Re: Var substitution in SELECT statements
Previous Message Randall Perry 2001-04-24 01:20:35 Var substitution in SELECT statements