basic function not working - Mailing list pgsql-novice

From joseph speigle
Subject basic function not working
Date
Msg-id 20031217102513.GA7499@www.sirfsup.com
Whole thread Raw
Responses Re: basic function not working
List 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
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

pgsql-novice by date:

Previous
From: "Gerard Mason"
Date:
Subject: Re: Returning arbitrary row sets from a function
Next
From: Tom Lane
Date:
Subject: Re: basic function not working