0

I'm getting the above error while trying to execute Stored procedure from BIRT. Please let me know the right way to call a Stored Procedure from BIRT. My SP runs a series of command and Insert rows in a table. I've to build a report by first calling the SP and query the data from that table. As the report will be imported into Maximo, not sure if I can use the JDBC connection!

Below is my Procedure:

CREATE OR REPLACE PROCEDURE MAXIMO.P_CCNBDET
    (V_ACC VARCHAR2, 
    V_CYID VARCHAR2, 
    V_YMNTH VARCHAR2)
    AS 
        V_CCSD date;
        V_CCED date;
        V_RUNDT  date;

BEGIN

 Delete from maximo.P_CCNBDET where accountnum = V_ACC and cycleid = V_CYID and billyearmonth = V_YMNTH;
 COMMIT;
 select startdate into V_CCSD from maximo.cyclemaster where cycleid = V_CYID and billyearmonth = V_YMNTH; 
 select enddate into V_CCED from maximo.cyclemaster where cycleid = V_CYID and billyearmonth = V_YMNTH; 
 select rundate into V_RUNDT from maximo.cyclemaster where cycleid = V_CYID and billyearmonth = V_YMNTH; 
 ------- Install Begins------------------
DECLARE CURSOR c1 IS
select 
0 as hasld,
'EN' as LANGCODE,
accountnum as accountnum,
itemnum as itemnum,
INVESTBY as INVESTBY,
sum(ct) as ct1 
from
(
select 
accountnum as accountnum ,
itemnum as itemnum,
INVESTBY as INVESTBY,
billstatus as billstatus ,
sum(((billenddate - billbegindate)/30)) as ct 
from 
maximo.sparepart where siteid = 'TD' and billstatus in ('I') and  BILLENDDATE =V_CCED and accountnum = V_ACC
group by accountnum,itemnum,INVESTBY,billstatus

union all

select 
accountnum as accountnum ,
itemnum as itemnum,
INVESTBY as INVESTBY,
billstatus as billstatus ,
sum(((billenddate - billbegindate)/30)) as ct 
from 
maximo.sparepart where siteid = 'TD' and billstatus in ('C') and BILLENDDATE   >= V_CCSD and BILLENDDATE   <= V_CCED and accountnum = V_ACC
group by accountnum,itemnum,INVESTBY,billstatus

union all

select   
accountnum as accountnum ,
itemnum as itemnum,
INVESTBY as INVESTBY,
billstatus as billstatus ,
count(1) as ct 
from maximo.sparepart where siteid = 'TD' 
and  billstatus in ('B') and BILLENDDATE is  null and BILLBEGINDATE< V_CCED and accountnum = V_ACC
group by accountnum,itemnum,investby,billstatus
)
group by accountnum,itemnum,INVESTBY;

            BEGIN
                FOR 
                    sched_rec IN
                    c1 LOOP
                        insert into 
                        maximo.ccnbdet
                        (
                            CCNBDETID,
                            HASLD,
                            LANGCODE,
                            ACCOUNTNUM,
                            ITEMNUM,
                            INVESTBY,
                            AVG,
                            SITEID,
                            ORGID,
                            ROWSTAMP,
                            BILLSTATUS,
                            RUNDATE,
                            CYCLEID,
                            BILLYEARMONTH,
                            STARTDATE,
                            ENDDATE
                        )
                        select  
                          maximo.CCNBDETIDSEQ.NEXTVAL,
                          sched_rec.hasld,
                          sched_rec.LANGCODE,
                          sched_rec.accountnum,
                          sched_rec.itemnum,
                          sched_rec.INVESTBY,
                          sched_rec.ct1,
                          'PQR',
                          'XYZ',
                          1,
                          'X',
                          V_RUNDT,
                          V_CYID,
                          V_YMNTH,
                          V_CCSD,
                          V_CCED
                          from dual;
                      END LOOP;

            END;
            COMMIT;

DECLARE CURSOR c2 IS
select 
0 as hasld,
'EN' as LANGCODE,
accountnum as accountnum,
itemnum as itemnum,
INVESTBY as INVESTBY,
BILLSTATUS as BILLSTATUS,
sum(ct) as ct1 from
(
select 
accountnum as accountnum ,
itemnum as itemnum,
INVESTBY as INVESTBY,
billstatus as billstatus ,
sum((( (V_CCSD-1) - billbegindate)/30)) as ct 
from 
maximo.sparepart where siteid = 'TD' and billstatus in ('Z') and  billyearmonth = V_YMNTH and accountnum = V_ACC
group by accountnum,itemnum,INVESTBY,billstatus

union all

select 
accountnum as accountnum ,
itemnum as itemnum,
INVESTBY as INVESTBY,
billstatus as billstatus ,
sum((( (V_CCSD-1) - billenddate)/30)) as ct 
from 
maximo.sparepart where siteid = 'TD' and billstatus in ('R') and billyearmonth = V_YMNTH and accountnum = V_ACC
group by accountnum,itemnum,INVESTBY,billstatus
)
group by accountnum,itemnum,INVESTBY,BILLSTATUS;

            BEGIN
                FOR
                      sched_rec1 IN
                    c2 LOOP
                    insert into 
                    maximo.ccnbdet
                    (
                        CCNBDETID,
                        HASLD,
                        LANGCODE,
                        ACCOUNTNUM,
                        ITEMNUM,
                        INVESTBY,
                        AVG,
                        SITEID,
                        ORGID,
                        ROWSTAMP,
                        BILLSTATUS,
                        RUNDATE,
                        CYCLEID,
                        BILLYEARMONTH,
                        STARTDATE,
                        ENDDATE
                    )
                    select  
                      maximo.CCNBDETIDSEQ.NEXTVAL,
                      sched_rec1.hasld,
                      sched_rec1.LANGCODE,
                      sched_rec1.accountnum,
                      sched_rec1.itemnum,
                      sched_rec1.INVESTBY,
                      sched_rec1.ct1,
                      'PQR',
                      'XYZ',
                      1,
                      sched_rec1.BILLSTATUS,
                      V_RUNDT,
                      V_CYID,
                      V_YMNTH,
                      V_CCSD,
                      V_CCED
                      from dual;
                      END LOOP;

            END;
            COMMIT;
    End;
XING
  • 9,608
  • 4
  • 22
  • 38
  • 1
    Post your procedure body as well and show us how you call it; – XING Sep 08 '16 at 07:18
  • Hi Xing, I've added my procedure above and I'm calling it in BIRT by following the below link: [link] (https://www.ibm.com/developerworks/community/blogs/a9ba1efe-b731-4317-9724-a181d6155e3a/entry/stored_procedures_and_maximo_reporting6?lang=en) – Vaibhav Patidar Sep 09 '16 at 06:39
  • You forgot to mention the error you are getting – XING Sep 09 '16 at 07:53
  • I've never heard of BIRT and your link is about DB2, but the technique seems to be for procedures that return ref cursors. That would explain why this BIRT framework fails when it attempts to fetch the next row, because your procedure doesn't return anything. – William Robertson Sep 12 '16 at 15:26

0 Answers0