Обсуждение: basic function not working
Hi, could somebody tell me what I'm missing here?
Postgres appears to not know where to look for the table I am using in my SELECT INTO clause because the error says it
iscoming before the FROM word.
============================================
the function is:
SET search_path = public;
CREATE or replace FUNCTION user_tablere (text) RETURNS text AS '
DECLARE
-- Declare aliases for function arguments.
location_in ALIAS FOR $1;
username text;
BEGIN
SELECT into username FROM user_table WHERE location = location_in;
return username;
END;
' LANGUAGE 'plpgsql';
============================================
which gives this out:
Welcome to psql 7.3.1, the PostgreSQL interactive terminal.
Type: \copyright for distribution terms
\h for help with SQL commands
\? for help on internal slash commands
\g or terminate with semicolon to execute query
\q to quit
address=# \e a_a.sql
SET
CREATE FUNCTION
address=# select user_tablere('sacu');
WARNING: Error occurred while executing PL/pgSQL function user_tablere
WARNING: line 12 at select into variables
ERROR: parser: parse error at or near "FROM" at character 9
address=#
============================================
--
joe speigle
joseph speigle <joe.speigle@jklh.us> writes:
> SELECT into username FROM user_table WHERE location = location_in;
You're missing anything to be put into username ...
regards, tom lane
believe it or not I was thinking about going to programming school next year..... On Wed, Dec 17, 2003 at 09:58:28AM -0500, Tom Lane wrote: > joseph speigle <joe.speigle@jklh.us> writes: > > SELECT into username FROM user_table WHERE location = location_in; > > You're missing anything to be put into username ... > > regards, tom lane > > ---------------------------(end of broadcast)--------------------------- > TIP 8: explain analyze is your friend -- joe speigle