X-Original-To: pgsql-sql@postgresql.org Received: from web20802.mail.yahoo.com (web20802.mail.yahoo.com [216.136.226.191]) by postgresql.org (Postfix) with SMTP id DF88F475A71 for ; Wed, 19 Mar 2003 09:59:22 -0500 (EST) Message-ID: <20030319145925.37042.qmail@web20802.mail.yahoo.com> Received: from [208.13.35.65] by web20802.mail.yahoo.com via HTTP; Wed, 19 Mar 2003 06:59:25 PST Date: Wed, 19 Mar 2003 06:59:25 -0800 (PST) From: Jeff Eckermann Subject: Re: Casting with character and character varying To: David Loh , pgsql-sql@postgresql.org In-Reply-To: <007001c2edda$848c8410$b7d273cb@davidloh> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Archive-Number: 200303/461 X-Sequence-Number: 12500 --- David Loh wrote: > else > select into Rec * from tableA where user_name = > trim(trailing '' '' from > cast(NEW.user_name as varchar)) and user_type = > ''T''; > if not found then > return NEW; > end if; > > insert into temptable values (tableA.FieldA); This last statement inserts every record from tableA into temptable. This follows from the PostgreSQL "implicit from-clause" feature, whereby "select tableA.FieldA" is equivalent to "select FieldA from tableA". What you want is to refer to "Rec.FieldA", which will give you the single value that you are looking for. __________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com