pg.ddx.io pgsql-admin@postgresql.org mailing list archive
help / color / mirror / Atom feedError with functions
12+ messages / 6 participants
[nested] [flat]
* Error with functions
@ 2003-09-20 06:24 shyamperi@davlin.co.in
2003-09-20 06:58 ` Re: Error with functions Tomasz Myrta <jasiek@klaster.net>
2003-09-20 07:29 ` Re: Error with functions Jean-Michel Chabanne <jeanmichel.chabanne@free.fr>
0 siblings, 2 replies; 12+ messages in thread
From: shyamperi@davlin.co.in @ 2003-09-20 06:24 UTC (permalink / raw)
To: pgsql-admin
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.
Attachments:
Untitled1 (text/html, 1.2K) download
<head></head><body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4><P><FONT face=verdana size=2>Hey,<BR>create or replace function sample(varchar,int) returns varchar as'<BR>declare<BR> data alias for $1;<BR> size alias for $2;<BR>begin<BR> return substr(data,(length(data)-size)+1,length(data));<BR>end;<BR>' language 'plpgsql';</FONT></P>
<P><FONT face=verdana size=2>____________________________<BR>WARNING: plpgsql: ERROR during compile of sample near line 2<BR>ERROR: parse error at or near ";"<BR><BR>Can any body tell me why is this error coming</FONT></P><PRE>-----
Warm Regards
Shÿam Peri
II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003
Ph : 91-824-2451001/5
Fax : 91-824-2451050
</PRE></body><br><br><b>
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.</b>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Error with functions
2003-09-20 06:24 Error with functions shyamperi@davlin.co.in
@ 2003-09-20 06:58 ` Tomasz Myrta <jasiek@klaster.net>
1 sibling, 0 replies; 12+ messages in thread
From: Tomasz Myrta @ 2003-09-20 06:58 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: pgsql-sql@postgresql.org
> 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
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Error with functions
2003-09-20 06:24 Error with functions shyamperi@davlin.co.in
@ 2003-09-20 07:29 ` Jean-Michel Chabanne <jeanmichel.chabanne@free.fr>
1 sibling, 0 replies; 12+ messages in thread
From: Jean-Michel Chabanne @ 2003-09-20 07:29 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: pgsql-admin; pgsql-sql@postgresql.org
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
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Error with functions
@ 2003-09-20 11:16 shyamperi@davlin.co.in
2003-09-20 16:02 ` Re: Error with functions Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 1 reply; 12+ messages in thread
From: shyamperi@davlin.co.in @ 2003-09-20 11:16 UTC (permalink / raw)
To: jeanmichel.chabanne@free.fr; +Cc: pgsql-admin
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@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.
Attachments:
Untitled1 (text/html, 3.9K) download
<head></head><body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4><P>5:08p<BR>Dear All,<BR>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.<BR><BR>CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '<BR> BEGIN<BR> RETURN $1 + 1;<BR> END;<BR>' LANGUAGE 'plpgsql';</P>
<P>The expected ouput of the above function should be 11 when we pass the 10 to it.... but it returns 1.<BR>Thank you in advance<BR></P><PRE>-----
Warm Regards
Shÿam Peri
II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003
Ph : 91-824-2451001/5
Fax : 91-824-2451050
</PRE><BR><BR>----------------Original Message------------------<BR><PRE>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
</PRE></body><br><br><b>
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.</b>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: Error with functions
2003-09-20 11:16 Re: Error with functions shyamperi@davlin.co.in
@ 2003-09-20 16:02 ` Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 0 replies; 12+ messages in thread
From: Tom Lane @ 2003-09-20 16:02 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: jeanmichel.chabanne@free.fr; pgsql-admin; pgsql-sql@postgresql.org
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
^ permalink raw reply [nested|flat] 12+ messages in thread
* error with functions
@ 2003-09-22 04:22 shyamperi@davlin.co.in
2003-09-22 05:01 ` Re: error with functions Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 1 reply; 12+ messages in thread
From: shyamperi@davlin.co.in @ 2003-09-22 04:22 UTC (permalink / raw)
To: pgsql-admin
10:12a
Dear all,
This is about the same problem which I have been facing for the past one week and which I am unable to solve.
I have create a function which return +1 of the argument passed.
Function Definition:
CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '
BEGIN
RETURN $1 + 1;
END;
' LANGUAGE 'plpgsql';
The output it was giving was always 1, despite any argument ( not string's ofcourse)
When I viewed the function definition in the pg_proc table...
psql "select proname,prosrc from pg_proc where proname='add_one'"
proname | prosrc
---------+-------------------------------------------------------
add_one | BEGIN RETURN +1 END;
(1 row)
______________
Can any body tell me why is the $1 missing..
I am using running postgres 7.3.4 in linux envt
Have a grate day
-----
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------------------
Subject : Re: [ADMIN] Postgresql UPDATE LOCKS unrelated rows.
Hi Stephan,
Here is the table structure. FYI, we tried the experiment with mysql
and the concurrency is working fine.
create table TABLE1( TABLE_ID IDENTITY NOT NULL ,
VA_ID SMALLINT NOT NULL,
V_STATES_ID SMALLINT NOT
NULL,
V_VOL VARCHAR(6),
V_OBJ_ID INT,
V_CELL SMALLINT,
V_POOL VARCHAR(255),
FOREIGN KEY(VA_ID) REFERENCES
TABLE2(VA_ID) ON DELETE CASCADE,
FOREIGN KEY(V_STATES_ID)
REFERENCES V_STATES(V_STATES_ID),
PRIMARY KEY(TABLE_ID));
We were trying to update V_VOL using following statement:
UPDATE TABLE1 SET V_VOL = 'ABCD' WHERE TABLE_ID = 100000
Regards,
Ravi
-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone.bigpanda.com]
Sent: Thursday, September 18, 2003 8:32 PM
To: Ravi T Ramachandra
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Postgresql UPDATE LOCKS unrelated rows.
On Thu, 18 Sep 2003, Ravi T Ramachandra wrote:
>
> Hi,
>
> We are using postgresql 7.3.2 on lunux platform. We performed
locking
> test as follows via JDBC:
>
> Started 2 concurrent transaction with autocommit false and isolation
> READ_COMMITTED :
>
> Transaction 1:
> ===========
> Update row 1
> Sleep for 30 seconds
> commit:
>
> Transaction 2:
> ===========
> Updated row 10000
> commit
>
> The second update had to wait for the first update operation to
> finish. We also made sure that the 2 unrelated rows are not on the
> same page.
>
> Is this expected behavior ?
> Does update lock the whole table ?
Generally not, but you really haven't given alot of information. What
is the table layout for the table in question? Are there foreign keys
involved?
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro
Limited is
'privileged' and 'confidential' and intended for use only by the
individual
or entity to which it is addressed. You are notified that any use,
copying
or dissemination of the information contained in the E-MAIL in any
manner
whatsoever is strictly prohibited.
***************************************************************************
---------------------------(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
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.
Attachments:
Untitled1 (text/html, 4.2K) download
<head></head><body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4><P>10:12a</P>
<P>Dear all,<BR>This is about the same problem which I have been facing for the past one week and which I am unable to solve. <BR>I have create a function which return +1 of the argument passed.</P>
<P>Function Definition:<BR>CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '<BR> BEGIN<BR> RETURN $1 + 1;<BR> END;<BR>' LANGUAGE 'plpgsql';<BR><BR>The output it was giving was always 1, despite any argument ( not string's ofcourse)<BR>When I viewed the function definition in the pg_proc table... <BR></P>
<P>psql "select proname,prosrc from pg_proc where proname='add_one'"<BR> proname | prosrc<BR>---------+-------------------------------------------------------<BR> add_one | BEGIN RETURN +1 END;<BR>(1 row)<BR>______________<BR>Can any body tell me why is the $1 missing.. <BR>I am using running postgres 7.3.4 in linux envt</P>
<P>Have a grate day</P><PRE>-----
Warm Regards
Shÿam Peri
II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003
Ph : 91-824-2451001/5
Fax : 91-824-2451050
</PRE><BR><BR>----------------Original Message------------------<BR><PRE>Subject : Re: [ADMIN] Postgresql UPDATE LOCKS unrelated rows.
Hi Stephan,
Here is the table structure. FYI, we tried the experiment with mysql
and the concurrency is working fine.
create table TABLE1( TABLE_ID IDENTITY NOT NULL ,
VA_ID SMALLINT NOT NULL,
V_STATES_ID SMALLINT NOT
NULL,
V_VOL VARCHAR(6),
V_OBJ_ID INT,
V_CELL SMALLINT,
V_POOL VARCHAR(255),
FOREIGN KEY(VA_ID) REFERENCES
TABLE2(VA_ID) ON DELETE CASCADE,
FOREIGN KEY(V_STATES_ID)
REFERENCES V_STATES(V_STATES_ID),
PRIMARY KEY(TABLE_ID));
We were trying to update V_VOL using following statement:
UPDATE TABLE1 SET V_VOL = 'ABCD' WHERE TABLE_ID = 100000
Regards,
Ravi
-----Original Message-----
From: Stephan Szabo [mailto:sszabo@megazone.bigpanda.com]
Sent: Thursday, September 18, 2003 8:32 PM
To: Ravi T Ramachandra
Cc: pgsql-admin@postgresql.org
Subject: Re: [ADMIN] Postgresql UPDATE LOCKS unrelated rows.
On Thu, 18 Sep 2003, Ravi T Ramachandra wrote:
>
> Hi,
>
> We are using postgresql 7.3.2 on lunux platform. We performed
locking
> test as follows via JDBC:
>
> Started 2 concurrent transaction with autocommit false and isolation
> READ_COMMITTED :
>
> Transaction 1:
> ===========
> Update row 1
> Sleep for 30 seconds
> commit:
>
> Transaction 2:
> ===========
> Updated row 10000
> commit
>
> The second update had to wait for the first update operation to
> finish. We also made sure that the 2 unrelated rows are not on the
> same page.
>
> Is this expected behavior ?
> Does update lock the whole table ?
Generally not, but you really haven't given alot of information. What
is the table layout for the table in question? Are there foreign keys
involved?
**************************Disclaimer************************************
Information contained in this E-MAIL being proprietary to Wipro
Limited is
'privileged' and 'confidential' and intended for use only by the
individual
or entity to which it is addressed. You are notified that any use,
copying
or dissemination of the information contained in the E-MAIL in any
manner
whatsoever is strictly prohibited.
***************************************************************************
---------------------------(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</PRE></body><br><br><b>
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.</b>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: error with functions
2003-09-22 04:22 error with functions shyamperi@davlin.co.in
@ 2003-09-22 05:01 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 0 replies; 12+ messages in thread
From: Stephan Szabo @ 2003-09-22 05:01 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: pgsql-admin
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> Dear all,
> This is about the same problem which I have been facing for the past one week and which I am unable to solve.
> I have create a function which return +1 of the argument passed.
> Function Definition:
> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '
> BEGIN
> RETURN $1 + 1;
> END;
> ' LANGUAGE 'plpgsql';
>
> The output it was giving was always 1, despite any argument ( not string's ofcourse)
> When I viewed the function definition in the pg_proc table...
>
> psql "select proname,prosrc from pg_proc where proname='add_one'"
> proname | prosrc
> ---------+-------------------------------------------------------
> add_one | BEGIN RETURN +1 END;
> (1 row)
> ______________
> Can any body tell me why is the $1 missing..
> I am using running postgres 7.3.4 in linux envt
> Have a grate day
How are you creating the function?
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: error with functions
@ 2003-09-22 04:48 shyamperi@davlin.co.in
2003-09-22 05:54 ` Re: error with functions Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 1 reply; 12+ messages in thread
From: shyamperi@davlin.co.in @ 2003-09-22 04:48 UTC (permalink / raw)
To: pgsql-admin
Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS ' BEGIN REURN $1 + 1; END; ' LANGUAGE 'plpgsql';"
Result: CREATE FUNCTION
And the function executed perfectly fine.
-----
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------------------
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> Dear all,
> This is about the same problem which I have been facing for the past
one week and which I am unable to solve.
> I have create a function which return +1 of the argument passed.
> Function Definition:
> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '
> BEGIN
> RETURN $1 + 1;
> END;
> ' LANGUAGE 'plpgsql';
>
> The output it was giving was always 1, despite any argument ( not
string's ofcourse)
> When I viewed the function definition in the pg_proc table...
>
> psql "select proname,prosrc from pg_proc where proname='add_one'"
> proname | prosrc
> ---------+-------------------------------------------------------
> add_one | BEGIN RETURN +1 END;
> (1 row)
> ______________
> Can any body tell me why is the $1 missing..
> I am using running postgres 7.3.4 in linux envt
> Have a grate day
How are you creating the function?
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.
Attachments:
Untitled1 (text/html, 2.0K) download
<head></head><body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4><P>Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS ' BEGIN REURN $1 + 1; END; ' LANGUAGE 'plpgsql';"</P>
<P>Result: CREATE FUNCTION</P>
<P>And the function executed perfectly fine.<BR></P><PRE>-----
Warm Regards
Shÿam Peri
II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003
Ph : 91-824-2451001/5
Fax : 91-824-2451050
</PRE><BR><BR>----------------Original Message------------------<BR><PRE>
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> Dear all,
> This is about the same problem which I have been facing for the past
one week and which I am unable to solve.
> I have create a function which return +1 of the argument passed.
> Function Definition:
> CREATE FUNCTION add_one (integer) RETURNS INTEGER AS '
> BEGIN
> RETURN $1 + 1;
> END;
> ' LANGUAGE 'plpgsql';
>
> The output it was giving was always 1, despite any argument ( not
string's ofcourse)
> When I viewed the function definition in the pg_proc table...
>
> psql "select proname,prosrc from pg_proc where proname='add_one'"
> proname | prosrc
> ---------+-------------------------------------------------------
> add_one | BEGIN RETURN +1 END;
> (1 row)
> ______________
> Can any body tell me why is the $1 missing..
> I am using running postgres 7.3.4 in linux envt
> Have a grate day
How are you creating the function?</PRE></body><br><br><b>
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.</b>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: error with functions
2003-09-22 04:48 Re: error with functions shyamperi@davlin.co.in
@ 2003-09-22 05:54 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 0 replies; 12+ messages in thread
From: Stephan Szabo @ 2003-09-22 05:54 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: pgsql-admin
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
> INTEGER AS ' BEGIN REURN $1 + 1; END; ' LANGUAGE
> 'plpgsql';"
You do realize that the shell is going to interpret that string in
double quotes right?
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: error with functions
@ 2003-09-22 05:42 shyamperi@davlin.co.in
2003-09-22 15:43 ` Re: error with functions Oliver Elphick <olly@lfix.co.uk>
2003-09-22 15:43 ` Re: error with functions Stephan Szabo <sszabo@megazone.bigpanda.com>
0 siblings, 2 replies; 12+ messages in thread
From: shyamperi@davlin.co.in @ 2003-09-22 05:42 UTC (permalink / raw)
To: pgsql-admin
>You do realize that the shell is going to interpret that string in
>double quotes right?
I guess so, for the very same I have tried with
Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE
'plpgsql';"
But still it is not taking it as $1, instead empty string.
Ideeally it shud consider $1 as string... but why isn't it
-----
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------------------
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
> INTEGER AS ' BEGIN REURN $1 + 1; END; ' LANGUAGE
> 'plpgsql';"
You do realize that the shell is going to interpret that string in
double quotes right?
---------------------------(end of
broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org
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.
Attachments:
Untitled1 (text/html, 1.6K) download
<head></head><body marginwidth=4 marginheight=4 topmargin=4 leftmargin=4><P>>You do realize that the shell is going to interpret that string in<BR>>double quotes right?<BR>I guess so, for the very same I have tried with<BR>Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS<BR> INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE<BR> 'plpgsql';"<BR>But still it is not taking it as $1, instead empty string.<BR>Ideeally it shud consider $1 as string... but why isn't it<BR><BR></P><PRE>-----
Warm Regards
Shÿam Peri
II Floor, Punja Building,
M.G.Road,
Ballalbagh,
Mangalore-575003
Ph : 91-824-2451001/5
Fax : 91-824-2451050
</PRE><BR><BR>----------------Original Message------------------<BR><PRE>
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
> INTEGER AS ' BEGIN REURN $1 + 1; END; ' LANGUAGE
> 'plpgsql';"
You do realize that the shell is going to interpret that string in
double quotes right?
---------------------------(end of
broadcast)---------------------------
TIP 1: subscribe and unsubscribe commands go to
majordomo@postgresql.org</PRE></body><br><br><b>
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.</b>
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: error with functions
2003-09-22 05:42 Re: error with functions shyamperi@davlin.co.in
@ 2003-09-22 15:43 ` Oliver Elphick <olly@lfix.co.uk>
1 sibling, 0 replies; 12+ messages in thread
From: Oliver Elphick @ 2003-09-22 15:43 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: pgsql-admin
On Mon, 2003-09-22 at 06:42, shyamperi@davlin.co.in wrote:
> >You do realize that the shell is going to interpret that string in
> >double quotes right?
> I guess so, for the very same I have tried with
> Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
> INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE
> 'plpgsql';"
> But still it is not taking it as $1, instead empty string.
> Ideeally it shud consider $1 as string... but why isn't it
It's still being interpreted by the shell. The shell takes no notice at
all of the nested quotes; everything inside the double quotes is treated
as literal text, after replacing variables. Look here:
olly@linda$ echo psql test -c "> CREATE FUNCTION add_one
(integer) RETURNS INTEGER AS ' BEGIN RETURN ''$1'' +
1; END; ' LANGUAGE 'plpgsql';"
psql test -c > CREATE FUNCTION add_one (integer) RETURNS INTEGER
AS ' BEGIN RETURN '''' + 1; END; ' LANGUAGE
'plpgsql';
Instead of trying to quote $1, you need to escape the dollar sign:
olly@linda$ echo psql test -c "> CREATE FUNCTION add_one
(integer) RETURNS INTEGER AS ' BEGIN RETURN \$1 +
1; END; ' LANGUAGE 'plpgsql';"
psql test -c > CREATE FUNCTION add_one (integer) RETURNS INTEGER
AS ' BEGIN RETURN $1 + 1; END; ' LANGUAGE
'plpgsql';
--
Oliver Elphick Oliver.Elphick@lfix.co.uk
Isle of Wight, UK http://www.lfix.co.uk/oliver
GPG: 1024D/3E1D0C1C: CA12 09E0 E8D5 8870 5839 932A 614D 4C34 3E1D 0C1C
========================================
"Therefore when thou doest thine alms, do not sound a
trumpet before thee, as the hypocrites do in the
synagogues and in the streets, that they may have
glory of men. Verily I say unto you, They have their
reward. But when thou doest alms, let not thy left
hand know what thy right hand doeth; That thine alms
may be in secret; and thy Father which seeth in secret
himself shall reward thee openly." Matthew 6:2-4
^ permalink raw reply [nested|flat] 12+ messages in thread
* Re: error with functions
2003-09-22 05:42 Re: error with functions shyamperi@davlin.co.in
@ 2003-09-22 15:43 ` Stephan Szabo <sszabo@megazone.bigpanda.com>
1 sibling, 0 replies; 12+ messages in thread
From: Stephan Szabo @ 2003-09-22 15:43 UTC (permalink / raw)
To: shyamperi@davlin.co.in; +Cc: pgsql-admin
On Mon, 22 Sep 2003 shyamperi@davlin.co.in wrote:
> >You do realize that the shell is going to interpret that string in
> >double quotes right?
> I guess so, for the very same I have tried with
> Command: psql test -c "> CREATE FUNCTION add_one (integer) RETURNS
> INTEGER AS ' BEGIN RETURN ''$1'' + 1; END; ' LANGUAGE
> 'plpgsql';"
> But still it is not taking it as $1, instead empty string.
> Ideeally it shud consider $1 as string... but why isn't it
The shell interprets the double quoted string and effectively replaces $1
with the shell's idea of what to put in place of it. This really has
nothing to do with postgres at all. Use a backslash before the $1, or
put it in a file and execute it from there.
Try these for example:
echo "$1"
echo '$1'
echo "\$1"
^ permalink raw reply [nested|flat] 12+ messages in thread
end of thread, other threads:[~2003-09-22 15:43 UTC | newest]
Thread overview: 12+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-09-20 06:24 Error with functions shyamperi@davlin.co.in
2003-09-20 06:58 ` Tomasz Myrta <jasiek@klaster.net>
2003-09-20 07:29 ` Jean-Michel Chabanne <jeanmichel.chabanne@free.fr>
2003-09-20 11:16 Re: Error with functions shyamperi@davlin.co.in
2003-09-20 16:02 ` Tom Lane <tgl@sss.pgh.pa.us>
2003-09-22 04:22 error with functions shyamperi@davlin.co.in
2003-09-22 05:01 ` Re: error with functions Stephan Szabo <sszabo@megazone.bigpanda.com>
2003-09-22 04:48 Re: error with functions shyamperi@davlin.co.in
2003-09-22 05:54 ` Re: error with functions Stephan Szabo <sszabo@megazone.bigpanda.com>
2003-09-22 05:42 Re: error with functions shyamperi@davlin.co.in
2003-09-22 15:43 ` Re: error with functions Oliver Elphick <olly@lfix.co.uk>
2003-09-22 15:43 ` Re: error with functions Stephan Szabo <sszabo@megazone.bigpanda.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox