Received: from postgresql.org.org (webmail.postgresql.org [216.126.85.28]) by postgresql.org (8.11.3/8.11.1) with SMTP id f3QC23393920 for ; Thu, 26 Apr 2001 08:02:03 -0400 (EDT) (envelope-from pgsql-interfaces-owner@postgresql.org) Received: from sysadmin.chi.wdr.com (sysadmin.chi.ubswarburg.com [146.180.1.66]) by postgresql.org (8.11.3/8.11.1) with ESMTP id f3P226380311 for ; Tue, 24 Apr 2001 22:02:06 -0400 (EDT) (envelope-from devin@sysadmin.chi.wdr.com) Received: from devin by sysadmin.chi.wdr.com with local (Exim 3.12 #2) id 14sEcv-0002BR-00; Tue, 24 Apr 2001 21:01:57 -0500 Date: Tue, 24 Apr 2001 21:01:56 -0500 (CDT) From: Tod McQuillin X-X-Sender: To: Randall Perry cc: Subject: Re: [GENERAL] Var substitution in SELECT statements In-Reply-To: Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Archive-Number: 200104/111 X-Sequence-Number: 1495 On Mon, 23 Apr 2001, Randall Perry 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? First, I would highly recommend you investigate the perl DBI abd DBD::Pg modules -- they handle variable placeholders quite efficiently and correctly. But for your problem above, surely you must use single quotes around any string you include as a literal in an SQL query. $res = $conn->exec("select cust, contact, user_name, email from $t where user_name = '$c'"); -- Tod McQuillin