plsql - How do i format Oracle Output for this Block? -
i'm stuck on block of statements , don't know how program output when code runs show amount of payment $10.00 , balance remaining in same format. code prompts me twice idpledge... i've got markup in code topics don't quite understand. using oracle 11g 2e , book isn't helpful. if there recommendation beginner books or resources listening (reading). code below:
set serveroutput on; declare pay_num number(2) := 0; /*initialize 0 */ loop_count number(2) := 12; /*intialize max number of months */ pay_amt number(8,2); pledge_bal number(8,2); v_pledgeamt number(8,2); start_date date := '04-oct-2012'; due_date date; v_due_date varchar2(15); begin select pledgeamt v_pledgeamt dd_pledge idpledge=&idpledge; pay_amt := (v_pledgeamt / loop_count); due_date := start_date; pledge_bal := (v_pledgeamt - pay_amt); in 1..loop_count loop pay_num := pay_num + 1; v_due_date := to_char(due_date, 'mm-dd-yyyy'); due_date := add_months(due_date, 1); pledge_bal := (pledge_bal - pay_amt); dbms_output.put_line ( 'payment num: ' || pay_num || ' ' || 'due date: ' || v_due_date || ' ' || 'amount due: ' || pay_amt || ' ' || 'balance: ' || to_char(pledge_bal, '$')); /* how format $*/ end loop; end;
as mentioned @ docs can use to_char proper formatter. in case to_char(pledge_bal, '$9,999.99')
using format '$9,999.99' fulfills following objectives :
returns comma in specified position. can specify multiple commas in number format model.
returns decimal point, period (.) in specified position.
returns value leading dollar sign.
if required can check more parameters @ link mentioned.
Comments
Post a Comment