dbTalk Databases Forums  

basic function not working

comp.databases.postgresql.novice comp.databases.postgresql.novice


Discuss basic function not working in the comp.databases.postgresql.novice forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
joseph speigle
 
Posts: n/a

Default basic function not working - 12-17-2003 , 04:25 AM






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

---------------------------(end of broadcast)---------------------------
TIP 9: the planner will ignore your desire to choose an index scan if your
joining column's datatypes do not match


Reply With Quote
  #2  
Old   
Tom Lane
 
Posts: n/a

Default Re: basic function not working - 12-17-2003 , 08:58 AM






joseph speigle <joe.speigle (AT) jklh (DOT) us> writes:
Quote:
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



Reply With Quote
  #3  
Old   
joseph speigle
 
Posts: n/a

Default Re: basic function not working - 12-17-2003 , 11:54 AM



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:
Quote:
joseph speigle <joe.speigle (AT) jklh (DOT) 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

---------------------------(end of broadcast)---------------------------
TIP 8: explain analyze is your friend



Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.