Saturday, 7 January 2012

switch case in oracle


create or replace
PROCEDURE P_GET_ALLTRANSACTIONS_REPORTS
(
  FROMDATE IN VARCHAR2,
  TODATE IN VARCHAR2,
  VLE_ID1 IN VARCHAR2,
  report out sys_refcursor
)
AS
BEGIN
open report for
SELECT  distinct tm.txn_id as "TXNNO",tm.service_id as "SERID", tm.TXN_DATETIME as "Transaction Date",
        tm.cONSUMER_NAME as "Customer Name",
        tm.cONSUMER_MOBILE as "Mobile No",
        ms.SERVICE_NAME as "Service Name",
          (
            CASE ms.SERVICE_NAME
                 WHEN 'Mobile / DTH Recharge' THEN tr.operator_name
            else mp.PROVIDER_NAME 
            END
           ) as "Serviceprovider/Operator",
       tm.AMOUNT as "Transaction Amount"
FROM  mst_provider mp
inner join mst_service ms on mp.provider_id=ms.provider_id
inner join  txn_master tm on ms.service_id =tm.service_id
inner join txn_recharge tr on (tr.txn_no,tr.mobileno,tr.vle_id,tr.amount,tr.lastupdate) in
                                                                    (
                                                                       select distinct
                                                                       txn_id,consumer_mobile,vle_id,amount,last_update
                                                                       from txn_master
                                                                       where vle_id=VLE_ID1
                                                                    )
where ((tm.TXN_DATETIME  between to_date(FROMDATE  ,'DD-MM-YY') AND to_date(TODATE,'DD-MM-YY')+1) and (tm.vle_id=VLE_ID1))
order by tm.TXN_DATETIME desc;
END P_GET_ALLTRANSACTIONS_REPORTS;

No comments:

Post a Comment