Received: from localhost (pluto.hub.org [200.46.204.4]) by postgresql.org (Postfix) with ESMTP id B50CE9FA265 for ; Wed, 22 Nov 2006 11:55:36 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.204.4]) (amavisd-new, port 10024) with ESMTP id 85218-05 for ; Wed, 22 Nov 2006 11:55:22 -0400 (AST) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from web31802.mail.mud.yahoo.com (web31802.mail.mud.yahoo.com [68.142.207.65]) by postgresql.org (Postfix) with SMTP id 3E2299FA48A for ; Wed, 22 Nov 2006 11:55:31 -0400 (AST) Received: (qmail 68440 invoked by uid 60001); 22 Nov 2006 15:55:29 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:Date:From:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-ID; b=PZ1LLpxptvUWV9gslh9S9mgpDc8AbMeBaDy10b8LvSjsmn15S99fkRxwICDw9rjM/AF3ZvawUzv39N/DVCxlZbc7II5zD9hu/DV1ReAcnKfZCQkh3wxiaFTsWBkxV2N+5Lv7xdOzhyBfEVKhnk9MfePDnAjNjHUrwXBcDorh5+k= ; X-YMail-OSG: q34ucpIVM1mY2kyF8p8GNtpxETfNG3cAbe_h02f9 Received: from [24.54.196.198] by web31802.mail.mud.yahoo.com via HTTP; Wed, 22 Nov 2006 07:55:29 PST Date: Wed, 22 Nov 2006 07:55:29 -0800 (PST) From: Richard Broersma Jr Subject: Re: select into To: Mulham freshcode , pgsql-sql@postgresql.org In-Reply-To: <20061122082816.26958.qmail@web90504.mail.mud.yahoo.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit Message-ID: <430473.67117.qm@web31802.mail.mud.yahoo.com> X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0.174 tagged_above=0 required=5 tests=AWL, BAYES_00, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, DNS_FROM_RFC_WHOIS X-Spam-Level: X-Archive-Number: 200611/229 X-Sequence-Number: 26881 > Hi guys, > > 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; > > where svc_data_rec is defined as record and svc_tbl_name is a varchar that holds the name of a > table and sub_id is another varchar. the error message is > > ERROR: syntax error at or near "$1" at character 17 > QUERY: SELECT * from $1 where 'uid' = $2 > CONTEXT: PL/pgSQL function "foo" line 132 at select into variables > LINE 1: SELECT * from $1 where 'uid' = $2 > > where am i going wrong? it seems that the variables are not being substituted with their > values correctly. Notice: http://www.postgresql.org/docs/8.2/interactive/sql-selectinto.html and particularly this example: http://www.postgresql.org/docs/8.2/interactive/sql-selectinto.html#AEN54014 Regards, Richard Broersma Jr.