Michael Meskes <[EMAIL PROTECTED]> writes: > 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';
> The first select returns NULL while the second correctly returns 'abc'. The NULL is perfectly correct: that's the initial value of the plpgsql variable. The above is essentially the same as saying login := login; It is not "incorrect". > Now I can guess what happens but I wonder if this is the desired > behaviour. Certainly, unless you'd like to disable all use of plpgsql variables in SQL queries. plpgsql has no way of guessing that "login" in the above query wasn't intended to reference its variable. Either choose a different variable name, or qualify the query-variable reference (eg, foo.login). regards, tom lane ---------------------------(end of broadcast)--------------------------- TIP 1: subscribe and unsubscribe commands go to [EMAIL PROTECTED]