My procedure which needs to call through shell script
CREATE OR REPLACE package body IRS_TIN.f1099k_data as
procedure create_1099k_data
(errcode out varchar2
errmsg out varchar2,
retcur out refcursor,
p_ptfolio_id in varchar2,
p_startdt in varchar2,
p_enddt in varchar2)
is proc_name varchar2(50) default 'create_1099k_data'||to_char(sysdate, 'YYYYMMDDHH24MISS');
begin
errcode :=0;
errmsg :=null;
for ptcr in ( Select ptfolio_id,ptfolio_name,
source_system,network_id
from portfolio_merchants
where ptfolio_id = p_ptfolio_id
and network_id = '06293870001' )
loop
merge into tr_1099k_data b
using ( Select pmx.source_system,
pmx.network_id,
pe.payee_id,
pct.pse_id, pct.epf_id,
'2011' yyyy,
sum( case when substr (reporting_month, 5,2) = '01' then grs else 0 end ) jan_grs,
sum( case when substr (reporting_month, 5,2) = '02' then grs else 0 end ) feb_grs,
sum( case when substr (reporting_month, 5,2) = '03' then grs else 0 end ) mar_grs,
sum( case when substr (reporting_month, 5,2) = '04' then grs else 0 end ) apr_grs,
sum( case when substr (reporting_month, 5,2) = '05' then grs else 0 end ) may_grs,
sum( case when substr (reporting_month, 5,2) = '06' then grs else 0 end ) jun_grs,
sum( case when substr (reporting_month, 5,2) = '07' then grs else 0 end ) jul_grs,
sum( case when substr (reporting_month, 5,2) = '08' then grs else 0 end ) aug_grs,
sum( case when substr (reporting_month, 5,2) = '09' then grs else 0 end ) sep_grs,
sum( case when substr (reporting_month, 5,2) = '10' then grs else 0 end ) oct_grs,
sum( case when substr (reporting_month, 5,2) = '11' then grs else 0 end ) nov_grs,
sum( case when substr (reporting_month, 5,2) = '12' then grs else 0 end ) dec_grs,
sum( txn_cnt) txn_cnt
from payee pe,
payee_merchant_xref pmx,
portfolio_merchants pm,
ptfolio_card_type_payer_xref pct,
mthly_grs mg
where pe.payee_id = pmx.payee_id
and pmx.source_system = pm.source_system
and pmx.network_id = pm.network_id
and pm.ptfolio_id = pct.ptfolio_id
and pmx.source_system = mg.source_system
and pmx.network_id = mg.network_id
and pct.product_code = mg.product_code
-- Parameters
and pmx.network_id = ptcr.network_id
and pct.ptfolio_id = ptcr.ptfolio_id
group by pe.payee_id,
pmx.source_system,
pmx.network_id,
pct.pse_id,
pct.epf_id ) t
on ( b.payee_id = t.payee_id and
b.source_system = t.source_system and
b.network_id = t.network_id and
b.pse_id = t.pse_id and
b.epf_id = t.epf_id and
b.yyyy = t.yyyy )
when matched then
update set b.jan_grs = b.jan_grs + t.jan_grs,
b.feb_grs = b.feb_grs + t.feb_grs,
b.mar_grs = b.mar_grs + t.mar_grs,
b.apr_grs = b.apr_grs + t.apr_grs,
b.may_grs = b.may_grs + t.may_grs,
b.jun_grs = b.jun_grs + t.jun_grs,
b.jul_grs = b.jul_grs + t.jul_grs,
b.aug_grs = b.aug_grs + t.aug_grs,
b.sep_grs = b.sep_grs + t.sep_grs,
b.oct_grs = b.oct_grs + t.oct_grs,
b.nov_grs = b.nov_grs + t.nov_grs,
b.dec_grs = b.dec_grs + t.dec_grs,
b.txn_cnt = b.txn_cnt + t.txn_cnt,
modified_by= 'f1099k_data.pkb',
modified_date= sysdate
when not matched then
insert ( id,
payee_id,
source_system,
network_id,
pse_id,
epf_id,
jan_grs,
feb_grs,
mar_grs,
apr_grs,
may_grs,
jun_grs,
jul_grs,
aug_grs,
sep_grs,
oct_grs,
nov_grs,
dec_grs,
txn_cnt,
yyyy,
form_status,
status,
status_comments,
created_date,
created_by)
values (tr1099kd_seq.nextval,
t.payee_id,
t.source_system,
t.network_id,
t.pse_id, t.epf_id,
t.jan_grs,
t.feb_grs,
t.mar_grs,
t.apr_grs,
t.may_grs,
t.jun_grs,
t.jul_grs,
t.aug_grs,
t.sep_grs,
t.oct_grs,
t.nov_grs,
t.dec_grs,
t.txn_cnt,
t.yyyy,
'OR',
'PENDING', 'INITIAL',
sysdate, 'f1099k_data.pkb');
end loop;
end;
procedure create_1099k_data
(errcode out varchar2,
errmsg out varchar2,
retcur out refcursor,
ptfolio_id in varchar)
is
startdtchar(10) default to_char(last_day(add_months(sysdate,-2))+1,'YYYYMMDD');
enddt char(10) default to_char(last_day(add_months(sysdate,-1)),'YYYYMMDD');
begin
create_1099k_data (errcode, errmsg, retcur, ptfolio_id, startdt, enddt);
dbms_output.put_line('ERRCODE-'||errcode||':'||'ERRORMSG-'||errmsg);
end;
end f1099k_data;
---------- Post updated at 09:52 PM ---------- Previous update was at 09:49 PM ----------
Table name is portfolio
and column name is portfolio_id
which is also the IN parameter of the procedure