Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id 35C369FA48A for ; Wed, 22 Nov 2006 12:14:40 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 45034-05 for ; Wed, 22 Nov 2006 12:14:24 -0400 (AST) X-Greylist: from auto-whitelisted by SQLgrey- Received: from sss.pgh.pa.us (sss.pgh.pa.us [66.207.139.130]) by postgresql.org (Postfix) with ESMTP id 0AAC59F9CF9 for ; Wed, 22 Nov 2006 12:14:23 -0400 (AST) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.13.6/8.13.6) with ESMTP id kAMGEMMU001139; Wed, 22 Nov 2006 11:14:22 -0500 (EST) To: Mulham freshcode cc: pgsql-sql@postgresql.org Subject: Re: select into In-reply-to: <20061122082816.26958.qmail@web90504.mail.mud.yahoo.com> References: <20061122082816.26958.qmail@web90504.mail.mud.yahoo.com> Comments: In-reply-to Mulham freshcode message dated "Wed, 22 Nov 2006 00:28:15 -0800" Date: Wed, 22 Nov 2006 11:14:22 -0500 Message-ID: <1138.1164212062@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: Maia Mailguard 1.0.1 X-Archive-Number: 200611/231 X-Sequence-Number: 26883 Mulham freshcode writes: > Am new to sql scripting so this might be a stupid question. Am getting an error while trying to do the following > SELECT INTO svc_data_rec * from svc_tbl_name where 'uid' = sub_id; The error message shows that this is getting rewritten into > QUERY: SELECT * from $1 where 'uid' = $2 so the problem is that you are using svc_tbl_name as a plpgsql variable, and plpgsql is not bright enough to realize that it shouldn't substitute the variable value at this particular spot in the query. You need to change the variable name to something that won't conflict. In general, don't use plpgsql variables that are named the same as any SQL tables or columns you need to mention in the function. regards, tom lane