Re: Simple math statement - problem

From: Lew <lew(at)lwsc(dot)ehost-services(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Simple math statement - problem
Date: 2007-12-01 08:01:52
Message-ID: S6ydndUPsOZsiczanZ2dnUVZ_v2pnZ2d@comcast.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Postgres User wrote:
>>> The problem turned out to be related to my function..
>>>
>>> Given this table:
>>>
>>> CREATE TABLE "table2" (
>>> "s_val" numeric(6,2),
>>> "e_val" numeric(6,2)
>>> ) WITH OIDS;
>>>

I am curious what would happen if you wrote your procedure like this:

declare
retval numeric(6,2);
rec table2%ROWTYPE;
begin
rec.s_val = 100;
rec.e_val = 101;
retval = (rec.s_val - rec.e_val) / rec.s_val;

return retval;
end

Also, one wonders why you need to do the calculation via a row or record at
all, when it would seem so easy just to plug in the values.

--
Lew

In response to

Browse pgsql-general by date

  From Date Subject
Next Message rihad 2007-12-01 08:02:23 full_page_writes = off?
Previous Message Lew 2007-12-01 07:51:55 Re: Simple math statement - problem