X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id 0E17ED1B518 for ; Tue, 21 Oct 2003 19:09:11 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 28191-08 for ; Tue, 21 Oct 2003 16:08:40 -0300 (ADT) Received: from sss.pgh.pa.us (unknown [192.204.191.242]) by svr1.postgresql.org (Postfix) with ESMTP id F3180D1B50C for ; Tue, 21 Oct 2003 16:08:38 -0300 (ADT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss.pgh.pa.us (8.12.10/8.12.10) with ESMTP id h9LJ8dit005307; Tue, 21 Oct 2003 15:08:40 -0400 (EDT) To: "geraldo" Cc: pgsql-sql@postgresql.org Subject: Re: function problem In-reply-to: References: Comments: In-reply-to "geraldo" message dated "Tue, 21 Oct 2003 10:25:14 -0200" Date: Tue, 21 Oct 2003 15:08:39 -0400 Message-ID: <5306.1066763319@sss.pgh.pa.us> From: Tom Lane X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200310/279 X-Sequence-Number: 15679 "geraldo" 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