From: | Jose Soares <jose(at)sferacarta(dot)com> |
---|---|
To: | Hitesh Patel <hitesh(at)presys(dot)com> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: [GENERAL] Need help creating a function |
Date: | 2000-02-04 13:33:24 |
Message-ID: | 389AD524.2D1CA0BC@sferacarta.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
create function money(float8) returns money as '
declare
f2 float8;
m money;
i2 int2;
i1 int4;
txt text;
begin
if $1 isnull then
return NULL;
end if;
--integer part...
i1:= dtrunc($1);
-- decimal part...
i2:= dround(datetime_part(''millisecond'',$1));
-- cut 3th digit...
txt:= dround(i2/10.0);
if textlen(txt) = 1 then
txt:= ''0'' || txt;
end if;
m:= i1 || (''.'' || txt);
return m;
end; ' language 'plpgsql';
Hitesh Patel wrote:
> Does anyone have a function laying around that convert a 'money' type to
> a float8 and return it?
>
> ************
--
Jose' Soares
Bologna, Italy Jose(at)sferacarta(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Mark Hollomon | 2000-02-04 13:49:20 | Re: [HACKERS] Re: [SQL] Proposed Changes to PostgreSQL |
Previous Message | Marc Tardif | 2000-02-04 13:00:03 | Re: [GENERAL] using ID as a key |