basic function not working

From: joseph speigle <joe(dot)speigle(at)jklh(dot)us>
To: pgsql-novice(at)postgresql(dot)org
Subject: basic function not working
Date: 2003-12-17 10:25:13
Message-ID: 20031217102513.GA7499@www.sirfsup.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

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 is coming 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

Responses

Browse pgsql-novice by date

  From Date Subject
Next Message Chris 2003-12-17 11:31:32 data/index file size info
Previous Message Gerard Mason 2003-12-17 01:30:41 Re: Returning arbitrary row sets from a function