I just got the following example:
DROP TABLE foo;
CREATE TABLE foo (login varchar(100));
INSERT INTO foo values ('abc');
DROP FUNCTION footest1(varchar(100));
CREATE FUNCTION footest1(varchar(100)) RETURNS varchar(100) AS ' DECLARE login varchar(100);
BEGIN SELECT INTO login login FROM foo LIMIT 1; RETURN login; END;
' LANGUAGE 'plpgsql';
DROP FUNCTION footest2(varchar(100));
CREATE FUNCTION footest2(varchar(100)) RETURNS varchar(100) AS ' DECLARE fieldname varchar(100);
BEGIN SELECT INTO fieldname login FROM foo LIMIT 1; RETURN fieldname; END;
' LANGUAGE 'plpgsql';
SELECT footest1('foobar');
SELECT footest2('foobar');
The first select returns NULL while the second correctly returns 'abc'.
I just wonder why it is that way. The only difference seems to be the
name of the variable which in footest1 equals the attribute name.
Now I can guess what happens but I wonder if this is the desired
behaviour.
Michael
--
Michael Meskes
Michael@Fam-Meskes.De
Go SF 49ers! Go Rhein Fire!
Use Debian GNU/Linux! Use PostgreSQL!