Join of cursor with table

Hi experts,
Oracle Version: 11GR2
I get dataset in the ref cursor as an out parameter from a procedure. Now, I have to derive column "NAME" from table "TEST" using ID as a join key between cursor and a table.
How can we do this in oracle?
Thanks

You cant join a cursor to a table. cursor is a SQL work area where instruction to execute a SQL is processed.
I could think of three approaches
1. The best way is to include the table "TEST" in the original SQL that builds the cursor.
2. If that is not possible then you need to fetch them (may be) into a SQL collection type and then join the table "TEST" with the collection type.
3. Or you may have to loop thorough the cursor and then for each row fetched you would have to join with the table "TEST"
Lets say this is your procedure
create or replace procedure getdept
  p_out_rc out sys_refcursor
as
begin
  open p_out_rc for
  select deptno
    from dept;
end;
Example for 2nd approach
Create a SQL Nested Table.
create or replace type deptno_tbl as table of number(10)
And you write a PL/SQL code like this. Code in red is the one to consider.
SQL> declare
  2    l_deptno deptno_tbl;
  3    l_rc     sys_refcursor;
  4  begin
  5    getdept(l_rc);
  6    fetch l_rc bulk collect into l_deptno;
  7
  8    for i in (
  9               select ename
10                 from emp e
11                 join table(l_deptno) t
12                   on e.deptno = t.column_value
13             )
14    loop
15      dbms_output.put_line(i.ename);
16    end loop;
17  end;
18  /
KING
CLARK
ADAMS
SCOTT
JONES
SMITH
TURNER
BLAKE
MARTIN
WARD
ALLEN
Example for 3rd approach.
SQL> declare
  2    l_rc     sys_refcursor;
  3    l_deptno number(10);
  4  begin
  5    getdept(l_rc);
  6    loop
  7      fetch l_rc into l_deptno;
  8      exit when l_rc%notfound;
  9      for i in (
10                 select ename
11                   from emp e
12                  where e.deptno = l_deptno
13               )
14      loop
15        dbms_output.put_line(i.ename);
16      end loop;
17    end loop;
18  end;
19  /
CLARK
KING
SMITH
JONES
SCOTT
ADAMS
ALLEN
WARD
MARTIN
BLAKE
TURNER
Finally I would again like to highlight that first approach is by far the best approach. The second and third approach has there own performance downside.

Similar Messages

  • OPENING CURSOR WITH TABLE NAME AS PERAMETER

    hi all,
    here i have a problem. please help me.
    create or replace procedure MAX_ID
    (COLUMN_NAME IN VARCHAR2,
    TABLE_NAME IN VARCHAR2) IS
    CURSOR MAX_CURSOR IS SELECT COLUMN_NAME FROM TABLE_NAME;
    begin
    END;
    in the above procedure table name and column name are in parameters. I have to declare cursor with the in parameter values. How to solve this problem. Give me solution as soon as possible. Waiting for your valuable suggestions.
    with regards,
    vali

    Hi,
    You will need to use dynamic SQL to be able to do that. This one returns a single row but you may need to work more on this to achieve the results which you are looking for based on your requirement.
    PROCEDURE get_data_dynamically_pr(pv_sqlstr VARCHAR2,pn_count IN OUT NUMBER) IS
    ln_cursor NUMBER;
    ln_rows NUMBER(5);
    BEGIN
    /* Retrieve the count from a table we passed */
    ln_cursor := DBMS_SQL.OPEN_CURSOR;
    DBMS_SQL.PARSE(ln_cursor, pv_sqlstr,DBMS_SQL.NATIVE);
    DBMS_SQL.DEFINE_COLUMN(ln_cursor, 1, pn_count);
    ln_rows := DBMS_SQL.EXECUTE(ln_cursor);
    IF DBMS_SQL.FETCH_ROWS(ln_cursor) = 0 then
    RETURN;
    END IF;
    DBMS_SQL.COLUMN_VALUE(ln_cursor, 1, pn_count);
    DBMS_SQL.CLOSE_CURSOR(ln_cursor);
    EXCEPTION
    WHEN OTHERS THEN
    RAISE_APPLICATION_ERROR (-20400,SQLERRM||'Exception raised in dynamic sql proc..');
    END;
    I hope this might be useful to you.

  • Need to increase performance-bulk collect in cursor with limit and in the for loop inserting into the trigger table

    Hi all,
    I have a performance issue in the below code,where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
    can someone please guide me here.Its bit urgent .Awaiting for your response.
    declare
    vmax_Value NUMBER(5);
      vcnt number(10);
      id_val number(20);
      pc_id number(15);
      vtable_nm VARCHAR2(100);
      vstep_no  VARCHAR2(10);
      vsql_code VARCHAR2(10);
      vsql_errm varchar2(200);
      vtarget_starttime timestamp;
      limit_in number :=10000;
      idx           number(10);
              cursor stg_cursor is
             select
                   DESCRIPTION,
                   SORT_CODE,
                   ACCOUNT_NUMBER,
                     to_number(to_char(CORRESPONDENCE_DATE,'DD')) crr_day,
                     to_char(CORRESPONDENCE_DATE,'MONTH') crr_month,
                     to_number(substr(to_char(CORRESPONDENCE_DATE,'DD-MON-YYYY'),8,4)) crr_year,
                   PARTY_ID,
                   GUID,
                   PAPERLESS_REF_IND,
                   PRODUCT_TYPE,
                   PRODUCT_BRAND,
                   PRODUCT_HELD_ID,
                   NOTIFICATION_PREF,
                   UNREAD_CORRES_PERIOD,
                   EMAIL_ID,
                   MOBILE_NUMBER,
                   TITLE,
                   SURNAME,
                   POSTCODE,
                   EVENT_TYPE,
                   PRIORITY_IND,
                   SUBJECT,
                   EXT_PRD_ID_TX,
                   EXT_PRD_HLD_ID_TX,
                   EXT_SYS_ID,
                   EXT_PTY_ID_TX,
                   ACCOUNT_TYPE_CD,
                   COM_PFR_TYP_TX,
                   COM_PFR_OPT_TX,
                   COM_PFR_RSN_CD
             from  table_stg;
    type rec_type is table of stg_rec_type index by pls_integer;
    v_rt_all_cols rec_type;
    BEGIN
      vstep_no   := '0';
      vmax_value := 0;
      vtarget_starttime := systimestamp;
      id_val    := 0;
      pc_id     := 0;
      success_flag := 0;
              vstep_no  := '1';
              vtable_nm := 'before cursor';
        OPEN stg_cursor;
              vstep_no  := '2';
              vtable_nm := 'After cursor';
       LOOP
              vstep_no  := '3';
              vtable_nm := 'before fetch';
    --loop
        FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
                  vstep_no  := '4';
                  vtable_nm := 'after fetch';
    --EXIT WHEN v_rt_all_cols.COUNT = 0;
        EXIT WHEN stg_cursor%NOTFOUND;
    FOR i IN 1 .. v_rt_all_cols.COUNT
      LOOP
       dbms_output.put_line(upper(v_rt_all_cols(i).event_type));
        if (upper(v_rt_all_cols(i).event_type) = upper('System_enforced')) then
                  vstep_no  := '4.1';
                  vtable_nm := 'before seq sel';
              select PC_SEQ.nextval into pc_id from dual;
                  vstep_no  := '4.2';
                  vtable_nm := 'before insert corres';
              INSERT INTO target1_tab
                           (ID,
                            PARTY_ID,
                            PRODUCT_BRAND,
                            SORT_CODE,
                            ACCOUNT_NUMBER,
                            EXT_PRD_ID_TX,         
                            EXT_PRD_HLD_ID_TX,
                            EXT_SYS_ID,
                            EXT_PTY_ID_TX,
                            ACCOUNT_TYPE_CD,
                            COM_PFR_TYP_TX,
                            COM_PFR_OPT_TX,
                            COM_PFR_RSN_CD,
                            status)
             VALUES
                            (pc_id,
                             v_rt_all_cols(i).party_id,
                             decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                             v_rt_all_cols(i).sort_code,
                             'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4),
                             v_rt_all_cols(i).EXT_PRD_ID_TX,
                             v_rt_all_cols(i).EXT_PRD_HLD_ID_TX,
                             v_rt_all_cols(i).EXT_SYS_ID,
                             v_rt_all_cols(i).EXT_PTY_ID_TX,
                             v_rt_all_cols(i).ACCOUNT_TYPE_CD,
                             v_rt_all_cols(i).COM_PFR_TYP_TX,
                             v_rt_all_cols(i).COM_PFR_OPT_TX,
                             v_rt_all_cols(i).COM_PFR_RSN_CD,
                             NULL);
                  vstep_no  := '4.3';
                  vtable_nm := 'after insert corres';
        else
              select COM_SEQ.nextval into id_val from dual;
                  vstep_no  := '6';
                  vtable_nm := 'before insertcomm';
          if (upper(v_rt_all_cols(i).event_type) = upper('REMINDER')) then
                vstep_no  := '6.01';
                  vtable_nm := 'after if insertcomm';
              insert into parent_tab
                 (ID ,
                 CTEM_CODE,
                 CHA_CODE,            
                 CT_CODE,                           
                 CONTACT_POINT_ID,             
                 SOURCE,
                 RECEIVED_DATE,                             
                 SEND_DATE,
                 RETRY_COUNT)
              values
                 (id_val,
                  lower(v_rt_all_cols(i).event_type), 
                  decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                  'Email',
                  v_rt_all_cols(i).email_id,
                  'IADAREMINDER',
                  systimestamp,
                  systimestamp,
                  0);  
         else
                vstep_no  := '6.02';
                  vtable_nm := 'after else insertcomm';
              insert into parent_tab
                 (ID ,
                 CTEM_CODE,
                 CHA_CODE,            
                 CT_CODE,                           
                 CONTACT_POINT_ID,             
                 SOURCE,
                 RECEIVED_DATE,                             
                 SEND_DATE,
                 RETRY_COUNT)
              values
                 (id_val,
                  lower(v_rt_all_cols(i).event_type), 
                  decode(v_rt_all_cols(i).product_brand,'LTB',2,'HLX',1,'HAL',1,'BOS',3,'VER',4,0),
                  'Email',
                  v_rt_all_cols(i).email_id,
                  'CORRESPONDENCE',
                  systimestamp,
                  systimestamp,
                  0); 
            END if; 
                  vstep_no  := '6.11';
                  vtable_nm := 'before chop';
             if (v_rt_all_cols(i).ACCOUNT_NUMBER is not null) then 
                      v_rt_all_cols(i).ACCOUNT_NUMBER := 'XXXX'||substr(trim(v_rt_all_cols(i).ACCOUNT_NUMBER),length(trim(v_rt_all_cols(i).ACCOUNT_NUMBER))-3,4);
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 'IB.Correspondence.AccountNumberMasked',
                 v_rt_all_cols(i).ACCOUNT_NUMBER);
             end if;
                  vstep_no  := '6.1';
                  vtable_nm := 'before stateday';
             if (v_rt_all_cols(i).crr_day is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Day',
                 'IB.Crsp.Date.Day',
                 v_rt_all_cols(i).crr_day);
             end if;
                  vstep_no  := '6.2';
                  vtable_nm := 'before statemth';
             if (v_rt_all_cols(i).crr_month is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Month',
                 'IB.Crsp.Date.Month',
                 v_rt_all_cols(i).crr_month);
             end if;
                  vstep_no  := '6.3';
                  vtable_nm := 'before stateyear';
             if (v_rt_all_cols(i).crr_year is not null) then 
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)
              values
                (id_val,
                 --'IB.Correspondence.Date.Year',
                 'IB.Crsp.Date.Year',
                 v_rt_all_cols(i).crr_year);
             end if;
                  vstep_no  := '7';
                  vtable_nm := 'before type';
               if (v_rt_all_cols(i).product_type is not null) then
                  insert into child_tab
                     (COM_ID,                                            
                     KEY,                                                                                                                                        
                     VALUE)
                  values
                    (id_val,
                     'IB.Product.ProductName',
                   v_rt_all_cols(i).product_type);
                end if;
                  vstep_no  := '9';
                  vtable_nm := 'before title';         
              if (trim(v_rt_all_cols(i).title) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE )
              values
                (id_val,
                 'IB.Customer.Title',
                 trim(v_rt_all_cols(i).title));
              end if;
                  vstep_no  := '10';
                  vtable_nm := 'before surname';
              if (v_rt_all_cols(i).surname is not null) then
                insert into child_tab
                   (COM_ID,                                            
                   KEY,                                                                                                                                          
                   VALUE)
                values
                  (id_val,
                  'IB.Customer.LastName',
                  v_rt_all_cols(i).surname);
              end if;
                            vstep_no  := '12';
                            vtable_nm := 'before postcd';
              if (trim(v_rt_all_cols(i).POSTCODE) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Customer.Addr.PostCodeMasked',
                  substr(replace(v_rt_all_cols(i).POSTCODE,' ',''),length(replace(v_rt_all_cols(i).POSTCODE,' ',''))-2,3));
              end if;
                            vstep_no  := '13';
                            vtable_nm := 'before subject';
              if (trim(v_rt_all_cols(i).SUBJECT) is not null) then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Correspondence.Subject',
                  v_rt_all_cols(i).subject);
              end if;
                            vstep_no  := '14';
                            vtable_nm := 'before inactivity';
              if (trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) is null or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '3' or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '6' or
                  trim(v_rt_all_cols(i).UNREAD_CORRES_PERIOD) = '9') then
              insert into child_tab
                 (COM_ID,                                            
                 KEY,                                                                                                                                            
                 VALUE)                              
               values
                (id_val,
                 'IB.Correspondence.Inactivity',
                  v_rt_all_cols(i).UNREAD_CORRES_PERIOD);
              end if;
                          vstep_no  := '14.1';
                          vtable_nm := 'after notfound';
        end if;
                          vstep_no  := '15';
                          vtable_nm := 'after notfound';
        END LOOP;
        end loop;
                          vstep_no  := '16';
                          vtable_nm := 'before closecur';
        CLOSE stg_cursor;
                          vstep_no  := '17';
                          vtable_nm := 'before commit';
        DELETE FROM table_stg;
      COMMIT;
                          vstep_no  := '18';
                          vtable_nm := 'after commit';
    EXCEPTION
    WHEN OTHERS THEN
      ROLLBACK;
      success_flag := 1;
      vsql_code := SQLCODE;
      vsql_errm := SUBSTR(sqlerrm,1,200);
      error_logging_pkg.inserterrorlog('samp',vsql_code,vsql_errm, vtable_nm,vstep_no);
      RAISE_APPLICATION_ERROR (-20011, 'samp '||vstep_no||' SQLERRM:'||SQLERRM);
    end;
    Thanks

    Its bit urgent
    NO - it is NOT urgent. Not to us.
    If you have an urgent problem you need to hire a consultant.
    I have a performance issue in the below code,
    Maybe you do and maybe you don't. How are we to really know? You haven't posted ANYTHING indicating that a performance issue exists. Please read the FAQ for how to post a tuning request and the info you need to provide. First and foremost you have to post SOMETHING that actually shows that a performance issue exists. Troubleshooting requires FACTS not just a subjective opinion.
    where i am trying to insert the data from table_stg into target_tab and in parent_tab tables and then to child tables via cursor with bulk collect .the target_tab and parent_tab are huge tables and have a row wise trigger enabled on it .the trigger is mandatory . This timetaken for this block to execute is 5000 seconds.Now my requirement is to reduce it to 5 to 10 mins.
    Personally I think 5000 seconds (about 1 hr 20 minutes) is very fast for processing 800 trillion rows of data into parent and child tables. Why do you think that is slow?
    Your code has several major flaws that need to be corrected before you can even determine what, if anything, needs to be tuned.
    This code has the EXIT statement at the beginning of the loop instead of at the end
        FETCH stg_cursor BULK COLLECT INTO v_rt_all_cols LIMIT limit_in;
                  vstep_no  := '4';
                  vtable_nm := 'after fetch';
    --EXIT WHEN v_rt_all_cols.COUNT = 0;
        EXIT WHEN stg_cursor%NOTFOUND;
    The correct place for the %NOTFOUND test when using BULK COLLECT is at the END of the loop; that is, the last statement in the loop.
    You can use a COUNT test at the start of the loop but ironically you have commented it out and have now done it wrong. Either move the NOTFOUND test to the end of the loop or remove it and uncomment the COUNT test.
    WHEN OTHERS THEN
      ROLLBACK;
    That basically says you don't even care what problem occurs or whether the problem is for a single record of your 10,000 in the collection. You pretty much just throw away any stack trace and substitute your own message.
    Your code also has NO exception handling for any of the individual steps or blocks of code.
    The code you posted also begs the question of why you are using NAME=VALUE pairs for child data rows? Why aren't you using a standard relational table for this data?
    As others have noted you are using slow-by-slow (row by row processing). Let's assume that PL/SQL, the bulk collect and row-by-row is actually necessary.
    Then you should be constructing the parent and child records into collections and then inserting them in BULK using FORALL.
    1. Create a collection for the new parent rows
    2. Create a collection for the new child rows
    3. For each set of LIMIT source row data
      a. empty the parent and child collections
      b. populate those collections with new parent/child data
      c. bulk insert the parent collection into the parent table
      d. bulk insert the child collection into the child table
    And unless you really want to either load EVERYTHING or abandon everything you should use bulk exception handling so that the clean data gets processed and only the dirty data gets rejected.

  • How can I fill a table of objects from cursor with select * bulk collect???

    Hi All, I have a TYPE as OBJECT
    create or replace type dept2_o as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    I can fill a table of objects from cursor with out select * bulk collect...., row by row
    declare
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    i integer;
    begin
    i:=0;
    dept_o_tab.extend(20);
    for rec in (select * from dept) loop
    i:=i+1;
    dept_o_tab(i):=dept2_o(
    deptno => rec.deptno,
    dname => rec.dname,
    loc =>rec.loc
    end loop;
    for k IN 1..i loop
    dbms_output.put_line(dept_o_tab(k).deptno||' '||dept_o_tab(k).dname||' '||dept_o_tab(k).loc);
    end loop;
    end;
    RESULT
    10 ACCOUNTING NEW YORK
    20 RESEARCH DALLAS
    30 SALES CHICAGO
    40 OPERATIONS BOSTON
    But I can't fill a table of objects from cursor with select * bulk collect construction ...
    declare
    TYPE dept2_t IS TABLE of dept2_o;
    dept_o_tab dept2_t:=dept2_t();
    begin
    dept_o_tab.extend(20);
    select * bulk collect into dept_o_tab from dept;
    end;
    RESULT
    ORA-06550: line 6, column 39;
    PL/SQL: ORA-00947: not enough values ....
    How can I fill a table of objects from cursor with select * bulk collect???

    create or replace type dept_ot as object (
    deptno NUMBER(2),
    dname VARCHAR2(14),
    loc VARCHAR2(13));
    create table dept
    (deptno number
    ,dname varchar2(14)
    ,loc varchar2(13)
    insert into dept values (10, 'x', 'xx');
    insert into dept values (20, 'y', 'yy');
    insert into dept values (30, 'z', 'zz');
    select dept_ot (deptno, dname, loc)
      from dept
    create type dept_nt is table of dept_ot
    declare
       l_depts dept_nt;
    begin
       select dept_ot (deptno, dname, loc)
         bulk collect
         into l_depts
         from dept
       for i in l_depts.first .. l_depts.last
       loop
          dbms_output.put_line (l_depts(i).deptno);
          dbms_output.put_line (l_depts(i).dname);
          dbms_output.put_line (l_depts(i).loc);    
       end loop;
    end;
    /

  • How to check with table for cursor..?

    How to check with table for cursor..?
    Here I have Table temp_final_plan
    Here i want to update if already exit...below is the procedure....
    CREATE OR REPLACE PROCEDURE spu_final_profit_plan
    AS
    -- Constant declarations
      ln_errnum number := 0;
    -- Variable declarations
       ls_errmsg app_errors.err_msg%TYPE;
       ls_appmsg app_errors.app_msg%TYPE;
       ls_appid  app_errors.app_id%TYPE;
    -- Cursor declaration for final_update_el
    CURSOR cur_final_update_el IS
        select '910' ent,
               '9127316' center,
               post_acct,
               sum(avg_mtd_01) sum_avg_mtd_01,
               sum(avg_mtd_02) sum_avg_mtd_02,
               sum(avg_ytd_01) sum_avg_ytd_01,
               sum(avg_ytd_02) sum_avg_ytd_02
          from mon_act_cypy
         where rec_type = 'A'
           and sum_flag = 'D'
           and yr = '2008'
           and substr(ctr_or_hier, 1, 2) = 'el'
           and ent || sub_ent in
               (select ent || sub_ent
                  from ent_ref
                 where roll_ent || roll_sub_ent = '999100')
         group by post_acct
        having sum(avg_mtd_01) <> 0
            or sum(avg_mtd_02) <> 0
            or sum(avg_ytd_01) <> 0
            or sum(avg_ytd_02) <> 0;
    -- Cursor declaration for final_update
    CURSOR cur_final_update IS
        select b.plan_ent b_plan_ent,
               b.plan_ctr b_plan_ctr,
               a.post_acct a_post_acct,
               sum(a.avg_mtd_01) sum_avg_mtd_01,
               sum(a.avg_mtd_02) sum_avg_mtd_02,
               sum(a.avg_ytd_01) sum_ytd_mtd_01,
               sum(a.avg_ytd_02) sum_ytd_mtd_02
          from mon_act_cypy a,
               plan_unit_tbl b
         where a.ent || a.ctr_or_hier = b.ent || b.ctr_or_hier
           and a.rec_type = 'A'
           and a.sum_flag = 'D'
           and a.yr = '2008'
           and b.hier_tbl_num = '001'
           and a.ent || a.sub_ent in
               (select ent || sub_ent
                  from ent_ref
                 where roll_ent || roll_sub_ent = '999100')
         group by b.plan_ent, b.plan_ctr, a.post_acct
        having sum(a.avg_mtd_01) <> 0
            or sum(a.avg_mtd_02) <> 0
            or sum(a.avg_ytd_01) <> 0
            or sum(a.avg_ytd_02) <> 0;
    -- Begin the procedure body
       BEGIN
    -- Insert / Update final profit plan for final_update query using cursor
       FOR rec_final_update_el IN cur_final_update_el
       LOOP
       EXIT WHEN rec_final_update_el%NOTFOUND;
       IF rec_final_update_el. THEN
          UPDATE temp_final_plan
             SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
                 sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,       
                 sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,       
                 sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,       
           WHERE ent = rec_final_update_el.ent
             AND center = rec_final_update_el.center
             AND post_acct = rec_final_update_el.post_acct;
       ELSE
          INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
                                             rec_final_update_el.center,
                                             rec_final_update_el.post_acct,
                                             rec_final_update_el.sum_avg_mtd_01,
                                             rec_final_update_el.sum_avg_mtd_02,
                                             rec_final_update_el.sum_avg_ytd_01,
                                             rec_final_update_el.sum_avg_ytd_02);
       END IF;
       END LOOP;
    -- Insert / Update final profit plan for final_update query using cursor
       FOR rec_final_update IN cur_final_update
       LOOP
       EXIT WHEN rec_final_update%NOTFOUND;
       IF rec_final_update. THEN
          UPDATE temp_final_plan
             SET sum_avg_mtd_01 = rec_final_update.sum_avg_mtd_01,
                 sum_avg_mtd_02 = rec_final_update.sum_avg_mtd_02,       
                 sum_avg_ytd_01 = rec_final_update.sum_avg_ytd_01,       
                 sum_avg_ytd_02 = rec_final_update.sum_avg_ytd_02,       
           WHERE ent = rec_final_update.b_plan_ent
             AND center = rec_final_update.b_plan_ctr
             AND post_acct = rec_final_update.a_post_acct;
       ELSE
          INSERT INTO temp_final_plan VALUES(rec_final_update.b_plan_ent,
                                             rec_final_update.b_plan_ctr,
                                             rec_final_update.a_post_acct,
                                             rec_final_update.sum_avg_mtd_01,
                                             rec_final_update.sum_avg_mtd_02,
                                             rec_final_update.sum_avg_ytd_01,
                                             rec_final_update.sum_avg_ytd_02);
       END IF;
       END LOOP;
    -- EXCEPTION handling section
       EXCEPTION
    -- Fire OTHERS Exception case by default
       WHEN OTHERS THEN
    -- ROLL BACK Transaction, if any failure
       ROLLBACK;
       ln_errnum := SQLCODE;
       ls_errmsg := SUBSTR(SQLERRM, 1, 100);
    -- Log the ERRORS into APP_ERRORS table using SPU_LOG_ERRORS procedure
       spu_log_errors(ln_errnum, ls_errmsg, ls_appid, ls_appmsg);
    -- End of the stored procedure
    END spu_final_profit_plan;
    [\pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I'm not sure what you mean by, 'How to check with table for cursor..?' but I'll offer a comment on your Code Snippet. I think you want to know how to check if a record exists so you know if you need to perform an INSERT or an UPDATE.
    Here is a snippet of your code. I'll put my comments in "Comment" style in your code.
    -- Insert / Update final profit plan for final_update query using cursor
       FOR rec_final_update_el IN cur_final_update_el
       LOOP
    /* There is no need to test for %NOTFOUND since you are using Cursor FOR Loop! 
    ** This construct automatically exits when the last record is processed. */
       EXIT WHEN rec_final_update_el%NOTFOUND;
    /* Is this where you would like to know how to Check if the record already exist??
    ** I asked this because, 'rec_final_update_el.' is not valid syntax.  Are you looking for
    ** an Cursor Attribute or Method you can check here? 
    ** I would suggest a Primary Key or Unique Index on ENT, CENTER, and POST_ACCT
    ** on the TEMP_FINAL_PLAN table. Then simply perform an INSERT and code an
    ** Exception to UPDATE when you get a DUP_VAL_ON_INDEX exception.  Otherwise,
    ** you will need to simply run an Implicit or Explicit Cursor to test if the row exists and
    ** use this return value to determine if you should INSERT or UPDATE.  */
       IF rec_final_update_el. THEN
          UPDATE temp_final_plan
             SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
                 sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,       
                 sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,       
                 sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,       
           WHERE ent = rec_final_update_el.ent
             AND center = rec_final_update_el.center
             AND post_acct = rec_final_update_el.post_acct;
       ELSE
          INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
                                             rec_final_update_el.center,
                                             rec_final_update_el.post_acct,
                                             rec_final_update_el.sum_avg_mtd_01,
                                             rec_final_update_el.sum_avg_mtd_02,
                                             rec_final_update_el.sum_avg_ytd_01,
                                             rec_final_update_el.sum_avg_ytd_02);
       END IF;
       END LOOP;I hope I've answered your question, but if I haven't please provide more details so we can better understand your request.
    Craig...

  • Cartesian join on 2 dimension tables, with count aggregation?

    Hi, I have 2 dimension tables, Students, and Subjects, and a fact table, Marks. (simplified)
    the Students and Subjects dimension tables both have a 1-N relationship with Marks, so reporting works fine.
    However, there are some students who does not have a score in a certain Subject, so when I generate the report of each Subject's scores by Student it'll be
    Subject Students Marks
    English A 89
    ......... C 70
    ......... D 60
    Maths B 30
    ......... C 80
    because Students and Subjects are joined by the Marks table
    What I'd like to see is
    Subject Students Marks
    English A 89
    ......... B 0
    ......... C 70
    ......... D 60
    Maths A 0
    ......... B 30
    ......... C 80
    ......... D 0
    The joins between the dimension and fact tables are all set to "Left-outer join" (where "left" is the dimension table)
    I thought I needed a cartesian/cross join on Subjects and Students, using the dummy table technique here: http://gerardnico.com/wiki/dat/obiee/densification_repository#the_cross_join_between_the_dimensions
    But it didn't work, not to mention that I have a feeling that this doesn't really apply to 10g or my problem.
    Can someone point me in the right direction on this? Thanks!
    Above problem solved, but I also need a column of "Count of students who scored 50 or less" which includes the students who did not have any scores. Adding the dummy column to my report breaks the aggregation in my report, while removing the column will take me back to square one.
    How do I generate a report that does aggregation that takes into account the students with no scores?
    Edited by: lum on 28-Mar-2012 20:13

    Here's what I did:
    I created the physical table with 1 column, and did a complex join with expression "1=1" on the 2 tables that my actual fact table was directly joined to (and none of the indirect joins). I'm using 11g, so to do complex joins I had to use Manage->Joins
    Then I added the dummy column to my Marks fact table in the BMM layer by just dragging it and set the aggregation rule. And then to the presentation layer too.
    After updating the repository onto the server, the table behaviour is still the same as before, and the dummy column didn't do anything and displayed a blank value.
    Could it be because of my other joins that make this dummy join not work? I don't even know if this 1=1 complex join work in 11g....!
    Has anyone tried this join technique in 11g? Thanks!
    PS: My dimension table and fact tables are actually logical tables that join several tables at the logical table source layer. My dummy fact table just joins the most detailed layer of the physical dimension tables.

  • Join columns of outer join with table have no uniqueness cons

    Hi! I'm getting noizy error in alert log from time to time:
    Join columns of outer join with table <table_name> have no uniqueness constraints
    I've collected all the queries (v$sql, all_source) with montioned table, but non of them produces that error if executed.
    Any hints how to reproduce this error or where else to search that buggy sql join?
    Edited by: user545083 on 25.10.2010 6:21

    Hi
    I think this error is output via an materialized view refresh - check for mviews against the given table which fulfil the issue given in the error text.
    Thanks
    Paul

  • How to join each row with other in the same table without repeating, please help

    Hi,
    I have a table say Adjustment having following data
    Emp_Id                  
    Adjustment_id                      
    Date
    1000101               
    1000300                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                               
    2014-02-12 00:00:00.000
    1000101               
    1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                               
    2014-02-12 00:00:00.000
    1000102               
    1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000304                               
    2014-02-12 00:00:00.000
    And I want following records:
    Emp_Id                  
    Adjustment_id      Adjustment_id1              
          Date
    1000101               
    1000300                1000301                               
    2014-02-12 00:00:00.000
    1000101               
    1000300                1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000300               
    1000303                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                1000302                               
    2014-02-12 00:00:00.000
    1000101               
    1000301                1000303                               
    2014-02-12 00:00:00.000
    1000101               
    1000302                1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                1000303                               
    2014-02-12 00:00:00.000
    1000102               
    1000302                1000304                               
    2014-02-12 00:00:00.000
    1000102                    
    1000303               
         1000304                                       
    2014-02-12 00:00:00.000

    Hi Uri,
    I am using SQL Server 2008, and I am trying join each adjustment_id with all other adjustment_id having same Date and Emp_id.
    so for following table records:
    Emp_Id                 
    Adjustment_id                
    Date
    1000102               
    1000302                         
    2014-02-12 00:00:00
    1000102               
    1000303                         
    2014-02-12 00:00:00
     1000102                   
    1000304                               
    2014-02-12 00:00:00
    Output should be:
    Emp_Id        
    Adjustment_id      Adjustment_id     
    Date
    1000102      
    1000302               1000303              
    2014-02-12 00:00:00 (first row with 2nd)
    1000102      
    1000302               1000304              
    2014-02-12 00:00:00 (first row with 3rd)
    1000102      
    1000303               1000304              
    2014-02-12 00:00:00 (2nd row with 3rd)

  • How can I crate a view with tables which require "Left outer join"?

    Hi guys,
    how can I define a view with tables which require "Left outer join"?. In SE11 "View",->tab "Join condition", it seems that it valid only for "Inner Join".
    Please give me some hint.
    Thanks in advance.
    Regards,
    Liying

    Hi
    Inner Join and Outer Join 
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join.
    With an inner join, you only get the records of the cross-product for which there is an entry in all tables used in the view.
    With an outer join, records are also selected for which there is no entry in some of the tables used in the view. (ABAP allows left outer join.)
    The data that can be selected with a view depends primarily on whether the view implements an inner join or an outer join.

  • PL/SQL: Populating Cursor with List then do IF EXISTS against Table

    Here is my issue. The DB I work with is an Event Database (Network Events). I have a task to take a list of 2600 nodes and see if these nodes exist with in a set of events which would be found with a certain WHERE clause. On my first pass, I did the WHERE clause AND NODE in (List of 2600 nodes). Well you can only put 1000 items in an in list so I split it up into 3 reports and then did a UNION all between them. This used 15% of db resources and ran for hours and the dba group would like me to find a better way. They would prefer that I use PL/SQL.
    I'm new to pl/sql (but not to programming nor sql). So the first thing I did is just figure out how to get my list into an Varray, which I then switched to a table because I could not find any examples, after hours and hours of searching the web,
    of referencing a Varray with SQL syntax.
    ******** BEGIN CODE Sample 1 ***********
    DECLARE
    DECLARE
    TYPE NodeList IS TABLE OF VARCHAR2(255);
    Nodes NodeList := NodeList('node1', node2', [......list of 2597 nodes..], 'node2600')
    BEGIN
    dbms_output.enable(1000000);
    FOR i IN Nodes.FIRST .. Nodes.LAST
    LOOP
    DBMS_OUTPUT.PUT_LINE('Relevant Items: ' || Nodes(i));
    END LOOP;
    END
    ******** END CODE Sample 1 ***********
    The pseudocode I'm envisioning goes something like this:
    IF any of these nodes (2600 node list) ,
    exist in the nodes for this WHERE clause (which is pulling from the db event table),
    then print out the records (of the events in the db event table) that contain those nodes (i.e the nodes from the list).
    I think I found an example of doing this with 2 cursors but I cant find that example again. And, anyway, I cant figure out how to get my list into a cursor. I have many examples of how to fill a cursor via a select against a db.
    I tried this but it did not work:
    ******** BEGIN CODE Sample 2 ***********
    DECLARE
    DECLARE
    TYPE NodeList IS TABLE OF VARCHAR2(255);
    Nodes NodeList := NodeList('node1', node2', [......list of 2597 nodes..], 'node2600')
    CURSOR MOM_OVO_NODES IS
    SELECT Node
    FROM NodeList
    ORDER BY Node;
    BEGIN
    dbms_output.enable(1000000);
    FOR nodelist_rec IN MOM_OVO_NODES
    LOOP
    dbms_output.put_line('Relevant Nodes: '||nodelist_rec.node);
    END LOOP;
    END
    ******** END CODE Sample 2 ***********
    Is there a way to get this list into a cursor? Or am I thinking about the whole thing incorrectly?
    brad

    Every time I come to OTN thinking I finally have a reason to use PL/SQL, I find that I really only need SQL! I'm never going to get to learn PL/SQL! :)
    Thanks for the link. The information is well written.
    Unfortunately, I dont have the rights to create a GTT table. I get ORA-01031.
    I work for a very large organization where even the DBA's are so task individualized that many of them can only do very specific tasks. So I dont see myself getting rights to create even temporary tables. That would probably take and act of God.
    So, accepting that pl/sql is NOT the best practices solution here. I'd still like to , as an exercise for the student, understand how I can populate a cursor with a list. Why wont my example work? Since I could ONLY find examples of using SELECT to populate a cursor, I turned my VARRAY into a table. Then I learned that I could initialize the table in the DECLARE section. Then I put my cursor declaration after the table initialization. Still no luck. Then I saw casting as TABLE mentioned but got nowhere with that. IS there a way to get that list into a cursor? Its really bothering me.
    Also, since its a table, and, as far as I know, in referring to a table, one needs to reference a column, what is the syntax for naming the single column in my table?
    I AM reading the pl/sql books on Safari, and I do have the 10lb tome from Steven Feuerstein sitting next to me. <-- I'd page through it more often if I could find a reason to use PL/SQL. Actually, the DBA group has mandated that I write everything in PL/SQL for "performance" reasons. I dont actually adhere to that but there it is.
    Also, whats the protocol for giving credit for answers on threads like this where several people give relatively the same answer? Do I just give the earliest time stamp full credit or give them all a "helpful"?
    brad

  • Data Transfer problem from cursor to table

    Hi ,
             I created one Extract FM to extract data through a Datasource by RAS3. When i run the FM directly  the cursor value (S_CURSOR) is displayed as 3850 and when i try to transfer using FETCH NEXT to a internal table (E_T_DATA) 498  entries populated but if i open the table all lines are blank. Pls help me. i.e. E_T_DATA[] = 498
    OPEN CURSOR WITH HOLD S_CURSOR FOR
        SELECT MATNR
        FROM MARA AS A "INNER JOIN MARC AS C
        "ON A~MATNR = C~MATNR
        "INTO TABLE E_T_DATA
        WHERE MATNR IN L_R_MATNREAN
          AND MTART IN ('ZPLU','ZPAK',
                          'ZCOM','ZTIN',
                          'ZSCR','ZEXW',
                          'ZCOU','ZGVR')
          AND EAN11 = ''
          AND ATTYP = '00'.
    FETCH NEXT CURSOR S_CURSOR
                 APPENDING CORRESPONDING FIELDS
                 OF TABLE E_T_DATA
                 PACKAGE SIZE S_S_IF-MAXSIZE.
      IF SY-SUBRC <> 0.
        CLOSE CURSOR S_CURSOR.
        RAISE NO_MORE_DATA.
      ENDIF.

    first of all you have to put your FETCH into a DO ... ENDDO

  • More than one join condition for 2 tables in obiee

    Hello,
    I am using obiee 11g.
    There are 2 tables tableA and tableB where the join condition is like (tableA.col1=tableB.col1) or (tableA.col1 is null and tableB.col1 is null)
    where should i do these type of joins.
    I tried putting in physcial layer->f(x) but giving error like here only columns an d opertaors are allowed.
    Thanks

    ok here it goes.
    I have a tableA with columns col1(pk),col2 and other columns
    I have tableB with columns col1(pk),col2..Only these 2 columns.
    Now distinct tableA.col2 values are put in tableB.col2. For those distinct values i have put the tableB.col1 values.
    Now tableA.col2 as well as tableB.col2 can be null beacuse there may be null values in tableA.col2.
    Now in tableB i have added one more row which has col1 as value and col2 as null.
    Now when in physical layer when i do tableA.col2=tableB.col2 i dont get the null values.
    What i want is whenever the tableA.col2 and tableB.col2 is null then take tableB.col1 for those vales.
    So when i query i do
    select * from tableA,tableB where
    ((tableA.col2=tableB.col2) or (tableA.col2 is null and tableB.col2 is null))
    What i want is when i do a join i should be able to give this OR condition in rpd thats it.
    because when i do in where clause of content tab it goes like a AND condition and not OR.
    Thanks
    Edited by: user123 on Jul 5, 2011 1:57 PM

  • Opening two cursors using open cursor with bulk collect on colections ..

    Is it possible to have the implementatiion of using bulk collect with collections using two open cursors ..
    first c1
    second c2
    open c1
    loop
    open c2
    loop
    end loop
    close c2
    end loop;
    close c1
    what i found is for every outer loop of cursor c1 , cursor c2 is open and closed for every record.
    is this willl imporove the performace .?
    EXAMPLE:-
    NOTE: The relatoin between finc and minc is one to many ..finc is parent and minc is child
    function chk_notnull_blank ( colname IN number ) return number is
    BEGIN
    if ( colname is NOT NULL and colname not in ( -8E14, -7E14, -6E14, -5E14, -4E14, -3E14, -2E14, -1E14, -1E9 )) then
    RETURN colname ;
    else
    RETURN 0;
    end if;
    END chk_notnull_blank;
    procedure Proc_AnnualFmlyTotIncSummary is
    CURSOR c_cur_finc IS SELECT FAMID FROM FINC ;
    CURSOR c_cur_minc IS SELECT FAMID, MEMBNO , ANFEDTX, ANGOVRTX, ANPRVPNX, ANRRDEDX, ANSLTX, SALARYX, SALARYBX, NONFARMX, NONFRMBX , FARMINCX, FRMINCBX, RRRETIRX, RRRETRBX, SOCRRX, INDRETX, JSSDEDX, SSIX, SSIBX from MINC minc WHERE FAMID IN ( SELECT FAMID FROM FINC finc WHERE minc.FAMID = finc.FAMID );
    v_tot_fsalaryx number := 0;
    v_tot_fnonfrmx number := 0;
    v_tot_ffrmincx number := 0;
    v_tot_frretirx number := 0;
    v_tot_findretx number := 0;
    v_tot_fjssdedx number := 0;
    v_tot_fssix number := 0;
    v_temp_sum_fsalaryx number := 0;
    v_temp_sum_fnonfrmx number := 0;
    v_temp_sum_ffrmincx number := 0;
    v_temp_sum_frretirx number := 0;
    v_temp_sum_findretx number := 0;
    v_temp_sum_fjssdedx number := 0;
    v_temp_sum_fssix number := 0;
    TYPE minc_rec IS RECORD (FAMID MINC.FAMID%TYPE, MEMBNO MINC.MEMBNO%TYPE , ANFEDTX MINC.ANFEDTX%TYPE, ANGOVRTX MINC.ANGOVRTX%TYPE , ANPRVPNX MINC.ANPRVPNX%TYPE , ANRRDEDX MINC.ANRRDEDX%TYPE , ANSLTX MINC.ANSLTX%TYPE, SALARYX MINC.SALARYX%TYPE , SALARYBX MINC.SALARYBX%TYPE , NONFARMX MINC.NONFARMX%TYPE , NONFRMBX MINC.NONFRMBX%TYPE, FARMINCX MINC.FARMINCX%TYPE , FRMINCBX MINC.FRMINCBX%TYPE , RRRETIRX MINC.RRRETIRX%TYPE , RRRETRBX MINC.RRRETRBX%TYPE, SOCRRX MINC.SOCRRX%TYPE , INDRETX MINC.INDRETX%TYPE , JSSDEDX MINC.JSSDEDX%TYPE , SSIX MINC.SSIX%TYPE , SSIBX MINC.SSIBX%TYPE );
    v_flag_boolean boolean := false;
    v_famid number ;
    v_stmt varchar2(3200) ;
    v_limit number := 50;
    v_temp_FAMTFEDX number := 0 ;
    v_temp_FGOVRETX number := 0 ;
    v_temp_FPRIVPENX number := 0 ;
    v_temp_FRRDEDX number := 0 ;
    v_temp_FSLTAXX number := 0 ;
    v_temp_FSALARYX number := 0 ;
    v_temp_FNONFRMX number := 0 ;
    v_temp_FFRMINCX number := 0 ;
    v_temp_FRRETIRX number := 0 ;
    v_temp_FINDRETX number := 0 ;
    v_temp_FJSSDEDX number := 0 ;
    v_temp_FSSIX number := 0 ;
    BEGIN
    OPEN c_cur_finc ;
    LOOP
         FETCH c_cur_finc BULK COLLECT INTO famid_type_tbl LIMIT v_limit;
         EXIT WHEN famid_type_tbl.COUNT = 0;
         FOR i in famid_type_tbl.FIRST..famid_type_tbl.LAST
         LOOP
         OPEN c_cur_minc ;
         LOOP
         FETCH c_cur_minc BULK COLLECT INTO minc_rec_type_tbl LIMIT v_limit;
         EXIT WHEN minc_rec_type_tbl.COUNT = 0;
              FOR j IN minc_rec_type_tbl.FIRST..minc_rec_type_tbl.LAST
              LOOP
              if ( famid_type_tbl(i) = minc_rec_type_tbl(j).FAMID ) THEN
              v_temp_FAMTFEDX := v_temp_FAMTFEDX + chk_notnull_blank(minc_rec_type_tbl(j).ANFEDTX );
              v_temp_FGOVRETX := v_temp_FGOVRETX + chk_notnull_blank(minc_rec_type_tbl(j).ANGOVRTX);
              v_temp_FPRIPENX := v_temp_FPRIPENX + chk_notnull_blank(minc_rec_type_tbl(j).ANPRVPNX);
              v_temp_FRRDEDX := v_temp_FRRDEDX + chk_notnull_blank(minc_rec_type_tbl(j).ANRRDEDX);
              v_temp_FSLTAXX := v_temp_FSLTAXX + chk_notnull_blank(minc_rec_type_tbl(j).ANSLTX );
              v_temp_FSALARYX := v_temp_FSALARYX + chk_notnull_blank(minc_rec_type_tbl(j).SALARYX ) + chk_notnull_blank(minc_rec_type_tbl(j).SALARYBX);
              v_temp_FNONFRMX := v_temp_FNONFRMX + chk_notnull_blank(minc_rec_type_tbl(j).NONFARMX) + chk_notnull_blank(minc_rec_type_tbl(j).NONFRMBX);
              v_temp_FFRMINCX := v_temp_FFRMINCX + chk_notnull_blank(minc_rec_type_tbl(j).FARMINCX) + chk_notnull_blank(minc_rec_type_tbl(j).FRMINCBX );
              v_temp_FRRETIRX := v_temp_FRRETIRX + chk_notnull_blank(minc_rec_type_tbl(j).RRRETIRX) + chk_notnull_blank(minc_rec_type_tbl(j).RRRETRBX ) + chk_notnull_blank(minc_rec_type_tbl(j).SOCRRX);
              v_temp_FINDREXT := v_temp_FINDRETX + chk_notnull_blank(minc_rec_type_tbl(j).INDRETX);
              v_temp_FJSSDEDX := v_temp_FJSSDEDX + chk_notnull_blank(minc_rec_type_tbl(j).JSSDEDX);
              v_temp_FSSIX := v_temp_FSSIX + chk_notnull_blank(minc_rec_type_tbl(j).SSIX ) + chk_notnull_blank(minc_rec_type_tbl(j).SSIBX);
              END IF;
              END LOOP;
         END LOOP ;
         CLOSE c_cur_minc;
         UPDATE FINC SET FAMTFEDX = v_temp_FAMTFEDX WHERE FAMID = famid_type_tbl(i);
         END LOOP;
    END LOOP;
    CLOSE c_cur_finc;
    END;
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    v_err_code := SQLCODE;
    v_err_msg := substr(SQLERRM, 1, 200);
    INSERT INTO audit_table (error_number, error_message) VALUES (v_err_code, v_err_msg);
    error_logging(p_error_code => substr(sqlerrm,1,9), p_error_message => substr(sqlerrm,12), p_package =>'PKG_FCI_APP',p_procedure => 'Proc_Annual_Deductions_FromPay ' , p_location => v_location);
    end Proc_AnnualFmlyTotIncSummary ;
    Is the proga efficient and free from compilation errors ..?
    thanks/kumar
    Edited by: kumar73 on Sep 22, 2010 12:48 PM

    function chk_notnull_blank ( colname IN number ) return number is Maybe this function should have its own forum:
    how to use case in this program
    Re: how to declare a formal parameter in a function of type record and access ?
    Re: how to define a function with table type parameter
    Re: creation of db trigger with error ..
    Re: How to write a trigger for the below scenario
    how to improve the code using advanced methods
    yours advice in improving the coding ..
    How to use bulk in multiple cursors !!
    ;-)

  • How to bring cursor in Table control??

    Hi to all
    How to bring cursor in Table control when entering into screen
    can anyone tell me??? pls explain with example..
    thanks
    senthil

    Hi,
    Check the below code
    data l_tc_name             like feld-name.
    data l_tc_field_name       like feld-name.
    get actual tc and column                            
      get cursor field l_tc_field_name
                 area  l_tc_name.
    Regards,
    Vind

  • Logical table does not join to any logical table

    HI,
    I want to implement Business Unit hierarchy for drill down in OBIEE  so I’ve created a custom table with the hierarchy information,
    I’ve imported that table in the out-of the box physical schema & defined a relationship between the W_ORG_D table & my custom INVENTRY_ORG table as INVENTRY_ORG.BU_ID = W_ORG_D. VIS_PR_BU_ID* but when I try to check in my changes I’m getting the following error.*
    Logical table INVENTRY_ORG does not join to any logical table.
    Kindly let me know how to resolve this error.One more doubt i have is can we import custom tables in the out of the box OBIEE mappings for SIEBEL..that is the core subject area.
    Thanks,

    Hi user10340125 ,
    1) I think you have joined tables in physical layer, but you have not created complex join in logical layer.
    Check your consistency and see what warnings you are getting.
    2) Yes you can import custom tables in whatever subject area. Once you imported tables in physical layer, then they all are just objects, so you can freely play around with them. Just for best practices, make sure you follow proper naming convention for custom tables and columns..
    - Vinay

