473,322 Members | 1,806 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

Parse error help needed...

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
2 1866
"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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: chotiwallah | last post by:
suppose i have the following code: switch ($inc): case 0: require 'inc0.php'; break; case 1: require 'inc1.php'; break; case 2:
4
by: rolf | last post by:
Hmm, I seem to be missing something basic with regards to SAXParsers. I'm parsing some XML using Java 1.4.2 and SAX, so I extend DefaultHandler and in my startElement() method I detect some kind...
5
by: BStorm | last post by:
I have a transaction log file where the DataSet table's Description column is actually delimited into "subcolumns" based upon the transaction id. I would like to parse these into separate fields...
24
by: | last post by:
Hi, I need to read a big CSV file, where different fields should be converted to different types, such as int, double, datetime, SqlMoney, etc. I have an array, which describes the fields and...
8
by: Brett Romero | last post by:
I get this error when I try to run my ASP.NET app on our server: Server Error in '/' Application. -------------------------------------------------------------------------------- Parser Error...
5
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C++ programming. FYI Although I have called...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
3
by: basswhizz | last post by:
Hi everyone im a high school student and I'm having trouble with one of my projects could you please help!! I'm getting this error message. Parse error: syntax error, unexpected...
2
by: Lawrence Krubner | last post by:
Imagine a template system that works by getting a file, as a string, and then putting it through eval(), something like this: $formAsString = $controller->command("readFileAndReturnString",...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.