From: | Hugo <htakada(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | psql newby question, help to port Sybase ASA StoredProcedure |
Date: | 2005-06-13 16:52:12 |
Message-ID: | f3d9ba9905061309522484cf9a@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Hi, can you give me hints to port this ASA stored procesure
ALTER procedure dba.sp_billetes(in p_importe numeric(15))
result(cien_mil numeric(3),cincuenta_mil numeric(3),diez_mil
numeric(3),cinco_mil numeric(3),mil numeric(3),quinientos numeric(3),cien
numeric(3),cincuenta numeric(3),diez numeric(3),cinco numeric(3),uno
numeric(3))
begin
declare v_divisor numeric(15);
declare v_resto numeric(15);
declare v_cociente numeric(15);
declare v_monto numeric(15);
declare v_100mil numeric(3);
declare v_50mil numeric(3);
declare v_10mil numeric(3);
declare v_5mil numeric(3);
declare v_1000 numeric(3);
declare v_500 numeric(3);
declare v_100 numeric(3);
declare v_50 numeric(3);
declare v_10 numeric(3);
declare v_5 numeric(3);
declare v_1 numeric(3);
declare i integer;
set v_monto=p_importe;
set i=1;
while i < 12 loop
case i
when 1 then
set v_100mil=truncnum((v_monto/100000),0);
set v_monto=mod(v_monto,100000)
when 2 then
set v_50mil=truncnum((v_monto/50000),0);
set v_monto=mod(v_monto,50000)
when 3 then
set v_10mil=truncnum((v_monto/10000),0);
set v_monto=mod(v_monto,10000)
when 4 then
set v_5mil=truncnum((v_monto/5000),0);
set v_monto=mod(v_monto,5000)
when 5 then
set v_1000=truncnum((v_monto/1000),0);
set v_monto=mod(v_monto,1000)
when 6 then
set v_500=truncnum((v_monto/500),0);
set v_monto=mod(v_monto,500)
when 7 then
set v_100=truncnum((v_monto/100),0);
set v_monto=mod(v_monto,100)
when 8 then
set v_50=truncnum((v_monto/50),0);
set v_monto=mod(v_monto,50)
when 9 then
set v_10=truncnum((v_monto/10),0);
set v_monto=mod(v_monto,10)
when 10 then
set v_5=truncnum((v_monto/5),0);
set v_monto=mod(v_monto,5)
when 11 then
set v_1=truncnum((v_monto/1),0);
set v_monto=mod(v_monto,1)
end case
;
set i=i+1
end loop;
select v_100mil,v_50mil,v_10mil,v_5mil,v_1000,v_500,v_100,v_50,v_10,v_5,v_1
end
thanks in advance for any help you could provide.
Hugo
From | Date | Subject | |
---|---|---|---|
Next Message | Dan Black | 2005-06-13 17:55:59 | Index does not working. |
Previous Message | Eric E | 2005-06-13 16:41:42 | Re: return next and pl/perl |