Обсуждение: Error with functions

Поиск
Список
Период
Сортировка

Error with functions

От
shyamperi@davlin.co.in
Дата:
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.
Вложения

Re: Error with functions

От
Tomasz Myrta
Дата:
> 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

Really?
I got no error and select sample('nothing',3) gave mi 'ing'
What is your postgresql version?

Regards,
Tomasz Myrta



Re: Error with functions

От
shyamperi@davlin.co.in
Дата:
Hey,
PostgreSQL 7.3 on i686-pc-linux-gnu, compiled by GCC 2.96

But, I am getting error when I am using the alias key word.
And also when I try to create a C function for the same and excute I am getting the following error
ERROR:  Memory exhausted in AllocSetAlloc(677865842)
And, I am allocating memory using the "palloc"
-----
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------------------

> 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

Really?
I got no error and select sample('nothing',3) gave mi 'ing'
What is your postgresql version?

Regards,
Tomasz Myrta


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.
Вложения

Re: Error with functions

От
shyamperi@davlin.co.in
Дата:
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
helpme 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@davlin.co.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@postgresql.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.
Вложения

Re: [ADMIN] Error with functions

От
Tom Lane
Дата:
shyamperi@davlin.co.in writes:
> 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 t=
> o it.... but it returns 1.

Works fine for me:

regression=# CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '
regression'#     BEGIN
regression'#         RETURN $1 + 1;
regression'#     END;
regression'# ' LANGUAGE 'plpgsql';
CREATE FUNCTION
regression=# select add_one(10);
 add_one
---------
      11
(1 row)

Perhaps you should show us exactly what you did.

            regards, tom lane

Re: [ADMIN] Error with functions

От
Jean-Michel Chabanne
Дата:
shyamperi@davlin.co.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@postgresql.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