X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (av.hub.org [200.46.204.144]) by postgresql.org (Postfix) with ESMTP id DA7BA9DCBC6 for ; Mon, 27 Mar 2006 10:34:11 -0400 (AST) Received: from postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 78030-01 for ; Mon, 27 Mar 2006 10:34:15 -0400 (AST) Received: from svr4.postgresql.org (svr4.postgresql.org [66.98.251.159]) by postgresql.org (Postfix) with ESMTP id 9754D9DCA75 for ; Mon, 27 Mar 2006 10:34:09 -0400 (AST) Received: from smtpq2.tilbu1.nb.home.nl (smtpq2.tilbu1.nb.home.nl [213.51.146.201]) by svr4.postgresql.org (Postfix) with ESMTP id 417D95AF1CD for ; Mon, 27 Mar 2006 14:34:12 +0000 (GMT) Received: from [213.51.146.190] (port=48852 helo=smtp1.tilbu1.nb.home.nl) by smtpq2.tilbu1.nb.home.nl with esmtp (Exim 4.30) id 1FNsn8-0006Me-70 for pgsql-sql@postgresql.org; Mon, 27 Mar 2006 16:33:58 +0200 Received: from cc503261-a.eelde1.dr.home.nl ([212.204.130.36]:55404 helo=[192.168.1.4]) by smtp1.tilbu1.nb.home.nl with esmtp (Exim 4.30) id 1FNsn6-0005RS-4H for pgsql-sql@postgresql.org; Mon, 27 Mar 2006 16:33:56 +0200 Message-ID: <4427F7D3.3000103@gmail.com> Date: Mon, 27 Mar 2006 16:33:55 +0200 From: Wiebe Cazemier User-Agent: Mozilla Thunderbird 1.0.7 (X11/20060225) X-Accept-Language: en-us, en MIME-Version: 1.0 To: pgsql-sql@postgresql.org Subject: unique names in variables and columns in plsql functions X-Enigmail-Version: 0.93.0.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enigB156D5C2C2843E68716DB5CF" X-AtHome-MailScanner-Information: Please contact support@home.nl for more information X-AtHome-MailScanner: Found to be clean X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, score=0 required=5 tests=[none] X-Spam-Score: 0 X-Spam-Level: X-Archive-Number: 200603/424 X-Sequence-Number: 24770 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB156D5C2C2843E68716DB5CF Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Hi, In a plpgsl function, consider the following excerpt: DECLARE provider_id INTEGER; BEGIN provider_id := (SELECT provider_id FROM investment_products WHERE id = my_new.investment_product_id); END; After a lot of trouble, I found out this line doesn't work correctly with the variable name as it is. It doesn't give an error or anything, it just retrieves some wrong value (probably NULL). When I change the variable name to anything other than "provider_id", it works OK. I was somewhat surprised to discover this. Can't Postgres determine that the provider_id in the SELECT statement is not the same one as the variable? --------------enigB156D5C2C2843E68716DB5CF Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.2.2 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFEJ/fTMHkUjYo9d9ARAlCVAJ0VzfNAqdAfTpZgQi7glcvEUIH/FwCePIDq LCpGTp9HiZNdKiSpHdLsDE4= =Je3F -----END PGP SIGNATURE----- --------------enigB156D5C2C2843E68716DB5CF--