Maybe you are looking for

  • Printing to Kodak printer

    Hi I can print my photos from iPad to Kodak c310 printer via the Kodak app ok, but I can print a web page or anything else , how can I resolve this, I think I may need an app but don't know which one if so

  • Can I load Acrobat Pro 6 onto Windows 7 and upgrade to Acrobat Pro 9?

    Can I load Acrobat Pro 6 onto Windows 7 and upgrade to Acrobat Pro 9?  My former PC ran on Windows XP and this new PC runs on Windows 7.  I don't want to shell out another $449 when Acrobat Pro 9 worked fine for me.

  • Not getting the Exception_.toString in Forms

    Hi, I hope someone can help me. I have a java jar file. The jar file executes properly from the command prompt. The functionality in this java method is to call a HELLO WORLD service of a hosted webservice. So on its own the jar works fine, I know th

  • Fix for mail non-delivery in 10.5.2

    After the 10.5.2 update I found that mail was stalling in the inbound queue - users could still send but not receive. The solution seems to be to add your domain name to the Local Host Aliases list (Mail - Advanced - Hosting tab in Server Admin), tur

  • Update to 10 won't take 9 Registration Number

    Upgrading from 9 to 10 .. (win 7) ... says I have an invalid registration number ... but this is the number I get from My Adobe, exactly. I've tried it with and without the dashes. How can this be resolved?