Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multiple DBMS_OUTPUT.PUT_LINE Outputs

Dj SteeleMar 24 2018 — edited Apr 3 2018

Good Day Community I am using Oracle XE with SQL Developer with the below If Then ElsIF  Statement Below (looking at 2 Outputs now but looking to add 4 more  ElsIF Else Statements) How can I see the output of each Statement ?    Am I utilizing DBMS_OUTPUT.PUT_LINE Correctly I am only getting OUTPUT from the first intial IF THEN  but not  ElsIF Thanks Community DSteele41 --Postage 25.35  but 0.00 for Refunds  ,  Tax =8.63  on 100.00  ,  SubTotal = 100.00  Receipt Amount (Total) = 108.63 DECLARE   v_local_tax_rate number(7,5);   v_state_tax_rate number(7,5);   v_orig_receipt_date Date;   P10_Refund_type1 char(1)  := 'f';   P10_Refund_type2 char(1)  := 'p';   P10_Refund_type3 char(1)  := 't';     P10_Taxable1 char(1)  := 'Y';   P10_Taxable2 char(1)  := 'N';     P10_POSTAGE  Number (11,2) := 0.00;   P10_SUBTOTAL Number (11,2) := 100.00;   P10_TAX      Number(11,2);   P10_RECEIPT_AMOUNT Number(11,2);     P10_REFUNDED_RECPT_NMBR varchar2(12) := '9000000690';   BEGIN     IF P10_REFUND_TYPE1 = 'f' and P10_Taxable1 = 'Y' -------------------------------REFUND TYPE FULL & TAXABLE YES     -- get Original Receipt Date     THEN                select receiptdate               into v_orig_receipt_date               from receiptdetail               where receiptnumber = P10_REFUNDED_RECPT_NMBR;                             -- get current tax rates               select a.tax_rate               into v_local_tax_rate               from tax_rates a               where upper(a.tax_type)= 'LOCAL'               and a.effective_date = (select max(b.effective_date)                                   from tax_rates b                                   where a.tax_type=b.tax_type                                   and b.effective_date <= v_orig_receipt_date);             select a.tax_rate               into v_state_tax_rate               from tax_rates a               where upper(a.tax_type)= 'STATE'               and a.effective_date = (select max(b.effective_date)                                   from tax_rates b                                   where a.tax_type=b.tax_type                                     and b.effective_date <=  v_orig_receipt_date);                         P10_TAX := Round(P10_SUBTOTAL *  ((v_local_tax_rate +  v_state_tax_rate) /100),2);                                  P10_RECEIPT_AMOUNT :=  P10_SUBTOTAL + P10_TAX +  P10_POSTAGE;             Dbms_Output.put_line(v_orig_receipt_date); Dbms_Output.put_line(v_local_tax_rate); Dbms_Output.put_line(v_state_tax_rate); Dbms_Output.put_line(P10_POSTAGE); Dbms_Output.put_line(P10_SUBTOTAL); Dbms_Output.put_line(P10_TAX); Dbms_Output.put_line(P10_RECEIPT_AMOUNT);                              ELSIF P10_REFUND_TYPE1 = 'f' and P10_Taxable2 = 'N' -------------------------------REFUND TYPE FULL & TAXABLE NO                                  THEN             select receiptdate               into v_orig_receipt_date               from receiptdetail               where receiptnumber = P10_REFUNDED_RECPT_NMBR;                             -- get current tax rates               select a.tax_rate               into v_local_tax_rate               from tax_rates a               where upper(a.tax_type)= 'LOCAL'               and a.effective_date = (select max(b.effective_date)                                   from tax_rates b                                   where a.tax_type=b.tax_type                                   and b.effective_date <= v_orig_receipt_date);             select a.tax_rate               into v_state_tax_rate               from tax_rates a               where upper(a.tax_type)= 'STATE'               and a.effective_date = (select max(b.effective_date)                                   from tax_rates b                                   where a.tax_type=b.tax_type                                     and b.effective_date <=  v_orig_receipt_date);                 P10_TAX := regexp_replace(regexp_replace(regexp_replace(P10_SUBTOTAL,'\,',''),'\<','-'),'\>','')  *  0;     P10_RECEIPT_AMOUNT := regexp_replace(regexp_replace(regexp_replace(P10_SUBTOTAL,'\,',''),'\<','-'),'\>','');      Dbms_Output.put_line(v_orig_receipt_date); Dbms_Output.put_line(v_local_tax_rate); Dbms_Output.put_line(v_state_tax_rate); Dbms_Output.put_line(P10_POSTAGE); Dbms_Output.put_line(P10_SUBTOTAL); Dbms_Output.put_line(P10_TAX); Dbms_Output.put_line(P10_RECEIPT_AMOUNT);            END IF;     END; --------------------------------------------------------------- Script Output: 15-MAR-18 4.125 4.5 0 100 8.63 108.63

This post has been answered by Gaz in Oz on Mar 24 2018
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 26 2018
Added on Mar 24 2018
20 comments
1,991 views