Many child cursors on an insert statement

Oracle: 10.2.0.5
Cursor_sharing = exact
I understand how you get many child cursors with cursor sharing set to exact. However, this is an insert statement. It has a plan_hash_value = 0 and there are not any explain plans in v$sql_plan.
They all have the parsing_schema_name = 'GWYDB'
This is not an issue with multiple copies of the same table in different schemas since the statement has <owner>.<table name>
this is a 1 line insert statement.
insert into schema.mytablue values (:b1.:b2,:b3);

Guess2 wrote:
Oracle: 10.2.0.5
Cursor_sharing = exact
I understand how you get many child cursors with cursor sharing set to exact. However, this is an insert statement. It has a plan_hash_value = 0 and there are not any explain plans in v$sql_plan.
They all have the parsing_schema_name = 'GWYDB'
This is not an issue with multiple copies of the same table in different schemas since the statement has <owner>.<table name>
this is a 1 line insert statement.
insert into schema.mytablue values (:b1.:b2,:b3);Oracle ERROR indicates something need to change.
post SQL & error code and message that needs to be fixed.

Similar Messages

  • Too many child cursors with reasons unknown

    Hi,
    I am looking at excessive child cursors for a particular SQL even after setting the CURSOR_SHARING parameter to SIMILAR. I am working on Oracle 10.2.0.4.0 hosted on a Windows 2003 Server. Since the application does not use bind variables I decided to test the efficiency of modifying the CURSOR_SHARING parameter to buy some time before the root cause is fixed.
    On querying V$SQL_SHARED_CURSOR I find that none of the flag columns which document the reason for the formation of a child cursor is Y. They are all flagged as N. So, I am perplexed as to why so many child cursors are being generated.
    Some statistical information below:
    Version Count for the SQL_ID = 23506
    Count of hash values for the SQL_ID = 1234048
    Total (sum) chunk size for the SQL_ID = 112,436,220
    Any clues/directions on how to get about this issue?
    Regards

    Indeed, histograms are being collected on the columns
    that form the predicates of the query. Doesn't this
    in fact offset the advantages of using bind variables
    to share SQL?Aniruddha,
    Correct. If you have a column that you think deserves a histogram then your front-end code has to co-operate with the database to make the histogram as useful as possible.
    If you are lucky, this means you can simply write your code to use a literal value for the predicate on that column and only end up with a few distinct versions of the SQL. At the opposite extreme, you could decide that the overhead of having hundreds of versions of the same query is less of a threat than having a really bad execution plan some of the time. In the more subtle cases, you may have to write code that is "histogram-aware" - i.e. it knows that it has to generate one of a few different statements depending on the supplied values.
    Histograms and bind variables don't go together comfortably - and that's a little nasty when you mix cursor_sharing=similar and the 10g automatic stats collection routines.
    Regards
    Jonathan Lewis
    http://jonathanlewis.wordpress.com
    http://www.jlcomp.demon.co.uk

  • Use of the "updlock" hint with update and insert statements

    I have inherited some stored procedures and am trying to figure out why the developers decided to use the "updlock" hint on many of the update and insert statements. I have looked around everywhere and have found only one explanation of why "update...with
    (updlock)" can be useful, namely when a table has no clustered index:
    http://www.sqlnotes.info/2012/10/10/update-with-updlock/ I have found nothing yet that mentions why "insert into...with (updlock)" might be used. I understand why the hint
    might be useful on select statements in some cases, but if all of the tables have clustered indexes, is there any good reason to use it on update and insert statements?
    Thanks,
    Ron
    Ron Rice

    This form of deadlock error can occur on a table which has a clustered index.
    If you are doing updates on a table which has a clustered index and that table also has a nonclustered index and the nonclustered index is used to find the row to update you can see this type of deadlock.  For example create a table with a clustered
    primary key index and a nonclustered index by running
    Create Table Foo(PK int primary key identity, OtherKey varchar(10), OtherData int);
    go
    Insert Foo Default Values;
    go 10000
    Update Foo Set OtherKey = 'C' + Cast(PK As varchar(10))
    Create Unique Index FooIdx On Foo(OtherKey);
    That creates a table with 10000 rows, a clustered index and a nonclustered index.  Then run
    Begin Transaction
    Update Foo Set OtherData = 1 Where OtherKey = 'C5'
    That will use the FooIdx index to find the row that needs to be updated.  It will get a U lock on the index row in the FooIdx index, then an X lock on the row in the clustered index, update that row, then free the U lock on FooIdx, but keep the X lock
    on the row in the clustered index.  (There is other locking going on, but to simplify things, I'm only showing the locks that lead to the deadlock).
    Then in another window, run
    Begin Transaction
    Update Foo Set OtherData = 2 Where OtherKey = 'C5'
    This will get a U lock on the index row in the FooIdx index, then try to get an X lock on the row in the clustered index.  But that row is already exclusively locked, so this second window will wait holding a U lock on FooIdx row and is waiting for
    an X lock on the clustered index row.
    Now go back to the first window and run
    Update Foo Set OtherData = 3 Where OtherKey = 'C5'
    This will once again try to get the U lock on the FooIdx row, but it is blocked by the U lock the second window holds.  Of course the second window is blocked by the X lock on the clustered index row and you have a deadlock.
    All that said, I certainly do not routinely code my updates with UPDLOCK.  I try to design databases and write code so that deadlocks will be rare without holding excessive locks.  The more locks you hold and the longer you hold them, the more
    blocking you will get and the slower your system will run.  So I write code that if a deadlock exception occurs, it is properly handled.  Then if too many deadlocks occur, that is the time to go back to the code to see what changes are needed to
    decrease the number of deadlocks (one way to do that may be to get locks earlier and/or hold them longer. 
    But I wouldn't worry much about this form of deadlock.  It is, in my experience, vary rare.  I don't recall ever seeing it in a production environment.
    Tom

  • How many insert statements to run in a batch

    Hi all,
    I have access to a table in a database. For one reason and another that I wont go into, this project only lets me run select and insert statements against this table. The reason I state this is because I know for performance its better not to use neat inserts but in this instance it is the only option.
    so... I have a c# application that has hold of a big set of data. In terms of performance would those people who are far more experienced with Oracle than myself consider it better to perform each insert statement on its own. Then move to the next. or... build a statement up that contains 10..20..30..100? statements and bulk run them.
    If it is better to bulk run... I know this is going to be a subjective question but what are the limits to the amount of statements one should run in a go.
    I have in the past run auto built scripts of 200mb+ in sqlDeveloper and it tended to break it. I think this is more an issue with sqlDeveloper than oracle however.
    Thanks Guys / Girls

    This thread looks useful to me. Please skim through.
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1583402705463

  • Plsql insert statement.  urgent help needed

    Hi all oracle gurus
    I am trying to insert a value which is difference between two dates, for that reason i am doing (" rec_jag_promos.end_date -rec_jag_promos.start_date") inside my insert statement.
    but it is not working. my plsql code is running but not giving me any o/p.
    Here what i am trying to do is i want to insert DAYS value into my table which is between start date and end date.
    ........its not working . please guide me or correct me.
    Below is part of my querry ........
    Thanks
    -- migrate data
    FOR rec_jag_promos IN cur_jag_promos
    LOOP
    v_jag_count := v_jag_count + 1;
    BEGIN
    v_wots_hot_id := rec_jag_promos.promotion_id;
    -- this call will throw and exception 0 or many regions found
    v_region_id := get_region_id( rec_jag_promos.promotion_id, rec_jag_promos.region_display_type );
    INSERT INTO wotif_promo.WOTS_HOT
    ( id, country_code,
    start_date, end_date,inventory_source_id,hotel_id,
    rate_plan_code,region_id,blurb, modified_username,
    version,DAYS_ACTIVE )
    VALUES
    ( v_wots_hot_id, rec_jag_promos.country_code,
    rec_jag_promos.start_date, rec_jag_promos.end_date,v_inv_source_id,rec_jag_promos.hotel_id,
    rec_jag_promos.rate_plan_code, v_region_id, rec_jag_promos.blurb, rec_jag_promos.modified_username,
    1, rec_jag_promos.end_date-rec_jag_promos.start_date);
    v_wots_hot_inserts := v_wots_hot_inserts + 1;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT Insert Error on wots_hot_id : ' || rec_jag_promos.wots_hot_id );
    DBMS_OUTPUT.PUT_LINE( SQLCODE || ' ' || SQLERRM );
    v_wots_hot_errs := v_wots_hot_errs + 1;
    END;

    I am trying to insert a value which is difference between two dates, for that reason i am doing (" rec_jag_promos.end_date -rec_jag_promos.start_date") inside my insert statement.
    ........its not working . please guide me or correct me.
    Below is my file ........
    Thanks
    DECLARE
    -- cursors
    CURSOR cur_inventory_source IS
    select id
    from wotif_common.inventory_source
    where SHORT_DESCRIPTION = 'wotif';
    CURSOR cur_jag_promos IS
    select wh.id as wots_hot_id, p.id as promotion_id, cty.iso_countrycode as country_code,
    wh.blurb, dm.propid as hotel_id,
    p.startdts as START_DATE, p.expirydts as END_DATE,
    wa.username as modified_username, rt.roomtypecode as rate_plan_code,
    dm.dealdate as hot_date, dm.advertisedrate as price,
    wh.REGIONDISPLAYTYPE as region_display_type
    from wotif_web.PROM_wots_hot wh
    join wotif_web.PROMOTION p on wh.promotionid=p.id
    join wotif_web.country cty on p.countrycode=cty.countrycode
    join wotif_web.deal_master dm on wh.dealid=dm.dealid
    join wotif_web.prop_master_room_type rt on rt.proproomtypeid=dm.proproomtypeid
    join wotif_web.wotif_administrator wa on p.adminid = wa.administratorid
    where p.expirydts < trunc(sysdate) ---> TRUNC(sysdate)
    order by wh.id;
    -- variables
    v_debug BOOLEAN := FALSE;
    v_nls_length_semantics VARCHAR2(255);
    v_jag_count INTEGER := 0;
    v_inv_source_id WOTIF_COMMON.INVENTORY_SOURCE.ID%TYPE;
    v_wots_hot_id WOTIF_PROMO.WOTS_ON.ID%TYPE;
    v_wots_hot_day_id WOTIF_PROMO.WOTS_ON_DAY.ID%TYPE;
    v_wots_hot_inserts INTEGER := 0;
    v_wots_hot_day_inserts INTEGER := 0;
    v_wots_hot_errs INTEGER := 0;
    v_wots_hot_rate_plan_errs INTEGER := 0;
    v_wots_hot_day_errs INTEGER := 0;
    v_region_id wotif_promo.WOTS_HOT.region_id%TYPE;
    -- variables
    FUNCTION get_region_id
    p_promotion_id IN wotif_web.PROMOTION.id%TYPE,
    p_region_type_enum IN wotif_web.PROM_WOTS_HOT.regiondisplaytype%TYPE
    ) RETURN NUMBER
    IS
    CURSOR cur_sub_region
    p_promotion_id IN wotif_web.PROMOTION.id%TYPE,
    p_region_type IN wotif_web.PROPERTY_REGION.region_type%TYPE
    ) IS
    select reg.region_id as REGION_ID
    from wotif_web.PROM_WOTS_HOT wh
    join wotif_web.PROPERTY_REGION reg on wh.propid = reg.prop_id
    where wh.promotionid = p_promotion_id
    and reg.region_type = p_region_type;
    CURSOR cur_region
    p_promotion_id IN wotif_web.PROMOTION.id%TYPE,
    p_region_type IN wotif_web.PROPERTY_REGION.region_type%TYPE
    ) IS
    select NVL(reg.parent_id, reg.id) as REGION_ID
    from wotif_web.PROM_WOTS_HOT wh
    join wotif_web.PROPERTY_REGION prop_reg on wh.propid = prop_reg.prop_id
    join wotif_web.region reg on prop_reg.region_id = reg.id
    where wh.promotionid = p_promotion_id
    and prop_reg.region_type = p_region_type;
    v_region_id wotif_web.PROPERTY_REGION.region_id%TYPE;
    BEGIN
    -- if region A
    IF p_region_type_enum = 0
    THEN
    OPEN cur_region( p_promotion_id, 'A' );
    FETCH cur_region INTO v_region_id;
    CLOSE cur_region;
    END IF;
    -- if region B
    IF p_region_type_enum = 2
    THEN
    OPEN cur_region( p_promotion_id, 'B' );
    FETCH cur_region INTO v_region_id;
    CLOSE cur_region;
    END IF;
    -- if sub_region A
    IF p_region_type_enum = 1
    THEN
    OPEN cur_sub_region( p_promotion_id, 'A' );
    FETCH cur_sub_region INTO v_region_id;
    CLOSE cur_sub_region;
    END IF;
    -- if sub_region B
    IF p_region_type_enum = 3
    THEN
    OPEN cur_sub_region( p_promotion_id, 'B' );
    FETCH cur_sub_region INTO v_region_id;
    CLOSE cur_sub_region;
    END IF;
    RETURN v_region_id;
    END get_region_id;
    -- main block
    BEGIN -- outer block
    -- initialise
    DBMS_OUTPUT.enable( 1000000 );
    -- validate
    EXECUTE IMMEDIATE 'alter session set NLS_LENGTH_SEMANTICS = ''CHAR''';
    SELECT VALUE
    INTO v_nls_length_semantics
    FROM NLS_SESSION_PARAMETERS
    WHERE PARAMETER = 'NLS_LENGTH_SEMANTICS';
    DBMS_OUTPUT.put_line('nls length semantics: ' || v_nls_length_semantics);
    IF v_nls_length_semantics 'CHAR' THEN
    RAISE_APPLICATION_ERROR( -20005, 'PROMO_MIGRATION ERROR: NLS_LENGTH_SEMANTICS set incorrectly');
    END IF;
    OPEN cur_inventory_source;
    FETCH cur_inventory_source INTO v_inv_source_id;
    CLOSE cur_inventory_source;
    DBMS_OUTPUT.put_line('v_inv_source_id: ' || v_inv_source_id);
    IF v_inv_source_id IS NULL THEN
    RAISE_APPLICATION_ERROR( -20005, 'PROMO_MIGRATION ERROR: v_inv_source_id not set');
    END IF;
    -- migrate data
    FOR rec_jag_promos IN cur_jag_promos
    LOOP
    v_jag_count := v_jag_count + 1;
    BEGIN
    v_wots_hot_id := rec_jag_promos.promotion_id;
    -- this call will throw and exception 0 or many regions found
    v_region_id := get_region_id( rec_jag_promos.promotion_id, rec_jag_promos.region_display_type );
    INSERT INTO wotif_promo.WOTS_HOT
    ( id, country_code,
    start_date, end_date,inventory_source_id,hotel_id,
    rate_plan_code,region_id,blurb, modified_username,
    version,DAYS_ACTIVE )
    VALUES
    ( v_wots_hot_id, rec_jag_promos.country_code,
    rec_jag_promos.start_date, rec_jag_promos.end_date,v_inv_source_id,rec_jag_promos.hotel_id,
    rec_jag_promos.rate_plan_code, v_region_id, rec_jag_promos.blurb, rec_jag_promos.modified_username,
    *1, rec_jag_promos.end_date -rec_jag_promos.start_date);*
    v_wots_hot_inserts := v_wots_hot_inserts + 1;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT Insert Error on wots_hot_id : ' || rec_jag_promos.wots_hot_id );
    DBMS_OUTPUT.PUT_LINE( SQLCODE || ' ' || SQLERRM );
    v_wots_hot_errs := v_wots_hot_errs + 1;
    END;
    -- insert single mandatory wots_hot_day
    BEGIN
    v_wots_hot_day_id := wotif_promo.wots_hot_day_seq.nextval;
    INSERT INTO wotif_promo.wots_hot_day
    ( id, wots_hot_id, hot_date, price )
    VALUES
    ( v_wots_hot_day_id, v_wots_hot_id, rec_jag_promos.hot_date, rec_jag_promos.price );
    v_wots_hot_day_inserts := v_wots_hot_day_inserts + 1;
    EXCEPTION
    WHEN OTHERS THEN
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT DAYS Insert Error on wots_hot_id : ' || rec_jag_promos.wots_hot_id );
    DBMS_OUTPUT.PUT_LINE( SQLCODE || ' ' || SQLERRM );
    v_wots_hot_day_errs := v_wots_hot_day_errs + 1;
    END;
    END LOOP; -- wots_hot loop
    DBMS_OUTPUT.PUT_LINE( 'Jaguar wots hot count ' || NVL( v_jag_count,0) );
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT' );
    DBMS_OUTPUT.PUT_LINE( 'inserts ' || NVL( v_wots_hot_inserts,0) );
    DBMS_OUTPUT.PUT_LINE( 'errors ' || NVL( v_wots_hot_errs,0) );
    DBMS_OUTPUT.PUT_LINE( ' ' );
    DBMS_OUTPUT.PUT_LINE( 'WOTS_HOT_DAY' );
    DBMS_OUTPUT.PUT_LINE( 'inserts ' || NVL( v_wots_hot_day_inserts,0) );
    DBMS_OUTPUT.PUT_LINE( 'errors ' || NVL( v_wots_hot_day_errs,0) );
    DBMS_OUTPUT.PUT_LINE( ' ' );
    END; --outer block
    commit;
    select count(*) from wotif_promo.wots_hot;
    select count(*) from wotif_promo.wots_hot_day;
    select * from wotif_promo.wots_hot_day;
    --commit;
    --rollback;                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Situations when child cursors are created.....

    Hi ,
    I 'd like to ask when child cursor(s) is created..., when a similar or exact text string for sql statement is found on the SQL AREA (Library cache of shared pool) but for a/many reason(s) - described in the v$sql_shared_memory- the same sql area cannot be used..., or for any other reason....???
    Does the value of CURSOR SHARING parameter affect this matter...??????
    Many thanks,
    Simon
    Message was edited by:
    sgalaxy
    Message was edited by:
    sgalaxy

    Hi Simon,
    The purpose of child cursors is to allow Oracle to save some memory. If you have a SQL that that is an exact literal match, but can't be shared for some other reason (i.e. bind variable mismatch, optimizer environment mismatch, etc), a new child is created. This allows one literal SQL statement to have two separate execution plans, without wasting space in the library cache by duplicating SQL that is identical. When that happens, V$SQL_SHARED_CURSOR should tell you the reason for the extra child. (I say "should" cause there have been numerous bugs filed on various versions where there are cases that child cursors are created and no reason is populated in V$SQL_SHARED_CURSOR.)
    Now, how does CURSOR_SHARING fit into the picture? Well, if you have a well-designed application that uses bind variables to allow for sharable SQL, then CURSOR_SHARING is not required and should be set to exact. In cases where bind variables are not used, and the shared pool is getting slammed w/ lots of unique literal SQL, then setting CURSOR_SHARING to force or similar will replace literals with system generated bind variables, and allow for sharing of the resultant SQL.
    Hope that helps,
    -Mark

  • Insert statement

    Hi...
    I want to make an insert statement with a cursor, and if in the destination table exists allready a record like in start table, I would like to skip to insert that record.....and inserting the other records from the start table......
    Can anyone help me?
    Thanks.

    Why not a plain insert statement like this
    insert into dest_table (col1, col2)
    select col3, col4
    from source_table
    where not exists(select 1 from dest_table where col1=col4);

  • Issu for running insert statement in oracle procedure.

    Hi expert,
    I ran a oracle procedure with a insert statement inside as:
    insert into table1 select....
    but I got error message related to this insert statement as "SQLERRM= ORA-08103: object no longer exists"
    I ran this statement separately in toad, no error message, but no data result from this execute.
    please tell how to fix this issue.
    Many Thanks,
    Edited by: 918440 on 27-Jun-2012 8:04 AM

    Hi friend,
    my insert statement is as follows:
            INSERT INTO HIROC_RU_FACT_S   
            select   
                    pp.policy_fk,  
                    pp.transaction_log_fk,  
                    p.policy_no,  
                    p.policy_type_code,   
                    hiroc_rpt_user.hiroc_get_entity_name(pp.policy_fk,'POLHOLDER')  policy_holder,  
                    pp.risk_fk,   
                    r.risk_base_record_fk,   
                    r.entity_fk,  
                    hiroc_sel_entity_risk_name2 (pp.risk_fk,r.entity_fk)  risk_name,   
                    substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2) rating_state_code,  
                    hiroc_get_province_name(substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2), 'PROVINCE_CODE', 'L') rating_state_name,  
                    hiroc_get_provicne_pol_prefix(substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2),p.policy_type_code) rating_prov_pol_prefix,   
                    nvl(r.risk_cls_used_to_rate,pth.peer_groups_code) rating_peer_group_code,  
                    hiroc_get_lookup_desc('PEER_GROUP',nvl(r.risk_cls_used_to_rate,pth.peer_groups_code),'L')  rating_peer_group_name,   
                    pth.policy_term_history_pk,   
                    pth.term_base_record_fk,   
                    to_char(pth.effective_from_date,'yyyy') term_effective_year,   
                    c.coverage_pk,   
                    c.coverage_base_record_fk,   
                    pc.coverage_code,   
                    c.product_coverage_code,   
                    pc.long_description,   
                    pp.coverage_component_code,  
                    c.effective_from_date,   
                    c.effective_to_date,  
                    cls.coverage_code coverage_class_code,   
                    cls.coverage_long_desc coverage_class_long_desc,   
                    decode(pp.coverage_component_code ,'GROSS',cls.exposure_unit,null) exposure_unit, --hiroc_get_expos_units_by_cov(c.coverage_pk,pc.coverage_code,c.effective_from_date,c.effective_to_date) exposure_unit,   
                    decode(pp.coverage_component_code ,'GROSS',cls.number_of_patient_day,null) number_of_patient_day,   
                    pth.effective_from_date  term_eff_from_date,   
                    pth.effective_to_date term_eff_to_date,    
                    pp.premium_amount premium_amount,    
                    (case when (pc.coverage_code in ('CP','MC1','MC2','MC3','MC4','HR','F') or pc.coverage_code like 'ST%') and  
                                  pp.coverage_component_code != 'RISKMGMT' then     
                            (nvl(pp.premium_amount,0))  
                        else  
                            0  
                    end) primary_premium,   
                    (hiroc_get_risk_units(hiroc_get_provicne_pol_prefix(substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2),p.policy_type_code)-- rating_prov_pol_prefix  
                                        ,nvl(r.risk_cls_used_to_rate,pth.peer_groups_code) -- rating_peer_group_code  
                                        ,cls.coverage_code --coverage_class_code  
                                        ,decode(pp.coverage_component_code ,'GROSS',cls.exposure_unit,null)  
                                        ,pp.premium_amount  
                                        ,(case when (pc.coverage_code in ('CP','MC1','MC2','MC3','MC4','HR','F') or pc.coverage_code like 'ST%') and  
                                                      pp.coverage_component_code != 'RISKMGMT' then     
                                                (nvl(pp.premium_amount,0))  
                                            else  
                                                0  
                                         end)  -- primary_premium  
                                        ,p.policy_type_code           
                                        ,trunc(pth.effective_to_date))) risk_units  
             from     proddw_mart.rmv_territory_makeup tm,  
                      proddw_mart.rmv_premium_class_makeup pcm,  
                      proddw_mart.rmv_product_coverage pc,  
                      proddw_mart.rmv_coverage c,  
                      proddw_mart.rmv_risk r,  
                      proddw_mart.rmv_policy_term_history pth,  
                      proddw_mart.rmv_policy p,  
                      proddw_mart.rmv_transaction_log tl,  
                      proddw_mart.rmv_policy_premium pp,  
                      (select  /* +rule */  
                               p.policy_no,  
                               p.policy_start_date,  
                               p.policy_end_date,   
                               r.risk_pk,  
                               r.risk_description,  
                               c.coverage_pk,  
                               c.parent_coverage_base_record_fk,  
                               pc.parent_product_covg_code,  
                               pc.coverage_code,  
                               pc.short_description coverage_short_desc,   
                               pc.long_description coverage_long_desc,  
                               c.exposure_unit,  
                               pc.exposure_basis_code,  
                               c.number_of_patient_day,  
                               p.policy_start_date policy_effective_date,  
                               p.policy_end_date policy_expiry_date,  
                               c.effective_from_date,  
                               c.effective_to_date,  
                               to_char(c.effective_from_date,'YYYY') class_eff_year  
                        from   proddw_mart.odwr_coverage_only      c  
                              ,proddw_mart.odwr_product_coverage   pc  
                              ,proddw_mart.odwr_risk               r  
                              ,proddw_mart.odwr_policy             p  
                        where  pc.code                 = c.product_coverage_code  
                          and  pc.parent_product_covg_code is not null                 -- coverage classes only  
                          and  r.risk_pk = c.risk_base_record_fk  
                          and  c.accounting_to_date = to_date('1/1/3000','mm/dd/yyyy') -- only open records  
                          and  c.base_record_b = 'N'  
                          and  p.base_record_b = 'N'  
                          and  p.policy_pk = r.policy_fk  
                          and  p.accounting_to_date = to_date('1/1/3000','mm/dd/yyyy')  -- only open records  
                       group by p.policy_no,  
                               p.policy_start_date,  
                               p.policy_end_date,   
                               r.risk_pk,  
                               r.risk_description,  
                               c.coverage_pk,  
                               c.parent_coverage_base_record_fk,  
                               pc.parent_product_covg_code,  
                               pc.coverage_code,  
                               pc.short_description, -- coverage_short_desc,   
                               pc.long_description, -- coverage_long_desc,  
                               c.exposure_unit,  
                               pc.exposure_basis_code,  
                               c.number_of_patient_day,  
                               p.policy_start_date, -- policy_effective_date,  
                               p.policy_end_date, -- policy_expiry_date,  
                               c.effective_from_date,  
                               c.effective_to_date,  
                               to_char(c.effective_from_date,'YYYY')-- class_eff_year  
                      ) cls  
                where    tm.risk_type_code = r.risk_type_code  
                and        tm.county_code = r.county_code_used_to_rate  
                and        tm.effective_from_date <= pp.rate_period_from_date  
                and        tm.effective_to_date   >  pp.rate_period_from_date  
                and        pcm.practice_state_code (+) = r.practice_state_code  
                and        pcm.risk_class_code (+) = r.risk_cls_used_to_rate  
                and        nvl(pcm.effective_from_date, pp.rate_period_from_date) <= pp.rate_period_from_date  
                and        nvl(pcm.effective_to_date, to_date('01/01/3000','mm/dd/yyyy')) > pp.rate_period_from_date  
                and        pc.code = c.product_coverage_code  
                and        c.base_record_b = 'N'  
                and        ( c.record_mode_code = 'OFFICIAL'  
                         and (c.closing_trans_log_fk is null or  
                              c.closing_trans_log_fk != tl.transaction_log_pk)  
                         or c.record_mode_code = 'TEMP'  
                         and c.transaction_log_fk = tl.transaction_log_pk )  
                and   c.parent_coverage_base_record_fk is null  
                and        c.effective_from_date  <  c.effective_to_date  
                and        c.effective_from_date  <= pp.rate_period_from_date  
                and        c.effective_to_date    >  pp.rate_period_from_date  
                and   c.accounting_from_date <= tl.accounting_date  
                and   c.accounting_to_date   >  tl.accounting_date  
                and        c.coverage_base_record_fk=pp.coverage_fk  
                and        r.base_record_b = 'N'  
                and        ( r.record_mode_code = 'OFFICIAL'  
                        and (r.closing_trans_log_fk is null or  
                             r.closing_trans_log_fk != tl.transaction_log_pk)  
                        or r.record_mode_code = 'TEMP'  
                        and r.transaction_log_fk = tl.transaction_log_pk )  
                and        r.effective_from_date  <  r.effective_to_date  
                and        r.effective_from_date  <= pp.rate_period_from_date  
                and        r.effective_to_date    >  pp.rate_period_from_date  
                and   r.accounting_from_date <= tl.accounting_date  
                and   r.accounting_to_date   >  tl.accounting_date  
                and         r.risk_base_record_fk = pp.risk_fk  
                and        pth.base_record_b = 'N'  
                and        ( pth.record_mode_code = 'OFFICIAL'  
                        and (pth.closing_trans_log_fk is null or  
                             pth.closing_trans_log_fk != tl.transaction_log_pk)  
                        or pth.record_mode_code = 'TEMP'  
                        and pth.transaction_log_fk = tl.transaction_log_pk )  
                and        pth.accounting_from_date <= tl.accounting_date  
                and        pth.accounting_to_date   >  tl.accounting_date  
                and        pth.term_base_record_fk = pp.policy_term_fk  
                and   p.policy_pk = pp.policy_fk  
                and        tl.transaction_log_pk  =  pp.transaction_log_fk  
                and   pp.active_premium_b = 'Y'  
                and        pp.rate_period_type_code in ('CS_PERIOD','SR_PERIOD')  
                and        pp.rate_period_to_date > pp.rate_period_from_date  
                and tl.accounting_date <= sysdate   
                and p.policy_cycle_code = 'POLICY'  
                and substr(p.policy_no,1,1) <> 'Q'  
                and tl.transaction_log_pk = (select max(pp.transaction_log_fk)  
                                               from proddw_mart.rmv_policy_premium pp,proddw_mart.rmv_transaction_log tl2  
                                              where pth.term_base_record_fk = pp.policy_term_fk  
                                                and pp.transaction_log_fk = tl2.transaction_log_pk  
                                                and tl2.accounting_date <= sysdate )    
                 and p.policy_type_code in ('LIABCRIME','MIDWIFE')    
                 and pth.accounting_to_date =  to_date('01/01/3000','mm/dd/yyyy') --<<<*******  eliminates duplicates  
                 and p.policy_no = cls.policy_no  
            --     and r.risk_pk = cls.risk_pk  
                 and c.coverage_base_record_fk = cls.parent_coverage_base_record_fk(+)  
                 and  cls.effective_from_date < pth.effective_to_date -- from date less than period end date  
                 and  cls.effective_to_date   > pth.effective_from_date -- to date greater than period start date  
                 and  cls.policy_effective_date   < pth.effective_to_date -- from date less than period end date  
                 and  cls.policy_expiry_date     > pth.effective_from_date -- to date greater than period start date  
           group by pp.policy_fk,  
                    pp.transaction_log_fk,  
                    p.policy_no,  
                    p.policy_type_code,   
                    pp.risk_fk,   
                    r.risk_base_record_fk,   
                    r.entity_fk,  
                    substr(trim(nvl(r.county_code_used_to_rate,pth.issue_state_code)),1,2), -- rating_state_code,  
                    r.county_code_used_to_rate,  
                    pth.issue_state_code,  
                    nvl(r.risk_cls_used_to_rate,pth.peer_groups_code) , --  rating_peer_group_code,  
                    r.risk_cls_used_to_rate,  
                    pth.peer_groups_code,  
                    pth.policy_term_history_pk,   
                    pth.term_base_record_fk,   
                    to_char(pth.effective_from_date,'yyyy'), --term_effective_year,   
                    c.coverage_pk,   
                    c.coverage_base_record_fk,   
                    pc.coverage_code,   
                    c.product_coverage_code,   
                    pc.long_description,   
                    pp.coverage_component_code,  
                    c.effective_from_date,   
                    c.effective_to_date,  
                    cls.coverage_code, -- coverage_class_code,   
                    cls.coverage_long_desc, -- coverage_class_long_desc,   
                    decode(pp.coverage_component_code ,'GROSS',cls.exposure_unit,null),-- exposure_unit,   
                    decode(pp.coverage_component_code ,'GROSS',cls.number_of_patient_day,null), -- number_of_patient_day,   
                    pth.effective_from_date, --term_eff_from_date,   
                    pth.effective_to_date, --, --term_eff_to_date,    
                    pp.premium_amount ;Edited by: BluShadow on 27-Jun-2012 16:12
    added {noformat}{noformat} tags for readability.  PLEASE READ {message:id=9360002} AS PREVIOUSLY REQUESTED!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           &

  • VLD-1119: Unable to generate Multi-table Insert statement for some or all t

    Hi All -
    I have a map in OWB 10.2.0.4 which is ending with following error: -
    VLD-1119: Unable to generate Multi-table Insert statement for some or all targets.*
    Multi-table insert statement cannot be generated for some or all of the targets due to upstream graphs of those targets are not identical on "active operators" such as "join".*
    The map is created with following logic in mind. Let me know if you need more info. Any directions are highly appreciated and many thanks for your inputs in advance: -
    I have two source tables say T1 and T2. There are full outer joined in a joiner and output of this joined is passed to an expression to evaluate values of columns based on
    business logic i.e. If T1 is available than take T1.C1 else take T2.C1 so on.
    A flag is also evaluated in the expression because these intermediate results needs to be joined to third source table say T3 with different condition.
    Based on value taken a flag is being set in the expression which is used in a splitter to get results in three intermediate tables based on flag value evaluated earlier.
    These three intermediate tables are all truncate insert and these are unioned to fill a final target table.
    Visually it is something like this: -
    T1 -- T3 -- JOINER1
    | -->Join1 (FULL OUTER) --> Expression -->SPLITTER -- JOINER2 UNION --> Target Table
    | JOINER3
    T2 --
    Please suggest.

    I verified that their is a limitation with the splitter operator which will not let you generate a multi split having more than 999 columns in all.
    I had to use two separate splitters to achieve what I was trying to do.
    So the situation is now: -
    Siource -> Split -> Split 1 -> Insert into table -> Union1---------Final tableA
    Siource -> Split -> Split 2 -> Insert into table -> Union1

  • Generate Insert Statement Script to Extract Data from Table in Oracle 7i

    Hi all, I have an old Oracle legacy system that is running for over 15 years.Every now and then we need to extract data from this table@ ORacle 7i to be imported back to Oracle 10G.
    My thoughts are to create a script of Insert statements in oracle 7 and that to be deployed back to Oracle 10G.
    I found this scripts in Google and not sure how exactly this works.Any explanation on thsi scripts , would be greatly appreciated.I find this scripst may help to generate a set of insert statements from that table to the latest table at 10G.
    <pre>
    -- Step 1: Create this procedure:
    create or replace Function ExtractData(v_table_name varchar2) return varchar2 As
    b_found boolean:=false;
    v_tempa varchar2(8000);
    v_tempb varchar2(8000);
    v_tempc varchar2(255);
    begin
    for tab_rec in (select table_name from user_tables where table_name=upper(v_table_name))
    loop
    b_found:=true;
    v_tempa:='select ''insert into '||tab_rec.table_name||' (';
    for col_rec in (select * from user_tab_columns
    where
    table_name=tab_rec.table_name
    order by
    column_id)
    loop
    if col_rec.column_id=1 then
    v_tempa:=v_tempa||'''||chr(10)||''';
    else
    v_tempa:=v_tempa||',''||chr(10)||''';
    v_tempb:=v_tempb||',''||chr(10)||''';
    end if;
    v_tempa:=v_tempa||col_rec.column_name;
    if instr(col_rec.data_type,'CHAR') > 0 then
    v_tempc:='''''''''||'||col_rec.column_name||'||''''''''';
    elsif instr(col_rec.data_type,'DATE') > 0 then
    v_tempc:='''to_date(''''''||to_char('||col_rec.column_name||',''mm/dd/yyyy hh24:mi'')||'''''',''''mm/dd/yyyy hh24:mi'''')''';
    else
    v_tempc:=col_rec.column_name;
    end if;
    v_tempb:=v_tempb||'''||decode('||col_rec.column_name||',Null,''Null'','||v_tempc||')||''';
    end loop;
    v_tempa:=v_tempa||') values ('||v_tempb||');'' from '||tab_rec.table_name||';';
    end loop;
    if Not b_found then
    v_tempa:='-- Table '||v_table_name||' not found';
    else
    v_tempa:=v_tempa||chr(10)||'select ''-- commit;'' from dual;';
    end if;
    return v_tempa;
    end;
    show errors
    -- STEP 2: Run the following code to extract the data.
    set head off
    set pages 0
    set trims on
    set lines 2000
    set feed off
    set echo off
    var retline varchar2(4000)
    spool c:\t1.sql
    select 'set echo off' from dual;
    select 'spool c:\recreatedata.sql' from dual;
    select 'select ''-- This data was extracted on ''||to_char(sysdate,''mm/dd/yyyy hh24:mi'') from dual;' from dual;
    -- Repeat the following two lines as many times as tables you want to extract
    exec :retline:=ExtractData('dept');
    print :retline;
    exec :retline:=ExtractData('emp');
    print :retline;
    select 'spool off' from dual;
    spool off
    @c:\t1
    -- STEP3: Run the spooled output c:\recreatedata.sql to recreate data.
    Source:http://www.idevelopment.info/data/Oracle/DBA_tips/PL_SQL/PLSQL_5.shtml
    </pre>

    Thanks Justin.
    I get what you are saying,i really wanted to see the output of the codes, because the furtherst i could get from that code is
    SELECT EXTRACTDATA('MYTABLE') FROM MYTABLE;
    and it generated this:
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    "select 'insert into MYTABLE ('||chr(10)||'DATE1,'||chr(10)||'TIME1,'||chr(10)||'COUNTS) values ('||decode(DATE1,Null,'Null','to_date('''||to_char(DATE1,'mm/dd/yyyy hh24:mi')||''',''mm/dd/yyyy hh24:mi'')')||','||chr(10)||''||decode(TIME1,Null,'Null',TIME1)||','||chr(10)||''||decode(COUNTS,Null,'Null',COUNTS)||');' from MYTABLE;
    select '-- commit;' from dual;"
    I was expecting a string of
    insert into mytable values (19/1/2009,1,1);
    insert into mytable values (19/10/2008,5,10);
    Thanks for the explanation .

  • Use of case  in an insert statement...

    Hi ,
    i have an insert statement in a db packaged procedure which needs a case statement to be used.....
    I want to use the case in a statement like the following...
    insert into x(a,b,c,d,e)
    values(a,b,case b='1' then c_val , d_val , null else null , null , e_val);
    In other words when the b_value (b column) has value '1' (in the example above) then the values for c , d columns of the tables are those passed as parameters to the procedure . On the other hand , when the the b_value (b column) has not value '1' then the values for c , d columns of the tables should be null and the on the e column another value passed as parameter to the procedure....????
    Is the above general syntax of insert correct...????
    Many thanks,
    Simon

    Something like this could do the trick:
    insert into x
                (a, b, c, d, e)
         values (a,
                 b,
                 case
                    when b = '1'
                       then c_val
                 end,
                 case
                    when b = '1'
                       then d_val
                 end,
                 case
                    when b = '1'
                       then null
                    else e_val
                 end
                );

  • Insert statement taking more time

    Hi,
    Insert happening very slow after sqlldr happening in my program. Please find the below workflow of my program.
    1) SQLLDR will be called, it will insert around 4 lakhs records in 'TEMP" table using direct path load.Response time is good here.
    2)After, SQLLDR has finished its job, my procedure will be called, there every cursor statement working fine, but when it comes for "INSERT" statement it takes almost 40 mins.
    3)Insert statement like this
    INSERT /*+ append */ INTO HISTORY_TABLE(<COLUMN1>,<COLUMN2>,..etc) SELECT (<COLUMN1>,.<COLUMN2>...etc) from TEMP_TABLE;
    4)select records from temp table which records were inserted during sqlldr(direct=true),before procedure call.
    5)I check explain plan for the Insert statement it shows conventional path loading
    | Id  | Operation                | Name             | Rows  | Bytes | Cost (%CPU)|
    |   0 | INSERT STATEMENT         |                  |   409K|   143M|  6752   (2)|
    |   1 |  LOAD AS SELECT          | HISTORY_TABLE    |       |       |            |
    |   2 |   TABLE ACCESS FULL      | TEMP_TABLE       |   409K|   143M|  6752   (2)|
    6)Since i have no where condition in my insert statement it go for an full table scan.
    Kindly advice to impove its performance.
    My db is oracle 11g r2(11.2.0.3.0)
    OS-Windows server 2008 r2
    Tkprof for the sesion:
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1     98.10    1860.58     347770      74736    1711253      407077
    Fetch        0      0.00       0.00          0          0          0           0
    total        1     98.10    1860.58     347770      74736    1711253      407077
    Misses in library cache during parse: 0
    Misses in library cache during execute: 1
    Optimizer mode: ALL_ROWS
    Parsing user id: 84     (recursive depth: 1)
    Elapsed times include waiting on following events:
      Event waited on                             Times   Max. Wait  Total Waited
      ----------------------------------------   Waited  ----------  ------------
      db file sequential read                    256304        6.61       1299.01
      direct path read temp                         273        3.47         14.99
      log buffer space                               22        0.75          3.84
      log file switch completion                      7       19.48         30.70
      log file switch (checkpoint incomplete)        16        8.12         17.15
      db file parallel read                           2        0.07          0.09
      log file switch (private strand flush incomplete)
                                                      3        0.32          0.74
      buffer busy waits                               4        0.00          0.00
      undo segment extension                          2        0.00          0.00
    SQL> show parameter optimizer
    NAME                                 TYPE        VALUE
    optimizer_capture_sql_plan_baselines boolean     FALSE
    optimizer_dynamic_sampling           integer     2
    optimizer_features_enable            string      11.2.0.3
    optimizer_index_caching              integer     0
    optimizer_index_cost_adj             integer     100
    optimizer_mode                       string      ALL_ROWS
    optimizer_secure_view_merging        boolean     TRUE
    optimizer_use_invisible_indexes      boolean     FALSE
    optimizer_use_pending_statistics     boolean     FALSE
    optimizer_use_sql_plan_baselines     boolean     TRUE
    SQL> show parameter db_file_multi
    NAME                                 TYPE        VALUE
    db_file_multiblock_read_count        integer     128
    SQL> show parameter db_block_size
    NAME                                 TYPE        VALUE
    db_block_size                        integer     8192
    SQL> show parameter cursor_sharing
    NAME                                 TYPE        VALUE
    cursor_sharing                       string      EXACT
    SQL>
    SQL> l
      1  select
      2* sname,pname,pval1,pval2 from sys.aux_stats$
    SQL> /
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_INFO        STATUS                          COMPLETED
    SYSSTATS_INFO        DSTART                          11-03-2011 06:38
    SYSSTATS_INFO        DSTOP                           11-03-2011 06:38
    SYSSTATS_INFO        FLAGS                         1
    SYSSTATS_MAIN        CPUSPEEDNW           1720.20725
    SYSSTATS_MAIN        IOSEEKTIM                    10
    SYSSTATS_MAIN        IOTFRSPEED                 4096
    SYSSTATS_MAIN        SREADTIM
    SYSSTATS_MAIN        MREADTIM
    SYSSTATS_MAIN        CPUSPEED
    SYSSTATS_MAIN        MBRC
    SNAME                PNAME                     PVAL1 PVAL2
    SYSSTATS_MAIN        MAXTHR
    SYSSTATS_MAIN        SLAVETHR
    Thanks
    Faiz

    Hi,
    Below i apend the both table definitions. Please check
    CREATE TABLE HISTORY_TABLE
       ( DAT_TIM VARCHAR2(19 BYTE),
    REC_TYP VARCHAR2(2 BYTE),
    AUTH_PPD VARCHAR2(4 BYTE),
    LN_TERM VARCHAR2(4 BYTE),
    FIID_TERM VARCHAR2(4 BYTE),
    TERM_ID VARCHAR2(16 BYTE),
    LN_ISSUER VARCHAR2(4 BYTE),
    FIID_ISSUER VARCHAR2(20 BYTE),
    PAN VARCHAR2(19 BYTE),
    MBR_NUM VARCHAR2(3 BYTE),
    BRCH_ID VARCHAR2(4 BYTE),
    REGN_ID VARCHAR2(4 BYTE),
    USER_FLD1X VARCHAR2(2 BYTE),
    TYP_CDE VARCHAR2(2 BYTE),
    TYP VARCHAR2(4 BYTE),
    RTE_STAT VARCHAR2(2 BYTE),
    ORIGINATOR CHAR(1 BYTE),
    RESPONDER CHAR(1 BYTE),
    ENTRY_TIM VARCHAR2(19 BYTE),
    EXIT_TIM VARCHAR2(19 BYTE),
    RE_ENTRY_TIM VARCHAR2(19 BYTE),
    TRAN_DAT VARCHAR2(6 BYTE),
    TRAN_TIM VARCHAR2(8 BYTE),
    POST_DAT VARCHAR2(6 BYTE),
    ACQ_ICHG_SETL_DAT VARCHAR2(6 BYTE),
    ISS_ICHG_SETL_DAT VARCHAR2(6 BYTE),
    SEQ_NUM VARCHAR2(12 BYTE),
    TERM_TYP VARCHAR2(2 BYTE),
    TIM_OFST VARCHAR2(5 BYTE),
    ACQ_INST_ID_NUM VARCHAR2(11 BYTE),
    RCV_INST_ID_NUM VARCHAR2(11 BYTE),
    T_CDE VARCHAR2(2 BYTE),
    T_FROM VARCHAR2(2 BYTE),
    T_TO VARCHAR2(2 BYTE),
    FROM_ACCT VARCHAR2(24 BYTE),
    USER_FLD1 VARCHAR2(1 BYTE),
    TO_ACCT VARCHAR2(19 BYTE),
    MULT_ACCT VARCHAR2(1 BYTE),
    AMT1 VARCHAR2(19 BYTE),
    AMT2 VARCHAR2(19 BYTE),
    AMT3 VARCHAR2(19 BYTE),
    DEP_BAL_CR VARCHAR2(10 BYTE),
    DEP_TYP VARCHAR2(1 BYTE),
    RESP_BYTE1 VARCHAR2(3 BYTE),
    RESP_BYTE2 VARCHAR2(3 BYTE),
    TERM_NAME_LOC VARCHAR2(25 BYTE),
    TERM_OWNER_NAME VARCHAR2(40 BYTE),
    TERM_CITY VARCHAR2(13 BYTE),
    TERM_ST_X VARCHAR2(3 BYTE),
    TERM_CNTRY_X VARCHAR2(2 BYTE),
    OSEQ_NUM VARCHAR2(12 BYTE),
    OTRAN_DAT VARCHAR2(4 BYTE),
    OTRAN_TIM VARCHAR2(8 BYTE),
    B24_POST_DAT VARCHAR2(4 BYTE),
    ORIG_CRNCY_CDE VARCHAR2(3 BYTE),
    AUTH_CRNCY_CDE VARCHAR2(3 BYTE),
    AUTH_CONV_RATE VARCHAR2(8 BYTE),
    SETL_CRNCY_CDE VARCHAR2(3 BYTE),
    SETL_CONV_RATE VARCHAR2(8 BYTE),
    CONV_DAT_TIM VARCHAR2(19 BYTE),
    RVSL_RSN VARCHAR2(2 BYTE),
    PIN_OFST VARCHAR2(16 BYTE),
    SHRG_GRP VARCHAR2(1 BYTE),
    DEST_ORDER VARCHAR2(1 BYTE),
    AUTH_ID_RESP VARCHAR2(6 BYTE),
    IMP_IND VARCHAR2(1 BYTE),
    AVAIL_IMP VARCHAR2(2 BYTE),
    LEDG_IMP VARCHAR2(2 BYTE),
    HLD_AMT_IMP VARCHAR2(2 BYTE),
    CAF_REFR_IND VARCHAR2(1 BYTE),
    USER_FLD3 VARCHAR2(1 BYTE),
    DEP_SETL_IMP_FLG VARCHAR2(1 BYTE),
    ADJ_SETL_IMP_FLG VARCHAR2(1 BYTE),
    PBF1 VARCHAR2(1 BYTE),
    PBF2 VARCHAR2(1 BYTE),
    PBF3 VARCHAR2(1 BYTE),
    PBF4 VARCHAR2(1 BYTE),
    USER_FLD4 VARCHAR2(16 BYTE),
    FRWD_INST_ID_NUM VARCHAR2(11 BYTE),
    CRD_ACCPT_ID_NUM VARCHAR2(40 BYTE),
    CRD_ISS_ID_NUM VARCHAR2(11 BYTE),
    USER_FLD6 VARCHAR2(1 BYTE),
    FILE_NAME VARCHAR2(100 BYTE),
    ERR_FLAG CHAR(1 BYTE),
    AMT2_ACTUAL VARCHAR2(20 BYTE),
    ID_COL NUMBER(23,0),
    RVSL_FLAG CHAR(1 BYTE),
    SWRE_ID VARCHAR2(20 BYTE),
    GAC_ID VARCHAR2(20 BYTE),
    INS_USER NUMBER(5,0),
    PART_CODE NUMBER(3,0),
    ISS_RECON NUMBER(1,0),
    ACQ_RECON NUMBER(1,0),
    CROSS_BRANCH CHAR(1 BYTE),
    CONSORTIUM_CODE NUMBER(3,0),
    FROM_HOST VARCHAR2(1 BYTE),
    FROM_HOST_ACQ VARCHAR2(1 BYTE),
    AUDIT_NUM VARCHAR2(12 BYTE),
    CAPTURE_CODE VARCHAR2(1 BYTE),
    RESP_DAT_TIME VARCHAR2(19 BYTE),
    PAN_SEQ_NUM NUMBER(1,0),
    SERVICE_CODE VARCHAR2(3 BYTE),
    ISS_BIN VARCHAR2(6 BYTE),
    POS_DATA VARCHAR2(12 BYTE),
    SECURITY_DATA VARCHAR2(8 BYTE),
    CASHBACK_AMT VARCHAR2(15 BYTE),
    REPLACEMENT_AMOUNT VARCHAR2(15 BYTE),
    SETTL_AMT VARCHAR2(16 BYTE),
    TRAN_FEE VARCHAR2(15 BYTE),
    SETL_FEE VARCHAR2(15 BYTE),
    MERC_CODE VARCHAR2(4 BYTE),
    NTWORK_DATA VARCHAR2(12 BYTE),
    PRIVATE_DATA_C_100 VARCHAR2(100 BYTE),
    PAYMENT_INFO VARCHAR2(50 BYTE),
    SURCHARGE_FEE VARCHAR2(15 BYTE),
    SURC_BILL_AMT VARCHAR2(19 BYTE),
    PROCESSING_CODE VARCHAR2(7 BYTE),
    FRWD_CNTRY_CODE VARCHAR2(3 BYTE),
    NTWORK_CODE VARCHAR2(2 BYTE),
    FUNCTION_CODE VARCHAR2(3 BYTE),
    REASON_CODE VARCHAR2(4 BYTE),
    FEES VARCHAR2(10 BYTE),
    SUR_CHARGE VARCHAR2(10 BYTE),
    MESSAGE_TYPE VARCHAR2(4 BYTE),
    APPROVE_STATUS VARCHAR2(10 BYTE),
    CPS_TRAN_ID VARCHAR2(20 BYTE),
    BANKTYPE_CODE VARCHAR2(5 BYTE),
    RRB_BIN_CODE VARCHAR2(7 BYTE),
    T_TYPE VARCHAR2(5 BYTE),
    FEE_CRNCY VARCHAR2(25 BYTE),
    FEE_INDICATOR VARCHAR2(1 BYTE),
    FEE_TYPE VARCHAR2(84 BYTE),
    CREDIT_BANK_CODE VARCHAR2(11 BYTE),
    CREDIT_BR_CODE VARCHAR2(8 BYTE),
    DEBIT_BANK_CODE VARCHAR2(11 BYTE),
    ACTION_CODE VARCHAR2(3 BYTE),
    ZEROS VARCHAR2(6 BYTE),
    OTRACE_AUDIT_NO VARCHAR2(6 BYTE),
    OFEE_TYPE1 VARCHAR2(2 BYTE),
    OFEE_CRNCY1 VARCHAR2(3 BYTE),
    OFEE_AMNT VARCHAR2(16 BYTE),
    OFEE_INDICATOR VARCHAR2(1 BYTE),
    SPACES VARCHAR2(2 BYTE),
    ACQ_BANK_CODE VARCHAR2(6 BYTE),
    CASHAT_POS VARCHAR2(16 BYTE),
    LTS_STATUS VARCHAR2(30 BYTE),
    APP_CODE VARCHAR2(6 BYTE),
    CARD_ACCEPTID VARCHAR2(15 BYTE),
    RESPONSE_CODE VARCHAR2(15 BYTE),
    RES_RECVD_HOST VARCHAR2(1 BYTE),
    DEVICE_ID VARCHAR2(16 BYTE),
    RECORD_TYPE VARCHAR2(1 BYTE),
    RRT_DEBIT_BANK_CODE VARCHAR2(11 BYTE),
    ORIG_TYP VARCHAR2(6 BYTE),
    DEVICE_TYPE VARCHAR2(3 BYTE),
    ORGTRAN_CODE VARCHAR2(4 BYTE),
    BILL_CRNCY VARCHAR2(3 BYTE),
    BILL_AMNT VARCHAR2(19 BYTE),
    OTRAN_AMNT VARCHAR2(19 BYTE),
    INS_DATE DATE,
    RECON_FLAG VARCHAR2(2 BYTE),
    TRAN_ID VARCHAR2(25 BYTE)
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
    NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_TST ;
      CREATE INDEX CMS_ALL_SWT_DATA_INDEX ON HISTORY_TABLE (TYP, DEVICE_ID, FROM_ACCT, AMT1, NTWORK_CODE, ISS_BIN, POST_DAT, RESP_BYTE1, DEVICE_TYPE, T_CDE, PRIVATE_DATA_C_100, REASON_CODE)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX CMS_ALL_SWT_DATA_INDEX1 ON HISTORY_TABLE (TO_NUMBER(AMT1))
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX CMS_ALL_SWT_DATA_INDEX_FN ON HISTORY_TABLE (SUBSTR(DEVICE_ID,4))
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX CMS_ALL_SWT_DATA_INDEX_IDX ON HISTORY_TABLE (T_CDE, PRIVATE_DATA_C_100, ISS_BIN)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX CMS_ALL_SWT_DATA_INDEX_TST ON HISTORY_TABLE (TYP, POST_DAT, RESP_BYTE1, DEVICE_TYPE, AMT1)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX CMS_ALL_SWT_DATA_INDEX_TST1 ON HISTORY_TABLE (DEVICE_TYPE, TO_NUMBER(AMT1))
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX IDX_ALLSWT_PAN ON HISTORY_TABLE (PAN)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
    Table Definition for TEMP Table:
    CREATE TABLE REC_TLF_TEMP
       ( DAT_TIM VARCHAR2(19 BYTE),
    REC_TYP VARCHAR2(2 BYTE),
    AUTH_PPD VARCHAR2(4 BYTE),
    LN_TERM VARCHAR2(4 BYTE),
    FIID_TERM VARCHAR2(4 BYTE),
    TERM_ID VARCHAR2(16 BYTE),
    LN_ISSUER VARCHAR2(4 BYTE),
    FIID_ISSUER VARCHAR2(20 BYTE),
    PAN VARCHAR2(19 BYTE),
    MBR_NUM VARCHAR2(3 BYTE),
    BRCH_ID VARCHAR2(4 BYTE),
    REGN_ID VARCHAR2(4 BYTE),
    USER_FLD1X VARCHAR2(2 BYTE),
    TYP_CDE VARCHAR2(2 BYTE),
    TYP VARCHAR2(4 BYTE),
    RTE_STAT VARCHAR2(2 BYTE),
    ORIGINATOR CHAR(1 BYTE),
    RESPONDER CHAR(1 BYTE),
    ENTRY_TIM VARCHAR2(19 BYTE),
    EXIT_TIM VARCHAR2(19 BYTE),
    RE_ENTRY_TIM VARCHAR2(19 BYTE),
    TRAN_DAT VARCHAR2(6 BYTE),
    TRAN_TIM VARCHAR2(8 BYTE),
    POST_DAT VARCHAR2(6 BYTE),
    ACQ_ICHG_SETL_DAT VARCHAR2(6 BYTE),
    ISS_ICHG_SETL_DAT VARCHAR2(6 BYTE),
    SEQ_NUM VARCHAR2(12 BYTE),
    TERM_TYP VARCHAR2(2 BYTE),
    TIM_OFST VARCHAR2(5 BYTE),
    ACQ_INST_ID_NUM VARCHAR2(11 BYTE),
    RCV_INST_ID_NUM VARCHAR2(11 BYTE),
    T_CDE VARCHAR2(2 BYTE),
    T_FROM VARCHAR2(2 BYTE),
    T_TO VARCHAR2(2 BYTE),
    FROM_ACCT VARCHAR2(24 BYTE),
    USER_FLD1 VARCHAR2(1 BYTE),
    TO_ACCT VARCHAR2(19 BYTE),
    MULT_ACCT VARCHAR2(1 BYTE),
    AMT1 VARCHAR2(19 BYTE),
    AMT2 VARCHAR2(19 BYTE),
    AMT3 VARCHAR2(19 BYTE),
    DEP_BAL_CR VARCHAR2(10 BYTE),
    DEP_TYP VARCHAR2(1 BYTE),
    RESP_BYTE1 VARCHAR2(3 BYTE),
    RESP_BYTE2 VARCHAR2(3 BYTE),
    TERM_NAME_LOC VARCHAR2(25 BYTE),
    TERM_OWNER_NAME VARCHAR2(40 BYTE),
    TERM_CITY VARCHAR2(13 BYTE),
    TERM_ST_X VARCHAR2(3 BYTE),
    TERM_CNTRY_X VARCHAR2(2 BYTE),
    OSEQ_NUM VARCHAR2(12 BYTE),
    OTRAN_DAT VARCHAR2(4 BYTE),
    OTRAN_TIM VARCHAR2(8 BYTE),
    B24_POST_DAT VARCHAR2(4 BYTE),
    ORIG_CRNCY_CDE VARCHAR2(3 BYTE),
    AUTH_CRNCY_CDE VARCHAR2(3 BYTE),
    AUTH_CONV_RATE VARCHAR2(8 BYTE),
    SETL_CRNCY_CDE VARCHAR2(3 BYTE),
    SETL_CONV_RATE VARCHAR2(8 BYTE),
    CONV_DAT_TIM VARCHAR2(19 BYTE),
    RVSL_RSN VARCHAR2(2 BYTE),
    PIN_OFST VARCHAR2(16 BYTE),
    SHRG_GRP VARCHAR2(1 BYTE),
    DEST_ORDER VARCHAR2(1 BYTE),
    AUTH_ID_RESP VARCHAR2(6 BYTE),
    IMP_IND VARCHAR2(1 BYTE),
    AVAIL_IMP VARCHAR2(2 BYTE),
    LEDG_IMP VARCHAR2(2 BYTE),
    HLD_AMT_IMP VARCHAR2(2 BYTE),
    CAF_REFR_IND VARCHAR2(1 BYTE),
    USER_FLD3 VARCHAR2(1 BYTE),
    DEP_SETL_IMP_FLG VARCHAR2(1 BYTE),
    ADJ_SETL_IMP_FLG VARCHAR2(1 BYTE),
    PBF1 VARCHAR2(1 BYTE),
    PBF2 VARCHAR2(1 BYTE),
    PBF3 VARCHAR2(1 BYTE),
    PBF4 VARCHAR2(1 BYTE),
    USER_FLD4 VARCHAR2(16 BYTE),
    FRWD_INST_ID_NUM VARCHAR2(11 BYTE),
    CRD_ACCPT_ID_NUM VARCHAR2(40 BYTE),
    CRD_ISS_ID_NUM VARCHAR2(11 BYTE),
    USER_FLD6 VARCHAR2(1 BYTE),
    FILE_NAME VARCHAR2(100 BYTE),
    ERR_FLAG CHAR(1 BYTE),
    AMT2_ACTUAL VARCHAR2(20 BYTE),
    ID_COL NUMBER(23,0),
    RVSL_FLAG CHAR(1 BYTE),
    SWRE_ID VARCHAR2(20 BYTE),
    GAC_ID VARCHAR2(20 BYTE),
    INS_USER NUMBER(5,0),
    PART_CODE NUMBER(3,0),
    ISS_RECON NUMBER(1,0),
    ACQ_RECON NUMBER(1,0),
    CROSS_BRANCH CHAR(1 BYTE),
    CONSORTIUM_CODE NUMBER(3,0),
    FROM_HOST VARCHAR2(1 BYTE),
    FROM_HOST_ACQ VARCHAR2(1 BYTE),
    AUDIT_NUM VARCHAR2(12 BYTE),
    CAPTURE_CODE VARCHAR2(1 BYTE),
    RESP_DAT_TIME VARCHAR2(19 BYTE),
    PAN_SEQ_NUM NUMBER(1,0),
    SERVICE_CODE VARCHAR2(3 BYTE),
    ISS_BIN VARCHAR2(6 BYTE),
    POS_DATA VARCHAR2(12 BYTE),
    SECURITY_DATA VARCHAR2(8 BYTE),
    CASHBACK_AMT VARCHAR2(15 BYTE),
    REPLACEMENT_AMOUNT VARCHAR2(15 BYTE),
    SETTL_AMT VARCHAR2(16 BYTE),
    TRAN_FEE VARCHAR2(15 BYTE),
    SETL_FEE VARCHAR2(15 BYTE),
    MERC_CODE VARCHAR2(4 BYTE),
    NTWORK_DATA VARCHAR2(12 BYTE),
    PRIVATE_DATA_C_100 VARCHAR2(100 BYTE),
    PAYMENT_INFO VARCHAR2(50 BYTE),
    SURCHARGE_FEE VARCHAR2(15 BYTE),
    SURC_BILL_AMT VARCHAR2(19 BYTE),
    PROCESSING_CODE VARCHAR2(7 BYTE),
    FRWD_CNTRY_CODE VARCHAR2(3 BYTE),
    NTWORK_CODE VARCHAR2(2 BYTE),
    FUNCTION_CODE VARCHAR2(3 BYTE),
    REASON_CODE VARCHAR2(4 BYTE),
    FEES VARCHAR2(10 BYTE),
    SUR_CHARGE VARCHAR2(10 BYTE),
    MESSAGE_TYPE VARCHAR2(4 BYTE),
    APPROVE_STATUS VARCHAR2(10 BYTE),
    CPS_TRAN_ID VARCHAR2(20 BYTE),
    BANKTYPE_CODE VARCHAR2(5 BYTE),
    RRB_BIN_CODE VARCHAR2(7 BYTE),
    T_TYPE VARCHAR2(5 BYTE),
    FEE_CRNCY VARCHAR2(25 BYTE),
    FEE_INDICATOR VARCHAR2(1 BYTE),
    FEE_TYPE VARCHAR2(84 BYTE),
    CREDIT_BANK_CODE VARCHAR2(11 BYTE),
    CREDIT_BR_CODE VARCHAR2(8 BYTE),
    DEBIT_BANK_CODE VARCHAR2(11 BYTE),
    ACTION_CODE VARCHAR2(3 BYTE),
    ZEROS VARCHAR2(6 BYTE),
    OTRACE_AUDIT_NO VARCHAR2(6 BYTE),
    OFEE_TYPE1 VARCHAR2(2 BYTE),
    OFEE_CRNCY1 VARCHAR2(3 BYTE),
    OFEE_AMNT VARCHAR2(16 BYTE),
    OFEE_INDICATOR VARCHAR2(1 BYTE),
    SPACES VARCHAR2(2 BYTE),
    ACQ_BANK_CODE VARCHAR2(6 BYTE),
    CASHAT_POS VARCHAR2(16 BYTE),
    LTS_STATUS VARCHAR2(30 BYTE),
    APP_CODE VARCHAR2(6 BYTE),
    CARD_ACCEPTID VARCHAR2(15 BYTE),
    RESPONSE_CODE VARCHAR2(15 BYTE),
    RES_RECVD_HOST VARCHAR2(1 BYTE),
    DEVICE_ID VARCHAR2(16 BYTE),
    RECORD_TYPE VARCHAR2(1 BYTE),
    RRT_DEBIT_BANK_CODE VARCHAR2(11 BYTE),
    ORIG_TYP VARCHAR2(6 BYTE),
    DEVICE_TYPE VARCHAR2(3 BYTE),
    ORGTRAN_CODE VARCHAR2(4 BYTE),
    BILL_CRNCY VARCHAR2(3 BYTE),
    TRAN_ID VARCHAR2(25 BYTE),
    RECON_FLAG VARCHAR2(2 BYTE),
    BILL_AMNT VARCHAR2(19 BYTE),
    OTRAN_AMNT VARCHAR2(19 BYTE),
    INS_DATE DATE
       ) SEGMENT CREATION IMMEDIATE
      PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
    NOCOMPRESS LOGGING
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_TST ;
      CREATE INDEX CMS_TLF_TEMP_INDEX3 ON REC_TLF_TEMP (TO_NUMBER(PAN))
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX CMS_TLF_TEMP_INDEX4 ON REC_TLF_TEMP (TO_NUMBER(AUDIT_NUM))
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX IDX_REC_TEMP_CDE ON REC_TLF_TEMP (T_CDE)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_TST ;
      CREATE INDEX IDX_TLF_DEVICEID ON REC_TLF_TEMP (DEVICE_ID)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX IDX_TLF_PRIVATE ON REC_TLF_TEMP (PRIVATE_DATA_C_100)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_TST ;
      CREATE INDEX IDX_TLF_TEMP_BYTE1 ON REC_TLF_TEMP (PRIVATE_DATA_C_100, ISS_BIN, NTWORK_CODE)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_TST ;
      CREATE INDEX IDX_TLF_TEMP_TST ON REC_TLF_TEMP (RESP_BYTE1)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX IND_TLFTEMP_RVSLFLG ON REC_TLF_TEMP (RVSL_FLAG)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX IND_TLFTEMP_TRMID_TCD ON REC_TLF_TEMP (TERM_ID, T_CDE)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX IND_TLFTMP_NWCDE ON REC_TLF_TEMP (NTWORK_CODE)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX REC_TLF_TEMP_INDEX ON REC_TLF_TEMP (PAN, SEQ_NUM, AUDIT_NUM)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
      CREATE INDEX TEMPREVLSET ON REC_TLF_TEMP (SEQ_NUM, TYP, REC_TYP, PAN)
      PCTFREE 10 INITRANS 2 MAXTRANS 255 COMPUTE STATISTICS
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
      BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
      TABLESPACE TBS_IDX ;
    It shows that no triggers for both the tables.
    Confirm that no where condition being used in the SQL.
    Thanks
    Faiz

  • Mapping multi-segment IDOC to multiple JDBC INSERT statements

    Hi Everyone,
    This is probably going to be easy for the experienced PI developers out there but I'm just starting out in this technology. We are running PI 1.11 and the scenario is as follows. We have a bespoke IDOC message type ZSTOCK which can contain 1-many segments with the following field content:
    WERKS
    MATNR
    VBELN
    ACT_LABST
    AVL_LABST
    For each segment in the source IDOC, I want to generate an INSERT statement to insert a row in an SQL table via the JDBC adapter with the following columns:
    Plant
    Material
    SalesOrd
    ActStock
    AvlStock
    Basically, each field on the source IDOC segment maps directly onto the target column of the SQL table. The problem is, on a multi-segment IDOC only the first segment is generating a row in the SQL table. I've seen a number of threads on this forum that seem to tackle the same issue but the solution is either missing or unclear. I think the solution lies somwhere in the occurrences of the STATEMENT node in my target message type and perhaps specific definitions in the message mapping. Can anyone help solve this mystery?
    Thanks,
    Gary

    Hi Gary
    If you created a data type, try to change occurrence of STATEMENT node to 0..unbounded or 1..unbounded.
    In the message mapping, map the target STATEMENT node with the source 1-many segment.
    You can find [here|http://help.sap.com/saphelp_nw70/helpdata/en/4d/8c103e05df2e4b95cbcc68fed61705/content.htm] more informations about the JDBC structure
    Regards,
    Giuseppe

  • Nds Insert statement little problem

    DB version XE 10g
    Hello
    I have little problem with my insert statement.
    In my code, are many examples, but plz focus on V2 and V3 part.
    As you can see V2 and V3 are not working
    I get following errors
    V2
    Error report:
    ORA-00984: column not allowed here
    ORA-06512: AT line 28
    00984. 00000 - "column not allowed here"
    V3
    Error report:
    ORA-00917: missing comma
    ORA-06512: AT line 33
    00917. 00000 - "missing comma"
    I really have no idea, why i'm getting these errors...
    DROP TABLE FILMYARNOLD;
    CREATE TABLE FILMYARNOLD
        FIL_ID VARCHAR2 (329),
        FIL_NAME VARCHAR2 (592),
        FIL_YEAR VARCHAR2 (294),
        FIL_ACTOR VARCHAR2 (392),
        FIL_TEXTT VARCHAR2 (2596)
    SET SERVEROUTPUT ON
    DECLARE
      TYPE FIL_TABLE IS TABLE OF VARCHAR2 (256);
      vfilmiczki FIL_TABLE := fil_table();
      statement VARCHAR2 (2048);
    BEGIN
    vfilmiczki.EXTEND;
    vfilmiczki(1) := '77804';
    vfilmiczki.EXTEND;
    vfilmiczki(2) := 'Predator';
    vfilmiczki.EXTEND;
    vfilmiczki(3) := '1984';
    vfilmiczki.EXTEND;
    vfilmiczki(4) := 'Arnold';
    vfilmiczki.EXTEND;
    vfilmiczki(5) := 'get to the choppa';
    /*statement := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT) VALUES ( ';
    statement := statement|| '''chlip'',''lol'',''lol'',''chlip''';--
    statement := statement||',''hmm'')';*/
    -------V1------------working-----------------
    --statement := 'INSERT INTO FILMYARNOLD (FIL_ID) VALUES ( ';
    --statement := statement||vfilmiczki(1)||' )';
    --EXECUTE IMMEDIATE statement;
    --------V2-------------------- not working -----------------------------------------
    --statement := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME) VALUES ( ';
    --statement := statement||vfilmiczki(1)||','||vfilmiczki(2)||' )';
    --EXECUTE IMMEDIATE statement;
    ----V3------------ not working ------------
    statement := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT) VALUES ( ';
    statement := statement||vfilmiczki(1)||','||vfilmiczki(2)||','||vfilmiczki(3)||','||vfilmiczki(4)||','||vfilmiczki(5)||' )';
    EXECUTE IMMEDIATE statement;
    /* statement := 'INSERT INTO FILMYARNOLD VALUES (:jeden, :dwa, :trzy, :cztery, :piec)';
    EXECUTE IMMEDIATE statement
      USING vfilmiczki(1)
      ,     vfilmiczki(2)
      ,     vfilmiczki(3)
      ,     vfilmiczki(4)
      ,     vfilmiczki(5); */
      statement := 'INSERT INTO FILMYARNOLD VALUES ('; --(:jeden, :dwa, :trzy, :cztery, :piec)';
        FOR i IN 1..vfilmiczki.COUNT
        LOOP
            IF i = vfilmiczki.LAST THEN
                statement := statement||vfilmiczki(i)||' )';
            ELSE
            statement := statement||vfilmiczki(i)||', ';
          END IF;
            --DBMS_OUTPUT.PUT_LINE (vfilmiczki(i));
        END LOOP;
        EXECUTE IMMEDIATE statement;
        --INSERT INTO FILMYARNOLD
        --VALUES (vfilmiczki(vfilmiczki.FIRST),vfilmiczki(2),vfilmiczki(3),
                --vfilmiczki(4), vfilmiczki(5));
        --DBMS_OUTPUT.PUT_LINE ('*****************');
        --DBMS_OUTPUT.PUT_LINE (vfilmiczki((vfilmiczki.LAST)));
    END;
    /Im waiting for your replys
    greetings

    Hi,
    change V2 to:
    STATEMENT := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME) VALUES ( ';
    STATEMENT := STATEMENT||VFILMICZKI(1)||','''||VFILMICZKI(2)||''' )';
    EXECUTE IMMEDIATE statement;and V3 to:
    ----V3------------ not working ------------
    STATEMENT := 'INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT) VALUES ( ';
    STATEMENT := STATEMENT||VFILMICZKI(1)||','''||VFILMICZKI(2)||''','||VFILMICZKI(3)
                 ||','''||VFILMICZKI(4)||''','''||VFILMICZKI(5)||''' )';
    EXECUTE IMMEDIATE statement;EXECUTE IMMEDIATE statement;One general remark: INSERT can be used directly in PL/SQL, you don't need to bother with dynamic SQL,
    and the direct SQL will be probably more efficient than dynamic SQL.
    Try this:
    SET SERVEROUTPUT ON
    DECLARE
      TYPE FIL_TABLE IS TABLE OF VARCHAR2 (256);
      vfilmiczki FIL_TABLE := fil_table();
      statement VARCHAR2 (2048);
    BEGIN
    vfilmiczki.EXTEND;
    vfilmiczki(1) := '77804';
    vfilmiczki.EXTEND;
    vfilmiczki(2) := 'Predator';
    vfilmiczki.EXTEND;
    vfilmiczki(3) := '1984';
    vfilmiczki.EXTEND;
    vfilmiczki(4) := 'Arnold';
    vfilmiczki.EXTEND;
    vfilmiczki(5) := 'get to the choppa';
    -------V1------------working-----------------
    INSERT INTO  FILMYARNOLD (FIL_ID) VALUES ( VFILMICZKI(1) );
    --------V2-------------------- not working -----------------------------------------
    INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME) VALUES ( VFILMICZKI(1),VFILMICZKI(2));
    ----V3------------ not working ------------
    INSERT INTO FILMYARNOLD (FIL_ID, FIL_NAME, FIL_YEAR, FIL_ACTOR, FIL_TEXTT)
    VALUES ( VFILMICZKI(1), VFILMICZKI(2), VFILMICZKI(3), VFILMICZKI(4), VFILMICZKI(5));
    END;
    /

  • Dynamic insert statement

    Hi all
    I had problem in insert statement.
    I know the column of the table, tablename and the value to be insert.
    My code:
    Data: column(20) type c.   -
    >refer to the tablecolumn
    Data: tablename(20) type c.  -
    >refer to table name
    Data: value(20) type c.          -
    >value to be insert to the column in the table
    column = 'Admino'.
    tablename = 'Student'.
    value = '123456'.
    <b>insert <column> into <tablename> values <value>.</b>
    i know there something wrong with my insert statement. How to do it in abap insert code where i can put in all the parameter in the insert statement.
    Anycode or sample to show. Many thank.

    From f1 help....
    EXTRACT
    Basic form
    EXTRACT fg.
    Effect
    Writes all fields of the field group fg (FIELD-GROUPS) as an entry in asequential dataset. If you have defined a field group HEADER,its fields precede each entry as a sort key. Afterwards, you canuse SORT and LOOP ... ENDLOOP to sort or process the datasetrespectively. No further EXTRACT statements are possible afterthis.
    Notes
    General:
    As soon as you have extracted a dataset using EXTRACT, you canno longer extend the field group using INSERT. In particular, you cannot change the HEADERfield group at all after the first EXTRACT (regardless of thefield group to which it applied).
    Large extract datasets are not stored in main memory. Instead, theyare kept in an external auxiliary file. You can set the directory inwhich this file is created using the SAP profile parameterDIR_EXTRACT. The default directory is the SAP data directory(SAP profile parameter DIR_DATA).
    Notes
    Runtime errors:
    EXTRACT_AFTER_SORT/LOOP: EXTRACT after SORT, orLOOP. EXTRACT_BUFFER_NO_ROLL: Unable to create the required main
    EXTRACT_FIELD_TOO_LARGE: Occupied length of a field is toolarge.
    EXTRACT_HEADER_NOT_UNIQUE: Field group HEADER wasmodified after an EXTRACT statement.
    EXTRACT_OPEN_EXTRACTFILE_OPEN:
    Error opening the external extract dataset file.
    EXTRACT_RESOURCEHANDLER_FAILED: Error deleting the externalextract dataset file.
    EXTRACT_TOO_LARGE: Total length of the entry for extraction(including HEADER fields) is too large.
    Additional help
    Filling anExtract with Data
    Extracts
    Since internal tables have fixed line structures, they are not suited to handle data sets with varying structures. Instead, you can use extract datasets for this purpose.
    An extract is a sequential dataset in the memory area of the program. You can only address the entries in the dataset within a special loop. The index or key access permitted with internal tables is not allowed. You may only create one extract in any ABAP program. The size of an extract dataset is, in principle, unlimited. Extracts larger than 500KB are stored in operating system files. The practical size of an extract is up to 2GB, as long as there is enough space in the filesystem.
    An extract dataset consists of a sequence of records of a pre-defined structure. However, the structure need not be identical for all records. In one extract dataset, you can store records of different length and structure one after the other. You need not create an individual dataset for each different structure you want to store. This fact reduces the maintenance effort considerably.
    In contrast to internal tables, the system partly compresses extract datasets when storing them. This reduces the storage space required. In addition, you need not specify the structure of an extract dataset at the beginning of the program, but you can determine it dynamically during the flow of the program.
    You can use control level processing with extracts just as you can with internal tables. The internal administration for extract datasets is optimized so that it is quicker to use an extract for control level processing than an internal table.
    Procedure for creating an extract:
    Define the record types that you want to use in your extract by declaring them as field groups. The structure is defined by including fields in each field group.
    Defining an Extract
    Fill the extract line by line by extracting the required data.
    Filling an Extract with Data
    Once you have filled the extract, you can sort it and process it in a loop. At this stage, you can no longer change the contents of the extract.
    Processing Extracts
    INSERT Statement
    The INSERT statement is used to insert values into a single database table.
    <insert statement> ::= INSERT INTO <table name> <insert column list> <insert source>.
    <insert source> ::= VALUES '(' <value> ( ',' <value> )* ')'
    | <query specification>.
    <value> ::= <value expression>
    | <dynamic parameter specification>
    | NULL.
    <insert column list> ::= '(' <column name> ( ',' <column name> )* ')'.
    In Open SQL the <insert column list> is not optional.
    You cannot specify string literals as values for CLOB columns. Hex literals are not supported in Open SQL.
    Examples
    INSERT INTO employees (employee_id, employee_name)
    VALUES (4711, 'John Smith')
    Inserting Values. A new row is inserted into the table employees with the values 4711 and 'John Smith' for the columns employee_id and employee_name respectively.
    INSERT INTO well_paid_employees (employee_id, salary)
    SELECT employee_id, salary
    FROM employees
    WHERE salary > ?
    Inserting the Result of a Query. The employee_idand the salaryof all employees from table employeeswith a salary exceeding a certain value are inserted into the table well_paid_employees.
    Please reward points if helpful.

Maybe you are looking for

  • Gathering physical memory for SQL 2005..SQL 2014

    Hi All, I'm trying to write a query to gather physical memory across my SQL servers (from SQL 2005 to SQL 2012). However, the sys.dm_os_sys_info DMV (the column for physical memory) is not the same after the switch to SQL 2012+. Here is the original

  • Where can I find the right doc for SunStudio For Linux ?

    I can find the docs for SunStudio here, http://docs.sun.com/app/docs/doc/819-5265/6n7c29ck9?a=view but it seems that it doesn't right on linux platform. #include <stdio.h> int main(void) #if defined(sun)         printf("sun defined \n"); #else       

  • Error in BDC_INSERT

    Hello Everyone, i have created a BDC in session method, the screens and all are supposed to be correct and still i am getting this error. "BDC_INSERT, screen .&. is invalid" i am using the same screens in many different programs, so i strongly feel t

  • Remote Management fails on Windows 7 64-bit

    Hello, I am not having issues remote controlling any workstations other than the ones running the 64-bit version of Win7. The windows firewall has the Zenworks Remote Management listener added to the allow list so I am not sure what else I need to co

  • Using 3GB of RAM with only Mail open?

    Hi I recently seemed to be having some slowness on my iMac 27" running Mountain Lion. I installed an app that monitors the RAM usage in the menu bar, and after switching on this morning, and only starting Mail, it seemed to be using 3GBs of RAM. That