pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Wiebe Cazemier <halfgaar@gmail.com>
To: pgsql-sql@postgresql.org
Subject: unique names in variables and columns in plsql functions
Date: Mon, 27 Mar 2006 16:33:55 +0200
Message-ID: <4427F7D3.3000103@gmail.com> (raw)

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?

Attachments:

  signature.asc (application/pgp-signature, 257B) download

view thread (6+ messages)  latest in thread

Message-ID: <4427F7D3.3000103@gmail.com>
Permalink:  ../4427F7D3.3000103@gmail.com/
Also on:    postgresql.org/message-id/4427F7D3.3000103@gmail.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: halfgaar@gmail.com
  Subject: Re: unique names in variables and columns in plsql functions
  In-Reply-To: <4427F7D3.3000103@gmail.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox