Skip site navigation (1) Skip section navigation (2)

Re: Error with functions

From: shyamperi(at)davlin(dot)co(dot)in
To: jeanmichel(dot)chabanne(at)free(dot)fr
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: Error with functions
Date: 2003-09-20 11:16:28
Message-ID: 7144314.1064057032072.JavaMail.tomcat@mail.davlin.co.in (view raw or flat)
Thread:
Lists: pgsql-adminpgsql-sql
5:08p
Dear All,
When I am executing any function with parameter.. I am unable to access them. So, I would be thankful if, anyone can help me in teaching this aspect.

CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '
    BEGIN
        RETURN $1 + 1;
    END;
' LANGUAGE 'plpgsql';
The expected ouput of the above function should be 11 when we pass the 10 to it.... but it returns 1.
Thank you in advance

-----
Warm Regards
Shÿam Peri

II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003 
Ph : 91-824-2451001/5
Fax : 91-824-2451050 





----------------Original Message------------------

shyamperi(at)davlin(dot)co(dot)in a écrit :

>Hey,
>create or replace function sample(varchar,int) returns varchar as'
>declare
>        data alias for $1;
>        size alias for $2;
>begin
>        return  substr(data,(length(data)-size)+1,length(data));
>end;
>' language 'plpgsql';
>____________________________
>WARNING:  plpgsql: ERROR during compile of sample near line 2
>ERROR:  parse error at or near ";"
>
>Can any body tell me why is this error coming
>-----
>Warm Regards
>Shÿam Peri
>
>II Floor, Punja Building,
>M.G.Road,
>Ballalbagh,
>Mangalore-575003 
>Ph : 91-824-2451001/5
>Fax : 91-824-2451050 
>
>
>DISCLAIMER: This message contains privileged and confidential
information and is
>intended only for the individual named.If you are not the intended
>recipient you should not disseminate,distribute,store,print, copy or
>deliver this message.Please notify the sender immediately by e-mail
if
>you have received this e-mail by mistake and delete this e-mail from
>your system.
>
>
>
------------------------------------------------------------------------
>
> Hey,
> create or replace function sample(varchar,int) returns varchar as'
> declare
>         data alias for $1;
>         size alias for $2;
> begin
>         return  substr(data,(length(data)-size)+1,length(data));
> end;
> ' language 'plpgsql';
>
> ____________________________
> WARNING:  plpgsql: ERROR during compile of sample near line 2
> ERROR:  parse error at or near ";"
>
> Can any body tell me why is this error coming
>
>-----
>Warm Regards
>Shÿam Peri
>
>II Floor, Punja Building,
>M.G.Road,
>Ballalbagh,
>Mangalore-575003 
>Ph : 91-824-2451001/5
>Fax : 91-824-2451050 
>
>
>  
>
>
>
> * DISCLAIMER: This message contains privileged and confidential 
> information and is intended only for the individual named.If you are

> not the intended recipient you should not 
> disseminate,distribute,store,print, copy or deliver this 
> message.Please notify the sender immediately by e-mail if you have 
> received this e-mail by mistake and delete this e-mail from your
system.*
>
>------------------------------------------------------------------------
>
>
>---------------------------(end of
broadcast)---------------------------
>TIP 1: subscribe and unsubscribe commands go to
majordomo(at)postgresql(dot)org
>  
>
Hi,

I juste did a copy/paste of your sample on my test DB. I didn't get
any 
error message and the function works fine.

I run PostgreSQL 7.3.3



-- 
Jean-Michel Chabanne
77450 MONTRY (FRANCE)
48" 54' N - 2" 49' E
Powered by Linux


DISCLAIMER: This message contains privileged and confidential information and is
intended only for the individual named.If you are not the intended
recipient you should not disseminate,distribute,store,print, copy or
deliver this message.Please notify the sender immediately by e-mail if
you have received this e-mail by mistake and delete this e-mail from
your system.

Attachment: Untitled1
Description: text/html (3.9 KB)

Responses

pgsql-admin by date

Next:From: Christopher SmithDate: 2003-09-20 14:12:08
Subject: Re: Are 50 million rows a problem for postgres ?
Previous:From: S.P.VimalaDate: 2003-09-20 07:47:25
Subject: Re: upgrade of 7.2.2-1 to 7.3.4

pgsql-sql by date

Next:From: Martin MarquesDate: 2003-09-20 11:18:17
Subject: Re: auto_increment
Previous:From: Martin MarquesDate: 2003-09-20 11:15:13
Subject: Re: auto_increment

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group