Stored Procedure: Extract data into second cursor

This is ready-to-run script with a commented out INCOMPLETE section of code where i need to select from a cursor.
--==  PDF Dcument Table of contents ==---
--==  PDF Report contains Period to date on condiments and bun sales for a region
--==  For each week for a 4-week period with week 6 representing PTD and week 7 representing
--==  YTD. Data should be gathered in rowsets and pivoted on client
--== 
--== Basic Functionallity:
--=== Write a stored procedure that performs the following:
--==  1) Select the report data into cursor 1  in the order with a resultset order
--==     in the way it will be printed to report.
--==  2) Create list of inique stores in separate cursor
--==  Approach: 
--== Create the Type object of fields needed to build table of contents for each row of the table. Add a sort field
--== to enable restore the original order of data after any sorting done on client 
--== Create table table of the row objects
--== Declare 2 cursors:
--   a) ) First cursor holds the data for the PDF Report  to be pivoted by the client
--   b) ) Second should contain a table of contents (unique storenbr) in the 
--== same order as the stores in the first cursor.
--== Oracle version 10g v2 on  W2K3
begin  execute immediate 'drop type TYP_TBL_CWSR_TOC'; exception when others then null; end;
begin  execute immediate 'drop type TYP_CWSR_TOC';  exception when others then null;  end;
begin execute immediate 'drop procedure Create_Rpt_and_TOC'; exception when others then null; end;
create or replace TYPE TYP_CWSR_TOC AS OBJECT
       (   sortcol         number             --== probably not needed, just in case
        ,  storenbr        varchar2(100)
        ,  storename       varchar2(200) 
create or replace TYPE TYP_TBL_CWSR_TOC AS TABLE OF TYP_CWSR_TOC;
create or replace procedure create_rpt_and_toc
     pc_report_data               OUT sys_refcursor
,    pc_TOC   OUT sys_refcursor     
AS
v_tblTOC        TYP_TBL_CWSR_TOC;
v_rec           TYP_CWSR_TOC := TYP_CWSR_TOC(NULL,NULL, NULL);
BEGIN
OPEN pc_report_data FOR
with  sample_data as
(    select 22 storeid , 1 week_nbr, 15942 net_sales, 372 buns, 176 condiments  from dual union all
      select 22 storeid , 6 week_nbr, 15942 net_sales, 372 buns, 176 condiments  from dual union all
      select 22 storeid , 7 week_nbr, 15942 net_sales, 372 buns, 176 condiments  from dual union all
      select 23 storeid , 1 week_nbr, 25302 net_sales, 481 buns, 221 condiments  from dual union all
      select 23 storeid , 6 week_nbr, 25302 net_sales, 481 buns, 221 condiments  from dual union all
      select 23 storeid , 7 week_nbr, 25302 net_sales, 481 buns, 221 condiments  from dual union all
      select 24 storeid , 1 week_nbr, 29347 net_sales, 598 buns, 238 condiments  from dual union all
      select 24 storeid , 6 week_nbr, 29347 net_sales, 598 buns, 238 condiments  from dual union all
      select 24 storeid , 7 week_nbr, 29347 net_sales, 598 buns, 238 condiments  from dual union all
      select 25 storeid , 1 week_nbr, 17637 net_sales, 360 buns, 165 condiments  from dual union all
      select 25 storeid , 6 week_nbr, 17637 net_sales, 360 buns, 165 condiments  from dual union all
      select 25 storeid , 7 week_nbr, 17637 net_sales, 360 buns, 165 condiments  from dual union all
      select 27 storeid , 1 week_nbr, 22010 net_sales, 405 buns, 172 condiments  from dual union all
      select 27 storeid , 6 week_nbr, 22010 net_sales, 405 buns, 172 condiments  from dual union all
      select 27 storeid , 7 week_nbr, 22010 net_sales, 405 buns, 172 condiments  from dual union all
      select 31 storeid , 1 week_nbr, 16836 net_sales, 345 buns, 168 condiments  from dual union all
      select 31 storeid , 6 week_nbr, 16836 net_sales, 345 buns, 168 condiments  from dual union all
      select 31 storeid , 7 week_nbr, 16836 net_sales, 345 buns, 168 condiments  from dual union all
      select 38 storeid , 1 week_nbr, 28244 net_sales, 524 buns, 247 condiments  from dual union all
      select 38 storeid , 6 week_nbr, 28244 net_sales, 524 buns, 247 condiments  from dual union all
      select 38 storeid , 7 week_nbr, 28244 net_sales, 524 buns, 247 condiments  from dual union all
      select 39 storeid , 1 week_nbr, 21011 net_sales, 407 buns, 238 condiments  from dual union all
      select 39 storeid , 6 week_nbr, 21011 net_sales, 407 buns, 238 condiments  from dual union all
      select 39 storeid , 7 week_nbr, 21011 net_sales, 407 buns, 238 condiments  from dual union all
      select 41 storeid , 1 week_nbr, 18026 net_sales, 430 buns, 179 condiments  from dual union all
      select 41 storeid , 6 week_nbr, 18026 net_sales, 430 buns, 179 condiments  from dual union all
      select 41 storeid , 7 week_nbr, 18026 net_sales, 430 buns, 179 condiments  from dual union all
      select 42 storeid , 1 week_nbr, 24821 net_sales, 466 buns, 212 condiments  from dual union all
      select 42 storeid , 6 week_nbr, 24821 net_sales, 466 buns, 212 condiments  from dual union all
      select 42 storeid , 7 week_nbr, 24821 net_sales, 466 buns, 212 condiments  from dual union all
      select 65 storeid , 1 week_nbr, 13356 net_sales, 281 buns, 136 condiments  from dual union all
      select 65 storeid , 6 week_nbr, 13356 net_sales, 281 buns, 136 condiments  from dual union all
      select 65 storeid , 7 week_nbr, 13356 net_sales, 281 buns, 136 condiments  from dual union all
      select 66 storeid , 1 week_nbr, 15421 net_sales, 337 buns, 155 condiments  from dual union all
      select 66 storeid , 6 week_nbr, 15421 net_sales, 337 buns, 155 condiments  from dual union all
      select 66 storeid , 7 week_nbr, 15421 net_sales, 337 buns, 155 condiments  from dual union all
      select 67 storeid , 1 week_nbr, 28064 net_sales, 625 buns, 283 condiments  from dual union all
      select 67 storeid , 6 week_nbr, 28064 net_sales, 625 buns, 283 condiments  from dual union all
      select 67 storeid , 7 week_nbr, 28064 net_sales, 625 buns, 283 condiments  from dual union all
      select 68 storeid , 1 week_nbr, 22875 net_sales, 493 buns, 238 condiments  from dual union all
      select 68 storeid , 6 week_nbr, 22875 net_sales, 493 buns, 238 condiments  from dual union all
      select 68 storeid , 7 week_nbr, 22875 net_sales, 493 buns, 238 condiments  from dual union all
      select 70 storeid , 1 week_nbr, 26434 net_sales, 562 buns, 248 condiments  from dual union all
      select 70 storeid , 6 week_nbr, 26434 net_sales, 562 buns, 248 condiments  from dual union all
      select 70 storeid , 7 week_nbr, 26434 net_sales, 562 buns, 248 condiments  from dual union all
      select 71 storeid , 1 week_nbr, 14259 net_sales, 297 buns, 133 condiments  from dual union all
      select 71 storeid , 6 week_nbr, 14259 net_sales, 297 buns, 133 condiments  from dual union all
      select 71 storeid , 7 week_nbr, 14259 net_sales, 297 buns, 133 condiments  from dual union all
      select 82 storeid , 1 week_nbr, 24446 net_sales, 469 buns, 210 condiments  from dual union all
      select 82 storeid , 6 week_nbr, 24446 net_sales, 469 buns, 210 condiments  from dual union all
      select 82 storeid , 7 week_nbr, 24446 net_sales, 469 buns, 210 condiments  from dual union all
      select 83 storeid , 1 week_nbr, 13959 net_sales, 280 buns, 104 condiments  from dual union all
      select 83 storeid , 6 week_nbr, 13959 net_sales, 280 buns, 104 condiments  from dual union all
      select 83 storeid , 7 week_nbr, 13959 net_sales, 280 buns, 104 condiments  from dual union all
      select 181 storeid , 1 week_nbr, 13140 net_sales, 273 buns, 136 condiments  from dual union all
      select 181 storeid , 6 week_nbr, 13140 net_sales, 273 buns, 136 condiments  from dual union all
      select 181 storeid , 7 week_nbr, 13140 net_sales, 273 buns, 136 condiments  from dual union all
      select 221 storeid , 1 week_nbr, 27347 net_sales, 546 buns, 289 condiments  from dual union all
      select 221 storeid , 6 week_nbr, 27347 net_sales, 546 buns, 289 condiments  from dual union all
      select 221 storeid , 7 week_nbr, 27347 net_sales, 546 buns, 289 condiments  from dual union all
      select 222 storeid , 1 week_nbr, 16456 net_sales, 379 buns, 148 condiments  from dual union all
      select 222 storeid , 6 week_nbr, 16456 net_sales, 379 buns, 148 condiments  from dual union all
      select 222 storeid , 7 week_nbr, 16456 net_sales, 379 buns, 148 condiments  from dual union all
      select 223 storeid , 1 week_nbr, 20611 net_sales, 439 buns, 165 condiments  from dual union all
      select 223 storeid , 6 week_nbr, 20611 net_sales, 439 buns, 165 condiments  from dual union all
      select 223 storeid , 7 week_nbr, 20611 net_sales, 439 buns, 165 condiments  from dual union all
      select 224 storeid , 1 week_nbr, 21537 net_sales, 420 buns, 173 condiments  from dual union all
      select 224 storeid , 6 week_nbr, 21537 net_sales, 420 buns, 173 condiments  from dual union all
      select 224 storeid , 7 week_nbr, 21537 net_sales, 420 buns, 173 condiments  from dual union all
      select 260 storeid , 1 week_nbr, 19329 net_sales, 380 buns, 196 condiments  from dual union all
      select 260 storeid , 6 week_nbr, 19329 net_sales, 380 buns, 196 condiments  from dual union all
      select 260 storeid , 7 week_nbr, 19329 net_sales, 380 buns, 196 condiments  from dual union all
      select 280 storeid , 1 week_nbr, 20692 net_sales, 512 buns, 202 condiments  from dual union all
      select 280 storeid , 6 week_nbr, 20692 net_sales, 512 buns, 202 condiments  from dual union all
      select 280 storeid , 7 week_nbr, 20692 net_sales, 512 buns, 202 condiments  from dual union all
      select 294 storeid , 1 week_nbr, 26522 net_sales, 481 buns, 252 condiments  from dual union all
      select 294 storeid , 6 week_nbr, 26522 net_sales, 481 buns, 252 condiments  from dual union all
      select 294 storeid , 7 week_nbr, 26522 net_sales, 481 buns, 252 condiments  from dual union all
      select 362 storeid , 1 week_nbr, 20611 net_sales, 317 buns, 221 condiments  from dual union all
      select 362 storeid , 6 week_nbr, 20611 net_sales, 317 buns, 221 condiments  from dual union all
      select 362 storeid , 7 week_nbr, 20611 net_sales, 317 buns, 221 condiments  from dual union all
      select 501 storeid , 1 week_nbr, 28337 net_sales, 518 buns, 273 condiments  from dual union all
      select 501 storeid , 6 week_nbr, 28337 net_sales, 518 buns, 273 condiments  from dual union all
      select 501 storeid , 7 week_nbr, 28337 net_sales, 518 buns, 273 condiments  from dual union all
      select 521 storeid , 1 week_nbr, 26118 net_sales, 438 buns, 257 condiments  from dual union all
      select 521 storeid , 6 week_nbr, 26118 net_sales, 438 buns, 257 condiments  from dual union all
      select 521 storeid , 7 week_nbr, 26118 net_sales, 438 buns, 257 condiments  from dual union all
      select 524 storeid , 1 week_nbr, 31929 net_sales, 582 buns, 247 condiments  from dual union all
      select 524 storeid , 6 week_nbr, 31929 net_sales, 582 buns, 247 condiments  from dual union all
      select 524 storeid , 7 week_nbr, 31929 net_sales, 582 buns, 247 condiments  from dual
, store_data as
      select 27   storeid,  'County Gate' storename ,    '5601' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                
      select 67   storeid,  'N. Jackson' storename ,    '0177' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                  
      select 68   storeid,  'Dyersburg' storename ,    '0277' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                  
      select 280   storeid,  'Poplar Ave.' storename ,    '3080' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                   
      select 294   storeid,  'Goodman Rd' storename ,    '5702' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                     
      select 25   storeid,  'Germantown' storename ,    '5094' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                              
      select 181   storeid,  'Mendehall' storename ,    '4090' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                    
      select 31   storeid,  'Winchester' storename ,    '2684' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                    
      select 41   storeid,  'Washington' storename ,    '4190' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                   
      select 42   storeid,  'Cordova' storename ,    '4393' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                       
      select 70   storeid,  'S. Jackson' storename ,    '0679' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                                                                                                                      
      select 221   storeid,  'Jackson' storename ,    '5500' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                      
      select 223   storeid,  'Highway 51' storename ,    '3485' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                        
      select 66   storeid,  'New Summer' storename ,    '2980' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                    
      select 82   storeid,  'Navy Road' storename ,    '1476' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                   
      select 224   storeid,  'New Covington' storename ,    '5397' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                              
      select 501   storeid,  'Kirby Quince' storename ,    '6504' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                               
      select 22   storeid,  'Wchstr/Good' storename ,    '2385' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                  
      select 23   storeid,  'Union Ave' storename ,    '1275' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                 
      select 24   storeid,  'West Poplar' storename ,    '4290' storenbr ,     'R1-Roosevelt' regionname ,   'D11-Wilcox' districtname , 'VMS' companyname  from dual union all                                                                   
      select 222   storeid,  'Thomas St.' storename ,    '1977' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                
      select 362   storeid,  'Wolfchase' storename ,    '5802' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                 
      select 524   storeid,  'Houston Levee' storename ,    '6705' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                             
      select 521   storeid,  'G-Town/I-40' storename ,    '6604' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                               
      select 38   storeid,  'Horn Lake' storename ,    '4994' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual union all                                                                    
      select 39   storeid,  'Macon/Syc' storename ,    '2885' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                    
      select 65   storeid,  'Poplar/Fenwick' storename ,    '2581' storenbr ,     'R1-Roosevelt' regionname ,   'D13-Bowser' districtname , 'VMS' companyname  from dual union all                                                                
      select 71   storeid,  'Humboldt' storename ,    '0785' storenbr ,     'R1-Roosevelt' regionname ,   'D14-Sandus' districtname , 'VMS' companyname  from dual union all                                                                      
      select 83   storeid,  'Mt. Moriah' storename ,    '1174' storenbr ,     'R1-Roosevelt' regionname ,   'D15-Rickard' districtname , 'VMS' companyname  from dual union all                                                                
      select 260   storeid,  'Getwell' storename ,    '1576' storenbr ,     'R1-Roosevelt' regionname ,   'D12-Smart' districtname , 'VMS' companyname  from dual
select decode(gc,0,companyname, 'VanderbiltFoods') as companyname
,       decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')) as regionname
,       decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods'))) as districtname
,       decode(gs,0,storenbr,decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')))) as storenbr
,       decode(gs,0,storename,decode(gd,0,districtname,decode(gr,0,regionname,decode(gc,0,companyname, 'VanderbiltFoods')))) as storename
,       net_sales
,       buns
,       condiments
from    (   select    companyname
            ,         grouping(companyname)     gc
            ,         regionname
            ,         grouping(regionname)      gr
            ,         districtname
            ,         grouping(districtname)    gd
            ,         storenbr
            ,         grouping(storenbr)        gs
            ,         max(storename) storename
            ,         sum(net_sales)            net_sales
            ,         sum(buns)                 buns
            ,         sum(condiments)           condiments
            from store_data  stdata
            inner join sample_data   sampdata on sampdata.storeid  = stdata.storeid
            group by   rollup(companyname, regionname, districtname, storenbr), week_nbr
            order by   companyname nulls first,gc desc, regionname nulls first, gr desc, districtname nulls first, gd desc,storenbr nulls first, gs desc
/*  --==  INCOMPLETE CODE --
    --== GET TABLE OF CONTENTS In same order as first cursor
    open pc_report_data for
    select   rownum as sortcol
    ,        storenbr
    ,        storename)
    BULK COLLECT INTO pc_TOC
END create_rpt_and_toc;I don't know sQL developer well enough to view cursor results from stored procedure
but here is test code from debugger window
DECLARE
  PC_REPORT_DATA sys_refcursor;
  PC_TOC sys_refcursor;
BEGIN
  CREATE_RPT_AND_TOC(
    PC_REPORT_DATA => PC_REPORT_DATA,
    PC_TOC => PC_TOC
  -- Modify the code to output the variable
  -- DBMS_OUTPUT.PUT_LINE('PC_REPORT_DATA = ' || PC_REPORT_DATA);
  -- Modify the code to output the variable
  -- DBMS_OUTPUT.PUT_LINE('PC_TOC = ' || PC_TOC);
END;

I am currently doing this in the presentation layer but is a lot cleaner and easier to maintain if handled in DB
I'd googled that suggested this was possible. I had decided on the FETCH. But I've been to avoid FETCH and LOOP
wherever possible.
One eample I found: I always try so much stuff, I forget where i got the idea) was:
-- pseudoscript
FETCH outer cursor.
    Select outer cursor
    open second cursor for select into and CLOSE Cursor. 
LOOPI also found this.
create or replace procedure testproc(c_test out sys_refcursor) is
    begin
      open c_test for select first_name, last_name, email from employees where rownum < 10;
   end;Here though, its a simple select from a table vs. a cursor.
I thouht it was woth asking the question.

Similar Messages

  • How to get the plsql table data into output cursor

    Hi,
    Could anybody please help me.
    Below is an example of the scenario..
    CREATE OR REPLACE PACKAGE chck IS
    PROCEDURE getdata(dept_no IN VARCHAR2,oc_result_cursor OUT sys_REFCURSOR);
    TYPE get_rec is record (ename varchar2(20),
    eno number(12));
    TYPE t_recs IS TABLE OF get_rec INDEX BY BINARY_INTEGER;
    emp_tab t_recs;
    END chck;
    CREATE OR REPLACE PACKAGE BODY chck AS
    PROCEDURE getdata(dept_no IN VARCHAR2,oc_result_cursor OUT sys_REFCURSOR)
    is
    BEGIN
    select ename, eno
    bulk collect into emp_tab
    from emp;
    open oc_result_cursor for select * from table(emp_tab); -- I believe something is wrong here ....
    END;
    END chck;
    the above package is giving me an error:
    LINE/COL ERROR
    10/29 PL/SQL: SQL Statement ignored
    10/43 PL/SQL: ORA-22905: cannot access rows from a non-nested table
    item
    let me know what needs to be changed
    Thanks
    Manju

    manjukn wrote:
    once i get the data into a plsql table, how to get this plsql table data into the cursor?There is no such thing as a PL/SQL table - it is an array.
    It is nothing at all like a table. It cannot be indexed, partitioned, cluster, etc. It does not exist in the SQL engine as an object that can be referenced. It resides in expensive PGA memory and needs to be copied (lock, stock and barrel) to the SQL engine as a bind variable.
    It is an extremely primitive structure - and should never be confused as being just like a table.
    Its use in SQL statements is also an exception to the rule. Sound and valid technical reasons need to justify why one want to push a PL/SQL array to the SQL engine to run SELECT 's against it.

  • Can not extract data into BW from SQL SERVER

    Dear All,
      I meet a problem to extract data from database(MS SQL Server 2000(sp3)) into BW now and can not extract data into BW ODS, even PSA, In the monitor, display yellow light(0 from 0 record), detail message just display message "data request arranged" "confirmed with: confirmation" in requests(message) step; "missing message: request received" in extract (message)  step; "no data" in processing(data packet) step and so on. but in fact, there are two records in my database test table and DB connection is OK. Even I can extract data from another test oracle database into BW ODS successfully.
       Our BW system has two BW applicaton server and use oracle database. the one application server locates on IBM AIX host. the another one locates on one NT server. the application server on NT server is used for data extration from MS SQL SERVER  database into BW oracle database. and MS SQL SERVER and NT platform application server locate on same one host. DBSL was installed on the NT application server already. and DB connector also was created successfully for MS SQL SERVER and datasource also was generated. DBSL type is Kernel640-WIN-IA32bit-unicode. my BW system is ECC5.0/UNICODE/ORACLE. all table/view/field name of MS SQL server is upcase and have not any specific character. for example: ZDEMO etc.
    wait your help.
    Thanks in advance.
    Billy

    Hi  Ravi,
    Could you help me to get knowledge about the followings:
    approximately how many records    extracting and transfering  from SAP R/3 to BIW  in an organisation. for that how much time  will take .
    How to extract data from  two are three source system  to BIW. Kindly help me with step by step explanation .If any screen shots with documents pls fwd to my ID. "[email protected]"
    Your help highly appreciated.
    Thanks.
    Hema

  • HOW TO CREATE STORED PROCEDURE IN DATA INTEGRATOR

    Hi to every one,
    Can any one help in giving me a solution for creating stored procedure in Data Integrator.
    I m new to this field

    Hi nath,
    Firstly are you using MYSQL or Oracle as the database,if its oracle database then follow this
    http://obiee101.blogspot.com/2008/01/obiee-using-oracle-stored-procedure-to.html
    http://oraclebizint.wordpress.com/2008/02/20/oracle-bi-ee-101332-executing-stored-proceduresfunctions-before-reports-before-report-triggers-and-global-temporary-tables/
    EXEC [DATABASE_NAME].[SCHEMA_NAME].[PROCEDURE_NAME][DATABASE_NAME] --> is the database name your creating your procedure
    [SCHEMA_NAME]-->is the user with which your creating
    [PROCEDURE_NAME] --> the name given to procedure
    You dont know how to get those run this SQL in TOAD and see select sys_context('userenv','db_name'), sys_context('userenv','session_user') from dual
    (OR) open you connection pool properties window in RPD,you will get the DB name and the user name as the schema name
    hope answered your question.
    CHeers,
    KK

  • Error while extracting data into 0GL_ACCOUNT

    Hi all,
            Initialize delta Process has been done successfully for extracting data into 0GL_ACCOUNT using DataSource 0GL_ACCOUNT_ATTR.
    However when using Delta Update for extracting data, the following error is displayed: 'ALE change pointers are not set up correctly' & is asking to activate the change pointer in BD61(Source System).
    I am not exactly sure of what i am supposed to do in BD61. Plz help.
    Regards,
    Srikar

    Hi Sushant,
                       Thanks for the reply.
                       I have checked in RSA2 for DataSource 0GL_ACCOUNT_ATTR.
                       All the Entries are present; However the status of SAKAN is not successful(Criss-Cross Shape is displayed). 
                       what am i supposed to do?
    Regards,
    Srikar

  • Extract data into the Oracle Database

    Hello,
    I have file in PDF format.
    I need to extract data into the Oracle Database.
    what should be my action ?
    And how could I accomplish?
    thanks
    DN

    You said:
    Do you know ahead of time how many columns are in the file?
    yes, It has 8 columns.
    But each PDF have different total of columns. Right now I am working on one PDF file only.
    e.g: page emp report has following values:
    Salray History Report in PDF format
    Page 1
    Date 10-21-2005
    LAST NAME SALARY COMMISSION
    Russell 14000 .4
    Partners 13500 .3
    Errazuriz 12000 .3
    Cambrault 11000 .3
    Zlotkey 10500 .2
    after converting it will be come as
    Salray History Report in PDF format
    Page 1
    Date 10-21-2005
    LAST NAME
    SALARY
    COMMISSION
    Russell
    Partners
    Errazuriz
    Cambrault
    Zlotkey
    14000
    13500
    12000
    11000
    .4
    .3
    .3
    .3
    End of Page 1
    Date 10-21-2005
    LAST NAME
    SALARY
    COMMISSION
    DN

  • How to run stored procedure IC Data / to define according script logic file

    We want to execute the stored procedure IC Data before the IC Booking. Could anybody tell me, how we have to define the script logic file in detail?
    We try it with this code (that runs without any error, but 0 rows are calculated, 0 rows are updated)
    *Run_stored_procedure=spicdata('%App%','%C_Category_Set%','%time_set%','','%entity_set%','','','Input','I','%logtable%','%scopetable%')
    *commit
    We also had tried with this code:
    *Run_stored_procedure=spicdata('%App%','%C_Category_Set%','%time_set%','','%entity_set%','','','','','%logtable%','%scopetable%')
    *commit

    step 1.
    Create a store procedure in back end.
    step2.
    Create a ssis package to execute the store procdure.
    step3.
    call this ssis pacakge in the data manager package and run the package.

  • Hi to all... What is a  XML data provider,stored Procedure, personal data

    Hi to all... What is a  XML data provider,stored Procedure, personal data providers in deski.  when we use these data provider in desk top intelligence.. and use of it.
    Please give detail description of the above...
    Thanks for reply..........

    Hi,
    We can create Desktop Intelligence reports using XML Data Provider, Personal Data Files and Stored Procedure.
    Following is some detailed information about these three.
    Xml data provider:
    Xml data provider is used for the integration of external data sources stored in XML format.
    This is similar to HTML.
    Stored Procedure:
    A stored procedure is a set of SQL commands that has been compiled and stored on the database server.
    Once the stored procedure has been "stored", client applications can execute the stored procedure over and over again without sending it to the database server again and without compiling it again.
    Stored procedures improve performance by reducing network traffic and CPU load.
    Personal data files:
    u2022     *.prn files
         A PRN file is a special type of file which contains instructions for a printer, it tells the printer what to print on the page and where as well as which paper tray to use, what the paper size is and a number of other controls.
    u2022     *.asc files
          Between the values of a row any number of carriage returns  or blanks are allowed. In any case it is strongly recommended that the data table be stored in such a way that it can be read and edited easily.
           The values may be stored in any format (integer, floating point, exponential notation) and they must be separated at least by one blank. The class information must be of integer type, the row identifiers are interpreted as strings. The lines can have any length and must not contain any comment.
    u2022     *.csv files
    A CSV file is a specially formatted plain text file which stores spreadsheet or basic database-style information in a very simple format, with one record on each line, and each field within that record separated by a comma.
    Regards,
    Pradnya Kokil

  • Oracle function to extract data into excel sheet

    I have extracted data from a couple of tables onto a view. Basically I have got about 15 coloums in that view but i need to extract the data in the view into an Excel sheet.
    I just want to know if their is a function in oracle whereby i can export the data in the view onto an excel sheet, because this statements is going to be scripted and run every morning for the data to be processed.
    Oracle version: oracle 9i
    OS : Windows 2003

    There are at least three options.
    One is to use UTL_FILE or spool to write the results out as a comma separated file. Excel can then read the .CSV without a hitch. Only use spool you want to overwrite the file (on create a new one) each day.
    The second approach would still use UTL_FILE but use Tom Kyte's OWA_SYLK utility to write an Excel-readable file.
    The third approach would be to reverse the direction. Define your database as a DNS datasource and embed your query in the Excel spreadsheet. This obviates the need for the user to pfaff around with CSV files but does require a bit more work on the OS side.
    Which approach you choose rather depends upon your precise needs.
    Cheers, APC

  • SQLException Calling Stored Procedure with Date OUT Parameters

    Hi,
    I'm trying to call a stored procedure in Oracle 10.1.0.4 using JDBC driver version 10.1.0.5. Here is the Stored procedure I'm trying to call:
    CREATE OR REPLACE PROCEDURE get_collector_segment_info (
    cid IN eb_collector_segment_iot.collector_id%TYPE,
    cnum IN eb_collector_segment_iot.collector_num%TYPE,
    sct OUT NOCOPY coll_seginfo_segment_codes,
    snt OUT NOCOPY coll_seginfo_segment_names,
    st OUT NOCOPY coll_seginfo_statuss,
    sdt OUT NOCOPY coll_seginfo_start_dates,
    edt OUT NOCOPY coll_seginfo_end_dates
    AS
    coll_id eb_collector_segment_iot.collector_id%TYPE;
    err_msg VARCHAR2 (1000);
    BEGIN
    -- Check if collector_id is present. If not, get the collector ID using collector Num
    IF cid IS NULL
    THEN
    coll_id := eb_collector_segment_get_cid (cnum, err_msg);
    IF err_msg IS NOT NULL
    THEN
    raise_application_error
    (-20001,
    'Error while getting Collector ID for Collector Num: '
    || cnum
    || ', Msg: '
    || err_msg
    END IF;
    ELSE
    coll_id := cid;
    END IF;
    -- Return the Segments
    SELECT ecs.segment_code, es.segment_name, es.status, ecs.start_date,
    ecs.end_date
    BULK COLLECT INTO sct, snt, st, sdt,
    edt
    FROM eb_collector_segment ecs, eb_segment es
    WHERE ecs.collector_id = coll_id
    AND ecs.segment_code = es.segment_code
    AND es.status = '1';
    IF SQL%ROWCOUNT = 0
    THEN
    raise_application_error
    (-20002,
    'No Segment records found for Collector ID: '
    || coll_id
    END IF;
    END get_collector_segment_info;
    ecs.segment_code, es.segment_name and es.status are of type VARCAHR2 and ecs.start_date and ecs.end_date are of type DATE. I wrote the following code to call the above store procedure:
    connection = this.datasource.getConnection();
    oracleCallableStatement = (OracleCallableStatement) connection.prepareCall("begin " + STORED_PROCEDURE_NAME
    + "(?, ?, ?, ?, ?, ?, ?); end;");
    oracleCallableStatement.setNull("cid", Types.VARCHAR);
    oracleCallableStatement.setLong("cnum", collectorNum);
    oracleCallableStatement.registerIndexTableOutParameter(3, 100, OracleTypes.VARCHAR, 100);
    oracleCallableStatement.registerIndexTableOutParameter(4, 100, OracleTypes.VARCHAR, 100);
    oracleCallableStatement.registerIndexTableOutParameter(5, 100, OracleTypes.VARCHAR, 100);
    oracleCallableStatement.registerIndexTableOutParameter(6, 100, OracleTypes.DATE, 0);
    oracleCallableStatement.registerIndexTableOutParameter(7, 100, OracleTypes.DATE, 0);
    resultSet = oracleCallableStatement.executeQuery();
    When I run the code, I get a "java.sql.SQLException: Invalid PL/SQL Index Table" exception on oracleCallableStatement.executeQuery(). I tried many other variations and searched on forums but nothing worked for me. Does anyone have any idea? I'm really desparate. i use JDK 1.4.2_12 and WebLogic 8.1 SP6.
    Thanks,
    Zhubin
    Message was edited by:
    zhoozhoo
    Message was edited by:
    zhoozhoo

    Hi Avi,
    I think you are right and I was using the wrong method. With some help from our DBA the problem was resolved Here is the correct code:
    connection = this.datasource.getConnection();
    oracleCallableStatement = (OracleCallableStatement) connection.prepareCall("begin " + STORED_PROCEDURE_NAME
    + "(?, ?, ?, ?, ?, ?, ?); end;");
    oracleCallableStatement.setNull(1, Types.VARCHAR);
    oracleCallableStatement.setLong(2, collectorNum);
    oracleCallableStatement.registerOutParameter(3, OracleTypes.ARRAY, "COLL_SEGINFO_SEGMENT_CODES");
    oracleCallableStatement.registerOutParameter(4, OracleTypes.ARRAY, "COLL_SEGINFO_SEGMENT_NAMES");
    oracleCallableStatement.registerOutParameter(5, OracleTypes.ARRAY, "COLL_SEGINFO_STATUSS");
    oracleCallableStatement.registerOutParameter(6, OracleTypes.ARRAY, "COLL_SEGINFO_START_DATES");
    oracleCallableStatement.registerOutParameter(7, OracleTypes.ARRAY, "COLL_SEGINFO_END_DATES");
    oracleCallableStatement.execute();
    String[] segmentCodes = (String[]) oracleCallableStatement.getARRAY(3).getArray();
    String[] segmentNumbers = (String[]) oracleCallableStatement.getARRAY(4).getArray();
    String[] segmentStatuses = (String[]) oracleCallableStatement.getARRAY(5).getArray();
    Timestamp[] startDates = (Timestamp[]) oracleCallableStatement.getARRAY(6).getArray();
    Timestamp[] endDates = (Timestamp[]) oracleCallableStatement.getARRAY(7).getArray();
    segments = new Segment[segmentCodes.length];
    for (int i = 0; i < segmentCodes.length; i++) {
    System.out.println(segmentCodes[i] + ' ' + segmentNumbers[i] + ' ' + segmentStatuses[i] + ' ' + startDates[i] + ' '
    + endDates);
    segments[i] = new Segment();
    segments[i].setSegmentCode(segmentCodes[i]);
    segments[i].setSegmentName(segmentNumbers[i]);
    segments[i].setStatus(segmentStatuses[i]);
    if (startDates[i] != null) {
    segments[i].setStartDate(new java.util.Date(startDates[i].getTime()));
    if (endDates[i] != null) {
    segments[i].setEndDate(new java.util.Date(endDates[i].getTime()));
    Thanks,
    Zhubin

  • Stored Procedures with Date data types and Oracle

    This should be easy.... But i keep getting the error:
    [Macromedia][Oracle JDBC Driver][Oracle]ORA-06550: line 1,
    column 7: PLS-00306: wrong number or types of arguments in call to
    'RETRIEVE_TS' ORA-06550: line 1, column 7: PL/SQL: Statement
    ignored
    And I got it worked out to where i know it is a problem with
    the way i am using the date data types in a stored procedure....
    In the past i usually avoided calling procedures in Oracle
    with date as the in type.... It is always easiest to let oracle
    convert the string to a date.... Unfortunately now i am stuck with
    having a date type in the procedure call.... So the question is:
    WHAT IS THE PROPER WAY TO SUBMIT DATE/TIME STAMP IN A STORED
    PROCEDURE?
    The Oracle Procedure looks like this:
    PROCEDURE retrieve_ts (
    p_at_tsv_rc IN OUT sys_refcursor,
    p_units IN OUT VARCHAR2,
    p_officeid IN VARCHAR2,
    p_timeseries_desc IN VARCHAR2,
    p_start_time IN DATE,
    p_end_time IN DATE,
    p_timezone IN VARCHAR2 DEFAULT 'GMT',
    p_trim IN NUMBER DEFAULT false_num,
    p_inclusive IN NUMBER DEFAULT NULL,
    p_versiondate IN DATE DEFAULT NULL,
    p_max_version IN NUMBER DEFAULT true_num
    AND the stored procedure call looks like this:
    <cfset ed = Now()>
    <cfset sd = #DateAdd("d",-lbt,Now())#>
    <cfstoredproc datasource="CWMS"
    procedure="cwms.cwms_ts.retrieve_ts"
    returncode="no">
    <cfprocparam type="inout" variable="unit" value="#unit#"
    dbvarname="@p_units"
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="in" value="MVS"
    dbvarname="@p_officeid"
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="in" value=#id.cwms_ts_id#
    dbvarname="@p_timeseries_desc"
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="in" value="#sd#"
    dbvarname="@p_start_time"
    cfsqltype="cf_sql_date">
    <cfprocparam type="in" value="#ed#"
    dbvarname="@p_end_time"
    cfsqltype="cf_sql_date">
    <cfprocparam type="in" value="#tz#"
    dbvarname="@p_time_zone"
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="in" value="0"
    dbvarname="@p_trim"
    cfsqltype="cf_sql_numeric">
    <cfprocparam type="in" value=""
    null = "yes"
    dbvarname="@p_inclusive"
    cfsqltype="cf_sql_numeric">
    <cfprocparam type="in" value=""
    null="yes"
    dbvarname="@p_versiondate"
    cfsqltype="cf_sql_date">
    <cfprocparam type="in" value="1"
    dbvarname="@p_max_version"
    cfsqltype="cf_sql_numeric">
    <cfprocresult name="ts_dat">
    </cfstoredproc>
    Text

    Yeah.... One is a type INOUT ref cursor.... which is denoted
    by the cfprocresult....
    By the way:
    Phil - the code example with a little tweaking worked fine on
    my machine....
    <<cfstoredproc procedure="test_pkg.test"
    datasource="myDSN" returncode="no">
    <cfprocparam type="IN" cfsqltype="cf_sql_timestamp"
    value="15-JUN-2005">
    <cfprocparam type="OUT" cfsqltype="cf_sql_varchar"
    variable="v_out">
    <cfprocresult name="rs1">
    </cfstoredproc>
    PROCEDURE test(
    v3_out OUT ref_cur_type,
    v1_in IN date default null,
    v2_out OUT varchar2
    IS
    BEGIN
    v2_out := TO_CHAR(v1_in, 'mm/dd/yyyy');
    OPEN v3_out
    FOR
    SELECT *
    FROM user
    WHERE activation_date >= v1_in;
    END test;
    Why do i still get this error......
    Here is what it looks like now:
    PROCEDURE retrieve_ts (
    p_at_tsv_rc IN OUT sys_refcursor,
    p_units IN OUT VARCHAR2,
    p_officeid IN VARCHAR2,
    p_timeseries_desc IN VARCHAR2,
    p_start_time IN DATE,
    p_end_time IN DATE,
    p_timezone IN VARCHAR2 DEFAULT 'GMT',
    p_trim IN NUMBER DEFAULT false_num,
    p_inclusive IN NUMBER DEFAULT NULL,
    p_versiondate IN DATE DEFAULT NULL,
    p_max_version IN NUMBER DEFAULT true_num
    <cfstoredproc datasource="CWMS"
    procedure="cwms.cwms_ts.retrieve_ts"
    returncode="no">
    <cfprocparam type="INOUT" variable="p_units"
    value="#unit#" <!---p_units--->
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="IN" value="MVS"
    <!---p_officeid--->
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="IN" value=#id.cwms_ts_id#
    <!---p_timeseries_desc--->
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="IN" value="#sd#"
    <!---p_start_time--->
    cfsqltype="cf_sql_timestamp">
    <cfprocparam type="IN" value="#ed#"
    <!---p_end_time--->
    cfsqltype="cf_sql_timestamp">
    <cfprocparam type="IN" value="#tz#"
    <!---p_timezone--->
    cfsqltype="cf_sql_varchar">
    <cfprocparam type="IN" value="0" <!---p_trim--->
    cfsqltype="cf_sql_integer">
    <cfprocparam type="IN" value=""
    <!---p_inclusive--->
    null = "yes"
    cfsqltype="cf_sql_numeric">
    <cfprocparam type="IN" value=""
    <!---p_versiondate--->
    null="yes"
    cfsqltype="cf_sql_timestamp">
    <cfprocparam type="IN" value="1"
    <!---p_max_version--->
    cfsqltype="cf_sql_integer">
    <cfprocresult name="ts_dat">
    <!---sys_refcursor--->
    </cfstoredproc>
    If I truly am short a parameter, How do you specify the INOUT
    sys_refcursor?

  • Question: Are there any advantages for stored procedure for data block?

    There are two ways to create data block:
    1. query table or view or
    2. stored procedure.
    After 9i, AS has a PL/SQL compiler. Do we still see the advantage of using stored procedure, as claimed that it is faster due to the stored procedure always compiled?
    Thank you in advance.
    Jimmy

    Jimmy,
    The "fast" side is not the only one benefit of stored procedures.
    Of course, you can use the BULK COLLECT functionality which is not available into Forms.
    But stored procedure is a good way to perform the following actions:
    complex handeling of datas (insert, update or delete that generate severals actions on other tables).
    externalization/centralisation of business rules.(separate the design and functionnal work).
    more secutity, because you can prohibit manipulation of datas outside of the procedures.
    You can change the rules without modify the forms.
    etc.
    Francois

  • HELP: Can't Pass Parameters w/Stored Procedure as Data Connection

    I'm working on using an existing employment application in PDF format, and I want the form fields to be prepopulated with the user's specific data.
    I'd like is so that when a user clicks a link (like www.mysite.com/empapp/empapp.pdf?UserID=5), a dynamic PDF document will open up and that user's data will be populated inside of the form fields by using that user's "UserID" variable/parameter that was passed in the querystring.
    I've tried a stored procedure that contains the following select statement:
    SELECT * FROM tblEmpApp WHERE UserID = @UserID
    I've also tried entering this select statement manually into the box instead of using a stored procedure without success. When I try to use the stored procedure, I receive this error:
    Stored procedure "spEmpApp" has non-optional parameters.
    How can I set the PDF doc up to populate the form fields based on that passed parameter in the querystring???
    ******************PLEASE HELP!!!******************

    had this same issue.  following works for me.
    -create a dataconnection to the db with a random query to the table.
    -just clone the dataconnection
         oDConn = xfa.sourceSet.DataConnection.clone(1);
    -change the query attribute to the stored procedure
         oDConn.resolveNode("#command").query.select.value = "exec spEmpApp 'parameter'"
    -open the cloned data connection
         oDconn.open();

  • Toplink support for stored procedure with 2 OUT  REF CURSOR ?

    Can Toplink StoredProcedureCall be used with Oracle PLSql procedure with 2 OUT parameters. Parameter type is Ref Cursor (Oracle PLSQL resulset)
    Regards

    In a TopLink StoredProcedureCall using an OUT CURSOR the cursor is assumed to map to the result set for the TopLink query.
    For example if you had a stored procedure READ_ALL_EMP that returned a out cursor of EMP rows, you could use that procedure in a TopLink mapped Employee class mapped to the EMP table and use the stored procedure in a ReadAllQuery for the Employee class.
    If the procedure does not return data that maps to objects, you can use a DataReadQuery to access the data. The out cursor would be returned as a Vector of DatabaseRows that contain the data from the cursor rows.
    If the procedures data is complex and does not map to objects, it may be better to access the procedure directly through JDBC.

  • Pl/sql stored procedure as data source

    Hi I am a newbie
    I have a pl/sql stored procedure inside a package which uses a SYS_REFCURSOR as it returns a result set.
    Can I use this procedure as a Data Source using the wizard?
    When I use the Data source configuration wizard I get a list with only the tables and views.I don't see any stored procedures
    Thanks

    Here is a sample procedure..
    CREATE OR REPLACE PROCEDURE TEST_USER.TEST_PROCEDURE1 ( p_cursor OUT SYS_REFCURSOR)
    AS
    BEGIN
    OPEN p_cursor FOR
    SELECT C1,C2
    FROM TEST_USER.test_table4procedure;
    END;
    When I execute the procedure, I see the results. The goal is to put the results of the procedure into a different table.
    Unfortunately I have close to 0 zero knowledge in both java and jython.
    Please help.
    NOTE: For the life of me, I have no clue why the "other" system wants it to be a stored procedure, when we can use a view/table and make everybody's life easier (aka K.I.S.S.)
    Regards,
    Dave Null

Maybe you are looking for