X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [64.117.225.181]) by svr1.postgresql.org (Postfix) with ESMTP id 5223CCCD81 for ; Fri, 18 Jul 2003 16:18:59 +0000 (GMT) Received: from svr1.postgresql.org ([64.117.224.193]) by localhost (svr5.postgresql.org [64.117.225.181]) (amavisd-new, port 10024) with ESMTP id 26853-09 for ; Fri, 18 Jul 2003 16:19:21 +0000 (GMT) Received: from megazone.bigpanda.com (unknown [66.180.233.26]) by svr1.postgresql.org (Postfix) with ESMTP id DE542CCD6F for ; Fri, 18 Jul 2003 13:18:47 -0300 (ADT) Received: by megazone.bigpanda.com (Postfix, from userid 1001) id B6222D628; Fri, 18 Jul 2003 09:19:16 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by megazone.bigpanda.com (Postfix) with ESMTP id 8D9115C10; Fri, 18 Jul 2003 09:19:16 -0700 (PDT) Date: Fri, 18 Jul 2003 09:19:16 -0700 (PDT) From: Stephan Szabo To: Reinoud van Leeuwen Cc: Josh Berkus , Subject: Re: [HACKERS] plpgsql strangeness with select into In-Reply-To: <200307180914.43379.josh@agliodbs.com> Message-ID: <20030718091807.T95696-100000@megazone.bigpanda.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200307/256 X-Sequence-Number: 14370 On Fri, 18 Jul 2003, Josh Berkus wrote: > > I'm debugging a trigger in plpgsql and for some reason or the "select > > into " does not seem to work. Here is an unaltered snippet of my > > trigger code: > > > > raise notice ''this id : %'',NEW.id; > > > > select into i_hierarchy_id > > hierarchy_id > > from link_def LD, > > link L, > > object_link OL > > where OL.id = NEW.id > > and L.id = OL.link_id > > and LD.id = L.link_def_id; > > > > raise notice ''i_hierarchy_id: %'',i_hierarchy_id; > > > > > > in the log this results in: > > > > NOTICE: this id : 5265 > > NOTICE: i_hierarchy_id: > > > > but when I perform the query on the command line I do get a result: > > > > select hierarchy_id > > from link_def LD, > > link L, > > object_link OL > > where OL.id = 5264 > > and L.id = OL.link_id > > and LD.id = L.link_def_id; > > > > hierarchy_id > > -------------- > > 1 > > (1 row) > > > > i_hierarchy_id is declared as integer and is not used before this code nor > > as a column name anywhere. > > > > Does anyone have a clue what is going wrong? I use Postgresql 7.3.3 on > > FreeBSD 4.5. > > Without seeing your full trigger code, I can't tell for sure. However, I > would guess that your "SELECT INTO" statement is querying data that has not > yet been created; it's an FK record waiting on a deferred trigger, or you're > using a BEFORE trigger and querying the record which has not yet been > committed. Or perhaps you have a variable named hierarchy_id in the function which is getting used rather than the column of the table in question. Seeing the entire function might help.