From: Tom Lane <tgl@sss.pgh.pa.us>
To: geraldo <geraldo@umc.br>
Cc: pgsql-sql@postgresql.org
Subject: Re: function problem
Date: Tue, 21 Oct 2003 15:08:39 -0400
Message-ID: <5306.1066763319@sss.pgh.pa.us> (raw)
In-Reply-To: <AKEMKCHOALAOGDNFIGFAEEABCAAA.geraldo@umc.br>
References: <AKEMKCHOALAOGDNFIGFAEEABCAAA.geraldo@umc.br>
"geraldo" <geraldo@umc.br> writes:
> Can anybody tell me why the following code when activated
> by a select only affects the first line of the table???
> create or replace function increase(integer)
> returns void as 'update tab set price=price*(1+$1/100.0)'
> language sql;
Works fine here.
regression=# create table tab (price numeric);
CREATE TABLE
regression=# insert into tab values(1);
INSERT 154584 1
regression=# insert into tab values(10);
INSERT 154585 1
regression=# insert into tab values(100);
INSERT 154586 1
regression=# select * from tab;
price
-------
1
10
100
(3 rows)
regression=# create or replace function increase(integer)
regression-# returns void as 'update tab set price=price*(1+$1/100.0)'
regression-# language sql;
CREATE FUNCTION
regression=# select increase(42);
increase
----------
(1 row)
regression=# select * from tab;
price
--------------------------
1.42000000000000000000
14.20000000000000000000
142.00000000000000000000
(3 rows)
regression=#
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: tgl@sss.pgh.pa.us, geraldo@umc.br
Subject: Re: function problem
In-Reply-To: <5306.1066763319@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
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