423,516 Members | 2,068 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,516 IT Pros & Developers. It's quick & easy.

Parse error help needed...

P: n/a
I am getting this error

postgres=# \i a.sql
psql:a.sql:10: ERROR: parser: parse error at or near "return" at character
26
--
a.sql
--
create function loadme() return text as '
Declare
s_out text ;
Begin
For i in 1..10000 loop
insert into test values (i,''Test'');
end loop;
return s_out;
End;
' language 'plpgsql';

Any help is appreciated

Thx
Deep

PS: I already loaded pl/pgsql in my database
[postgres@node1]~$ createlang -d test -l
Procedural languages
Name | Trusted?
---------+----------
plpgsql | t
(1 row)
-----Original Message-----
From: pg*****************@postgresql.org
[mailto:pg*****************@postgresql.org] On Behalf Of Chris Ochs
Sent: Monday, January 12, 2004 4:30 PM
To: pg***********@postgresql.org
Subject: Re: [GENERAL] sql insert function
Never mind, I forgot to quote the quote's...

Chris
The documentation doesn't have any examples of using an sql language
function to do an insert, andI am at loss as to I am doing wrong here.
The error I get trying to create the function is: ERROR: syntax
error at or near "$1" at character 148

CREATE FUNCTION taxship(varchar,integer,varchar,float,float) returns integer AS '
insert into taxship(s_oid,order_id,mer_id,tax,shipping) values
('$1',$2,'$3',$4,$5); SELECT 1;
' LANGUAGE SQL;
---------------------------(end of
broadcast)---------------------------
TIP 7: don't forget to increase your free space map settings

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

---------------------------(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

Nov 22 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
"Thapliyal, Deepak" <dt********@soe.sony.com> writes:
I am getting this error

postgres=# \i a.sql
psql:a.sql:10: ERROR: parser: parse error at or near "return" at character
26 create function loadme() return text as '

^^^^^^

I think you want "returns" here.

-Doug

---------------------------(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

Nov 22 '05 #2

P: n/a
Thapliyal, Deepak wrote:
create function loadme() return text as '
try "RETURNS" instead of "RETURN"

[the guys writing the function parser might want to consider reporting
what the parser was expecting at this point]
Declare
s_out text ;
Begin
For i in 1..10000 loop
insert into test values (i,''Test'');
end loop;
return s_out;
End;
' language 'plpgsql';


The rest looks fine (works for me - yes I tested it this time)

Alex Satrapa
---------------------------(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

Nov 22 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.