Explicit access of the index in bulk bind forall

Hi
I wonder if it is possible to access the index itself in a bulk bind. For instance:
SQL> desc draft_responces;
Name Type Nullable Default Comments
S_NUMBER VARCHAR2(10)
CLUSTER_ID NUMBER
STATEMENT_ID NUMBER
RESPONCE NUMBER Y
RESP_NUM NUMBER Y
and I wished to insert the responce number i into the resp_num:
forall i in indices of p_statement_ids
insert into draft_responces
s_number
,cluster_id
,statement_id
,responce
,resp_num)
values (
p_snumber
,p_cluster_id
,p_statement_ids(i)
,p_responces(i)
, i );
which fails ... is it possible to access the index i in a bulk bind explicitly?
thanks

finophile wrote:
Hi
I wonder if it is possible to access the index itself in a bulk bind. For instance:
SQL> desc draft_responces;
Name Type Nullable Default Comments
S_NUMBER VARCHAR2(10)
CLUSTER_ID NUMBER
STATEMENT_ID NUMBER
RESPONCE NUMBER Y
RESP_NUM NUMBER Y
and I wished to insert the responce number i into the resp_num:
forall i in indices of p_statement_ids
insert into draft_responces
s_number
,cluster_id
,statement_id
,responce
,resp_num)
values (
p_snumber
,p_cluster_id
,p_statement_ids(i)
,p_responces(i)
, i );
which fails ... is it possible to access the index i in a bulk bind explicitly?
thanksHi,
according to the documentation index is the "Name for the implicitly declared integer variable that is local to the FORALL statement. Statements outside the FORALL statement cannot reference index. Statements inside the FORALL statement can reference index as an index variable, *but cannot use it in expressions* or change its value. After the FORALL statement runs, index is undefined."
So it appears the answer is no. You can get around this by using an ordinary for loop, though you don't get the benefit of bulk operations.
Andre

Similar Messages

  • Accessing the index in bulk binds

    Hi
    I wonder if it is possible to access the index itself in a bulk bind. For instance:
    SQL> desc draft_responces;
    Name Type Nullable Default Comments
    S_NUMBER VARCHAR2(10)
    CLUSTER_ID NUMBER
    STATEMENT_ID NUMBER
    RESPONCE NUMBER Y
    RESP_NUM NUMBER Y
    and I wished to insert the responce number i into the resp_num:
    forall i in indices of p_statement_ids
    insert into draft_responces
    s_number
    ,cluster_id
    ,statement_id
    ,responce
    ,resp_num)
    values (
    p_snumber
    ,p_cluster_id
    ,p_statement_ids(i)
    ,p_responces(i)
    , i );
    which fails ... is it possible to access the index i in a bulk bind explicitly?
    thanks

    You're in the wrong forum (this one is for issues with the SQL Developer tool). You'll get more answers in the SQL And PL/SQL forum.
    Have fun,
    K.

  • How do you get a topic to open in a custom window when accessed from the index?

    I right click on an index key word and open Properties. There is only one topic associated with this key word. I click on the Advanced tab, select the custom window that I created. Click OK, compile, etc.
    When I try to access this topic from the index, it still opens in the default pane. When I access it from the TOC, it opens in the custom window. How can I get the topic to open in the custom window from the index?
    Thanks!
    Sue

    Hello,
    The link might not work in Preview (When the option to open link in new tab is checked) however it will work if you do a File>Preview page/site in Browser.
    Muse Preview has only one tab and cannot open another tab/window which is why this functionality does not work in Muse Preview. but works in preview in Browser and in published site.
    Regards,
    Sachin

  • Bulk binding in 11g

    Hello,
    My below block works perfectly fine. However the processing takes longer time because of the volume of
    records in the table. I would like to change this below code to use FORALL.
    How can I convert the code to use bulk binding FORALL instead of 'For'.
    Declare
    Cursor  C1 Is Select
    a.old_transaction_id from
    Ideaal_Cons.Tb_Prchs_Sale_Trans_Base A
    where Rownum < 10;
    Type C_Typ Is Table Of C1%Rowtype Index By Pls_Integer;
    C_Rectype C_Typ;
    Type Tab_Desc Is Table Of Ideaal_Cons.Tb_Bookkeeping_Trans_Base.Desc_Line1%Type;
    Type Tab_Nbr Is Table Of Number;
      V_Desc_Tab Tab_Desc;
      V_Nbr      Tab_Nbr; 
      V_Desc_Line1 Varchar2(50);
      V_Desc_Line2 Varchar2(50);
      V_Desc_Line3 Varchar2(50);
      V_Desc_Line4 Varchar2(50);
      V_Desc_Line5 Varchar2(50);
      V_Desc_Line6 Varchar2(50);
      V_Desc_Line7 Varchar2(50);
      V_Desc_Line8 Varchar2(50);
      a number;
      V_Rec Number :=0;
      V_User Varchar2(20) := 'Sisadmin';
    Begin
       Dbms_Output.Enable;
       Open C1;
       Loop
       Fetch C1 Bulk Collect Into C_Rectype Limit 500;
        if C_Rectype.COUNT > 0 THEN
           FOR i IN C_Rectype.FIRST..C_Rectype.LAST
           loop
         Select Line_No,
                Desc_Line
          Bulk Collect Into
              V_Nbr, V_Desc_Tab
          From Ideaal_Staging.Tb_Sisadmin_Trade_Descr
          Where Transaction_Id = C_Rectype(I).Old_Transaction_Id
             Union All
             Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Union All
          Select Null As Line_No, Null As Desc_Line From Dual
          Order By Line_No Asc
              V_Desc_Line1 := V_Desc_Tab(1);
              V_Desc_Line2 := V_Desc_Tab(2);
              V_Desc_Line3 := V_Desc_Tab(3);
              V_Desc_Line4 := V_Desc_Tab(4);
              V_Desc_Line5 := V_Desc_Tab(5);
              V_Desc_Line6 := V_Desc_Tab(6);
              V_Desc_Line7 := V_Desc_Tab(7);
              V_Desc_Line8 := V_Desc_Tab(8);
         Update Ideaal_Cons.Tb_Prchs_Sale_Trans_Base
            Set
              Desc_Line1  = V_Desc_Line1,
              Desc_Line2  = V_Desc_Line2,          
              Desc_Line3  = V_Desc_Line3,          
              Desc_Line4  = V_Desc_Line4,          
              Desc_Line5  = V_Desc_Line5,          
              Desc_Line6  = V_Desc_Line6,          
              Desc_Line7  = V_Desc_Line7,          
              Desc_Line8  = V_Desc_Line8
         Where Old_Transaction_Id = C_Rectype(I).Old_Transaction_Id;
         end loop;
       END IF;
         V_Rec := V_Rec + Nvl(C_Rectype.Count,0);
            Commit;
        Exit When C_Rectype.Count = 0;
    End Loop;
    Dbms_Output.Put_Line('Total Rec updated To Trade Table :- '|| V_Rec);
    End;
    /

    Cool stuff, so you should be able to read through that link and implement the update in that manner if you have issues running the single update command.
    As best i can tell, this works for your needs ... again, i don't know your data so you may have to muddle with it a bit. If you need help with that you will have to start showing your data and explaining "why" or "how" it doesn't fit your requirement.
    TUBBY_TUBBZ?drop table Tb_Prchs_Sale_Trans_Base;
    Table dropped.
    Elapsed: 00:00:00.06
    TUBBY_TUBBZ?drop table Tb_Sisadmin_Trade_Descr;
    Table dropped.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?create table Tb_Prchs_Sale_Trans_Base
      2  (
      3     Transaction_Id       number,
      4     Old_Transaction_Id   number,
      5     desc_line1           varchar2(10),
      6     desc_line2           varchar2(10),
      7     desc_line3           varchar2(10),
      8     desc_line4           varchar2(10),
      9     desc_line5           varchar2(10),
    10     desc_line6           varchar2(10),
    11     desc_line7           varchar2(10),
    12     desc_line8           varchar2(10)
    13  );
    Table created.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?insert into Tb_Prchs_Sale_Trans_Base (Transaction_Id, Old_Transaction_Id) values (998, 1);
    1 row created.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?insert into Tb_Prchs_Sale_Trans_Base (Transaction_Id, Old_Transaction_Id) values (999, 2);
    1 row created.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?create table Tb_Sisadmin_Trade_Descr
      2  (
      3     Transaction_Id number,
      4     line_nbr       number,
      5     desc_line      varchar2(10)
      6  );
    Table created.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?insert into Tb_Sisadmin_Trade_Descr values (1, 1, 'line1');
    1 row created.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?insert into Tb_Sisadmin_Trade_Descr values (1, 2, 'line2');
    1 row created.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?insert into Tb_Sisadmin_Trade_Descr values (1, 3, 'line3');
    1 row created.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?insert into Tb_Sisadmin_Trade_Descr values (2, 4, 'line4');
    1 row created.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?insert into Tb_Sisadmin_Trade_Descr values (2, 5, 'line5');
    1 row created.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?
    TUBBY_TUBBZ?update Tb_Prchs_Sale_Trans_Base tgt
      2     set
      3        (desc_line1, desc_line2, desc_line3, desc_line4, desc_line5, desc_line6, desc_line7, desc_line8)
      4     =
      5     (
      6        select
      7           max(decode(line_nbr, 1, desc_line)),
      8           max(decode(line_nbr, 2, desc_line)),
      9           max(decode(line_nbr, 3, desc_line)),
    10           max(decode(line_nbr, 4, desc_line)),
    11           max(decode(line_nbr, 5, desc_line)),
    12           max(decode(line_nbr, 6, desc_line)),
    13           max(decode(line_nbr, 7, desc_line)),
    14           max(decode(line_nbr, 8, desc_line))
    15        from
    16           Tb_Sisadmin_Trade_Descr src
    17        where
    18           src.Transaction_Id   = tgt.Old_Transaction_Id
    19     );
    2 rows updated.
    Elapsed: 00:00:00.01
    TUBBY_TUBBZ?select * from Tb_Prchs_Sale_Trans_Base;
        TRANSACTION_ID OLD_TRANSACTION_ID DESC_LINE1                     DESC_LINE2                     DESC_LINE3                     DESC_LINE4                     DESC_LINE5                     DESC_LINE6                     DESC_LINE7                     DESC_LINE8
                   998                  1 line1                          line2                          line3
                   999                  2                                                                                              line4                          line5
    2 rows selected.
    Elapsed: 00:00:00.00
    TUBBY_TUBBZ?

  • Question regarding bulk binding

    Gurus,
    How does oracle try to differentiate whether the query should use the concept of bulk binding and a normal query ? Is the key word FOR ALL makes the difference ? Or is there any other difference ??
    Please help
    Regards

    Its not up to oracle to decide, Its the developer who decides it. Bulk bind is used to reduce context switch. And you can achieve it with some of the bulk bind utilities provided by oracle like FORALL and BULK COLLECT.
    Read [Overview of Bulk Binds|http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_packages.htm#sthref853] for more info.
    Thanks,
    Karthick.

  • Query don't use the right index when using bind variables

    Hi people !
    I need some help because I have an issue with a query that don t use the right Indexes as it should
    First of all, I have mainly three tables :
    ORDER : Table that contains description for each Order (approximately 1 000 000 Records)
    ORDER_MVTS : Table that contains the tasks made (called movements) to set up each Orders
    with quantity of packages prepared for each product (approximately 10 000 000 Records)
    PRODUCT : Tables that contains the products (approximately 50 000 Records)
    When I launch the query with hard coded values, it brings back response very fast
    because it uses the right index (ORDER_DHR_VALID) which represent the date and hour of the order
    (with format 'DD/MM/YYYY HH24:MI:SS'). The selectivity for this index is good.
    NB 1: I have to use the trick " >= Trunc(date) and < trunc(date) +1 " to filter on a simple date because
    the index contains hour and minutes (I know it wasn't probably a bright idea at conception time).
    NB 2: The index on ORDER_MVTS.PRODUCT_CODE is'nt discriminating enough because there is'nt enough different products.
    It's the same for index on CUSTOMER_CODE and on MVT_TYPE so only the index on ORDER.DHR_VALID is good.
    Here is the correct explain plan when I execute the query with hard coded values :
    SELECT SUM(ORDER_MVTS.NB_PACKAGE)
    FROM ORDER_MVTS, PRODUCT, ORDER
    WHERE ORDER.DHR_VALID >= TRUNC(to_date('14/11/2008 10:04:56','DD/MM/YYYY HH24:MI:SS'))
    AND ORDER.DHR_VALID < TRUNC(to_date('14/11/2008 10:04:56','DD/MM/YYYY HH24:MI:SS')) + 1
    AND ORDER_MVTS.MVT_TYPE = 'DELIVERY'
    AND PRODUCT.CODE = ORDER_MVTS.PRODUCT_CODE
    AND ORDER_MVTS.ORDER_CODE = ORDER.CODE
    AND ORDER.CUSTOMER_CODE = 'ADIDAS'
    AND PRODUCT.CODE = 1234
    Rows Row Source Operation
    1 SORT AGGREGATE
    2 NESTED LOOPS
    4 NESTED LOOPS
    2 INDEX UNIQUE SCAN (object id 378548) --> PRODUCT_PK
    4 TABLE ACCESS BY INDEX ROWID ORDER
    777 INDEX RANGE SCAN (object id 378119) --> ORDER_DHR_VALID
    2 TABLE ACCESS BY INDEX ROWID ORDER_MVTS
    30 INDEX RANGE SCAN (object id 377784) --> ORDER_MVTS_ORDER_FK
    Now the problem is when the query is used in a Cursor with bind variables.
    It seems like Oracle don't use index on ORDER.DHR_VALID because he can't figure out that he have
    to actually filter on a short period of time (only one day).
    So Oracle uses the index on ORDER_MVTS.PRODUCT_CODE which is'nt a bright idea (it takes 10 secondes instead of just one)
    Here is the bad explain plan :
    Rows Row Source Operation
    1 SORT AGGREGATE
    2 NESTED LOOPS
    722 NESTED LOOPS
    2 INDEX UNIQUE SCAN (object id 378548) --> PRODUCT_PK
    722 TABLE ACCESS BY INDEX ROWID ORDER_MVTS
    1790 INDEX RANGE SCAN (object id 377777) --> ORDER_MVTS_PRODUCT_FK
    2 TABLE ACCESS BY INDEX ROWID ORDER
    1442 INDEX UNIQUE SCAN (object id 378439) --> ORDER_PK
    Now I have found two solutions to this problem :
    1) using a Hint to force the use of index on ORDER.DHR_VALID (with /*+ INDEX(ORDER ORDER_DHR_VALID) */ )
    2) Using Dynamic SQL and keeping the date hard coded (but not the other values except mvt_type)
    For example :
    QUERY :=
    'SELECT SUM(ORDER_MVTS.NB_PACKAGE)
    FROM ORDER_MVTS, PRODUCT, ORDER
    WHERE ORDER.DHR_VALID >= TRUNC(TO_DATE('''||To_char(P_DTE_VAL,'DD/MM/YYYY')||''',''DD/MM/YYYY'')) '||
    AND ORDER.DHR_VALID < TRUNC(TO_DATE('''||To_char(P_DTE_VAL,'DD/MM/YYYY')||''',''DD/MM/YYYY'')) + 1 '||
    AND ORDER_MVTS.MVT_TYPE = 'DELIVERY'
    AND PRODUCT.CODE = ORDER_MVTS.PRODUCT_CODE
    AND ORDER_MVTS.ORDER_CODE = ORDER.CODE
    AND ORDER.CUSTOMER_CODE = :CUSTOMER
    AND PRODUCT.CODE = :CODE ';
    These two solutions work but Number 1 is bad in theory because it uses a Hint
    and Number 2 may be difficult to code.
    So my question is : Does someone knows another solution to force the use of index ORDER_DHR_VALID that can be simple and reliable.
    Thank you very much for support
    Edited by: remaï on Apr 1, 2009 4:08 PM

    What version of oracle you have? CBO work is different in 9i and 10g.
    Usually cost based optimizer do not want to use index for >< condition with binding variables because optimizer can not use statistic to determine selectivity, and by default selectivity of <> operators is low.
    (As I remember '>' selectivity by default is 5%, you have two conditions > and <, therefore resulting selectivity will be 0.05*0.05=0.0025 as two independent events, but selectivity of other conditions
    ORDER_MVTS.MVT_TYPE = 'DELIVERY' or ORDER.CUSTOMER_CODE = 'ADIDAS' looks much better for CBO)
    The best solution I see is do not use binding variables. Actually your query looks as searching query, which executes not so often, therefore you will not have perfomance win along of skipping execution plan creation.
    Edited by: JustasVred on Apr 1, 2009 10:10 AM

  • How to access cataloged pdf index on the Web

    I have indexed a pdf catalog, then copied the results to a Web server.  I can access the individual pdf files okay, but neither Acrobat Pro nor Reader can read the index.  How do I do it?  Thanks!

    You need to EMBED the index file in the PDF.  Here is a helpful blog posting that explains it:  Speed up PDF Search with an Embedded Index

  • Binding a button in the "index.html" page to a Javascript .js file via Mobile JQuery

    I'm unable to bind an event to a button in the index.html file, without calling onclick("eventHandler") within the button element.  Please note that the event handler was declared in a seperate .js file and included in the index.html file. 

    Not enough information.  Can we see your code or a link to your online test page?
    Nancy O.

  • How i can access system tables to know the indexes are properly done

    Hello Friends,
    I have created a table with partitions and a iindex on some columns ..
    Using system tables I want to find out whether the indexes are also having partitions implemented .
    Please let me know what might be the query using system tables.
    using the following query I can findout what all partitions are their in a particular table.
    SELECT FROM ALL_TAB_PARTITIONS ORDER BY TABLE_NAME, PARTITION_NAME;*
    I want the same on indexes ..
    CREATE TABLE X_FA_REV_MNTH_AGG
    X_FA_REV_MNTH_AGG_RK NUMBER(10) NOT NULL,
    X_AS_OF_DT DATE NOT NULL,
    FINANCIAL_ADVISOR_RK NUMBER(10) NOT NULL,
    FINANCIAL_ADVISOR_ID VARCHAR2(6 BYTE),
    X_FA_UNIV_PRODUCER_ID VARCHAR2(6 BYTE),
    X_REVENUE_TYPE_CD VARCHAR2(6 BYTE),
    X_MNTH_REV_AMT NUMBER(18,5),
    PROCESSED_DTTM DATE
    TABLESPACE KAW_DATA
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    NOLOGGING
    PARTITION BY RANGE (X_AS_OF_DT)
    PARTITION P200712 VALUES LESS THAN (TO_DATE(' 2008-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200801 VALUES LESS THAN (TO_DATE(' 2008-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200802 VALUES LESS THAN (TO_DATE(' 2008-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200803 VALUES LESS THAN (TO_DATE(' 2008-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200804 VALUES LESS THAN (TO_DATE(' 2008-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200805 VALUES LESS THAN (TO_DATE(' 2008-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200806 VALUES LESS THAN (TO_DATE(' 2008-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200807 VALUES LESS THAN (TO_DATE(' 2008-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200808 VALUES LESS THAN (TO_DATE(' 2008-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200809 VALUES LESS THAN (TO_DATE(' 2008-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200810 VALUES LESS THAN (TO_DATE(' 2008-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200811 VALUES LESS THAN (TO_DATE(' 2008-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200812 VALUES LESS THAN (TO_DATE(' 2009-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    NOCOMPRESS
    NOCACHE
    NOPARALLEL
    MONITORING;
    CREATE UNIQUE INDEX XPKX_FA_REV_MNTH_AGG ON X_FA_REV_MNTH_AGG
    (X_AS_OF_DT, X_FA_REV_MNTH_AGG_RK, FINANCIAL_ADVISOR_RK)
    INITRANS 2
    MAXTRANS 255
    NOLOGGING
    LOCAL (
    PARTITION P200712
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200801
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200802
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200803
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200804
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200805
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200806
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200807
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200808
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200809
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200810
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200811
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION P200812
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    PARTITION PMAX
    NOLOGGING
    NOCOMPRESS
    TABLESPACE KAW_DATA
    PCTFREE 10
    INITRANS 2
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    BUFFER_POOL DEFAULT
    )NOPARALLEL;

    Try ALL_IND_PARTITIONS :)
    You should give the Reference Guide a read at http://tahiti.oracle.com for your Oracle version. It gives information for all views that you may or may not be aware of.

  • Dynamic SQL and Bulk Bind... Interesting Problem !!!

    Hi Forum !!
    I've got a very interesting problem involving Dynamic SQL and Bulk Bind. I really Hope you guys have some suggestions for me...
    Table A contains a column named TX_FORMULA. There are many strings holding expressions like '.3 * 2 + 1.5' or '(3.4 + 2) / .3', all well formed numeric formulas. I want to calculate each formula, finding the number obtained as a result of each calculation.
    I wrote something like this:
    DECLARE
    TYPE T_FormulasNum IS TABLE OF A.TX_FORMULA%TYPE
    INDEX BY BINARY_INTEGER;
    TYPE T_MontoIndicador IS TABLE OF A.MT_NUMBER%TYPE
    INDEX BY BINARY_INTEGER;
    V_FormulasNum T_FormulasNum;
    V_MontoIndicador T_MontoIndicador;
    BEGIN
    SELECT DISTINCT CD_INDICADOR,
    TX_FORMULA_NUMERICA
    BULK COLLECT INTO V_CodIndicador, V_FormulasNum
    FROM A;
    FORALL i IN V_FormulasNum.FIRST..V_FormulasNum.LAST
    EXECUTE IMMEDIATE
    'BEGIN
    :1 := TO_NUMBER(:2);
    END;'
    USING V_FormulasNum(i) RETURNING INTO V_MontoIndicador;
    END;
    But I'm getting the following messages:
    ORA-06550: line 22, column 43:
    PLS-00597: expression 'V_MONTOINDICADOR' in the INTO list is of wrong type
    ORA-06550: line 18, column 5:
    PL/SQL: Statement ignored
    ORA-06550: line 18, column 5:
    PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL
    Any Idea to solve this problem ?
    Thanks in Advance !!

    Hallo,
    many many errors...
    1. You can use FORALL only in DML operators, in your case you must use simple FOR LOOP.
    2. You can use bind variables only in DML- Statements. In other statements you have to use literals (hard parsing).
    3. RETURNING INTO - Clause in appropriate , use instead of OUT variable.
    4. Remark: FOR I IN FIRST..LAST is not fully correct: if you haven't results, you get EXCEPTION NO_DATA_FOUND. Use Instead of 1..tab.count
    This code works.
    DECLARE
    TYPE T_FormulasNum IS TABLE OF VARCHAR2(255)
    INDEX BY BINARY_INTEGER;
    TYPE T_MontoIndicador IS TABLE OF NUMBER
    INDEX BY BINARY_INTEGER;
    V_FormulasNum T_FormulasNum;
    V_MontoIndicador T_MontoIndicador;
    BEGIN
    SELECT DISTINCT CD_INDICATOR,
    TX_FORMULA_NUMERICA
    BULK COLLECT INTO V_MontoIndicador, V_FormulasNum
    FROM A;
    FOR i IN 1..V_FormulasNum.count
    LOOP
    EXECUTE IMMEDIATE
    'BEGIN
    :v_motto := TO_NUMBER('||v_formulasnum(i)||');
    END;'
    USING OUT V_MontoIndicador(i);
    dbms_output.put_line(v_montoindicador(i));
    END LOOP;
    END;You have to read more about bulk- binding and dynamic sql.
    HTH
    Regards
    Dmytro
    Test table
    a
    (cd_indicator number,
    tx_formula_numerica VARCHAR2(255))
    CD_INDICATOR TX_FORMULA_NUMERICA
    2 (5+5)*2
    1 2*3*4
    Message was edited by:
    Dmytro Dekhtyaryuk

  • ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind

    Hi
    I am getting this run time error ORA-06502: PL/SQL: numeric or value error: Bulk Bind: Truncated Bind in my pl/sql . I tried evrything , changing datatypes ,etc but still this error is coming .What can be the cause , please help.
    declare
    svid xxpor_utility.p_svid@sppmig1%type;
    p_sv_id xxpor_utility.p_svid@sppmig1%type;
    tab xxpor_utility.xxpor_indextab@sppmig1;
    svid1 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id1 xxpor_utility.p_svid@sppmig1%type;
    tab1 xxpor_utility.xxpor_indextab@sppmig1;
    svid2 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id2 xxpor_utility.p_svid@sppmig1%type;
    tab2 xxpor_utility.xxpor_indextab@sppmig1;
    svid3 xxpor_utility.p_svid@sppmig1%type;
    p_sv_id3 xxpor_utility.p_svid@sppmig1%type;
    tab3 xxpor_utility.xxpor_indextab@sppmig1;
    v_index t2_error_table.id_value%type;
    v_code t2_error_table.error_code%type;
    p_error varchar2(600);
    k number(20):=0;
    v_msg varchar2(2000);
    v_commit_count number(10);
    v_at_gpid varchar2(512);
    v_at_oper varchar2(512);
    v_sch varchar2(512);
    v_vat varchar2(512);
    exp exception;
    exp1 exception;
    exp2 exception;
    exp3 exception;
    exp4 exception;
    v_pay varchar2(512);
    v_res varchar2(512);
    v_digit varchar2(512);
    v_agree varchar2(512);
    v_driver_licence PERSON_HISTORY.drivers_licence%TYPE;
    v_cus_gen1 number(10);
    v_cus_gen2 number(10);
    v_cus_gen3 number(10);
    svid_sr number(10);
    v_social PERSON_HISTORY.social_security_number%TYPE;
    CURSOR person_cur (p_person_id person_history.person_id%TYPE)
    IS
    SELECT drivers_licence ,social_security_number
    FROM PERSON_HISTORY@SPPMIG1
    WHERE PERSON_ID=p_person_id --p2(p).person_id
         AND EFFECTIVE_START_DATE = (SELECT MAX(EFFECTIVE_START_DATE)
         FROM PERSON_HISTORY@sppmig1
                                            WHERE PERSON_ID=p_person_id);--p2(p).person_id) ;
    --p number(20):=1;
    --j number(20);
    cursor c1 is
    select * from cus_node_his ;
    type temp_c1 is table of customer_node_history%rowtype
    index by binary_integer;
    t2 temp_c1;
    type temp_c2 is table of customer_node_history@slpmig1%rowtype
    index by binary_integer;
    p2 temp_c2;
    /*cursor c2(p_id customer_query.customer_node_id%type) is
    select general_1,general_2,general_3
    from customer_query@sppmig1 c where c.customer_query_type_id=10003 and
    c.customer_node_id(+) =p_id
    and c.open_date = (select
    max(open_date) from customer_query@sppmig1 where customer_node_id=p_id
    and customer_query_type_id=10003 and c.customer_query_id =(select max(customer_query_id) from customer_query@sppmig1
    where customer_node_id=p_id and customer_query_type_id=10003));*/
    procedure do_bulk_insert is
    bulk_errors EXCEPTION;
    PRAGMA EXCEPTION_INIT(bulk_errors, -24381);
    begin
    forall j in 1..t2.count SAVE EXCEPTIONS
    insert into aaa values t2(j);
    commit;
    --t2.delete;
    k:=0;
    v_msg:=sqlerrm;
    EXCEPTION WHEN bulk_errors THEN
    FOR L IN 1..SQL%bulk_exceptions.count
    LOOP
    v_index := SQL%bulk_exceptions(L).ERROR_INDEX;
    v_code := sqlerrm(-1 * SQL%bulk_exceptions(L).ERROR_CODE);
    --v_index := SQL%bulk_exceptions(j).ERROR_INDEX;
    --v_code := sqlerrm(-1 * SQL%bulk_exceptions(j).ERROR_CODE);
    INSERT INTO t2_error_table
    VALUES('CUSTOMER_NODE_HISTORY',
    'CUSTOMER_NODE_ID',
    v_msg,
    t2(v_index).customer_node_id,
    null,
    'DO_BULK_INSERT',
    v_code
    commit;
    END LOOP;
    end do_bulk_insert;
    begin
    select value into v_at_gpid from t2_system_parameter@sppmig1 where name='atlanta_group_id';
    select value into v_commit_count from t2_system_parameter@sppmig1 where name='batch_size';
    select value into v_sch from t2_system_parameter@sppmig1 where name='schedule_id';
    select value into v_pay from t2_system_parameter@sppmig1 where name='payment_location_code';
    select value into v_at_oper from t2_system_parameter@sppmig1 where name='atlanta_operator_id';
    select value into v_digit from t2_system_parameter@sppmig1 where name='digits_to_be_screened';
    select value into v_res from t2_system_parameter@sppmig1 where name='responsible_agent';
    select value into v_vat from t2_system_parameter@sppmig1 where name='vat_rate';
    select value into v_agree from t2_system_parameter@sppmig1 where name='bank_agreement_status';
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_TYPE_ID',tab);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CREDIT_RATING_CODE',tab2);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','PAYMENT_METHOD_CODE',tab3);
    xxpor_utility.xxpor_loadmemory@sppmig1('CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_STATUS_CODE',tab1);
    open c1;
    loop
    fetch c1 bulk collect into p2 limit v_commit_count;
    for p in 1..p2.count loop
    k:=K+1;
    begin
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CUSTOMER_NODE_TYPE_ID,tab,svid);
    p_sv_id:=svid;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CUSTOMER_NODE_STATUS_CODE,tab1,svid1);
    p_sv_id1 :=svid1;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).CREDIT_RATING_CODE,tab2,svid2);
    p_sv_id2:=svid2;
    xxpor_utility.xxpor_getsvid@sppmig1(p2(p).PAYMENT_METHOD_CODE,tab3,svid3);
    p_sv_id3:=svid3;
    OPEN person_cur (p2(p).person_id);
    FETCH person_cur INTO v_driver_licence, v_social;
    CLOSE person_cur;
    --select social_security_number  into v_social from person_history@sppmig1 where
    --PERSON_ID=p2(p).person_id AND EFFECTIVE_START_DATE = (SELECT MAX(EFFECTIVE_START_DATE) FROM
    --PERSON_HISTORY@sppmig1 WHERE PERSON_ID=p2(p).person_id) ;
    /*open c2(p2(p).customer_node_id);
    fetch c2 into v_cus_gen1, v_cus_gen2, v_cus_gen3;
    close c2;
    xxpor_utility.get_status_code@sppmig1(v_cus_gen1,v_cus_gen2,v_cus_gen3,svid_sr);*/
    svid_sr:=2600000;
    t2(k).CUSTOMER_NODE_ID     :=     p2(p).CUSTOMER_NODE_ID;
    t2(k).LAST_MODIFIED          :=     p2(p).LAST_MODIFIED;
    t2(k).EFFECTIVE_START_DATE     :=     p2(p).EFFECTIVE_START_DATE;
    t2(k).EFFECTIVE_END_DATE     :=     p2(p).EFFECTIVE_END_DATE;
    t2(k).CUSTOMER_NODE_TYPE_ID     := p_sv_id;
    if p_sv_id is null then
    raise exp1;
    end if;
    t2(k).PRIMARY_IDENTIFIER      :=     p2(p).PRIMARY_IDENTIFIER;
    t2(k).PRIMARY_IDENTIFIER2     :=     p2(p).PRIMARY_IDENTIFIER2;
    t2(k).NODE_NAME           :=     p2(p).NODE_NAME ;
    t2(k).NODE_NAME_UPPERCASE     :=     p2(p).NODE_NAME_UPPERCASE ;
    t2(k).NODE_NAME_SOUNDEX     :=     p2(p).NODE_NAME_SOUNDEX;
    t2(k).ATLANTA_GROUP_ID          := v_at_gpid ;
    t2(k).ATLANTA_OPERATOR_ID     :=     p2(p).ATLANTA_OPERATOR_ID;
    t2(k).GL_CODE_ID          :=     p2(p).GL_CODE_ID;
    t2(k).PARENT_CUSTOMER_NODE_ID     := p2(p).PARENT_CUSTOMER_NODE_ID ;
    t2(k).HIERARCHY_LEVEL          := p2(p).HIERARCHY_LEVEL ;
    t2(k).ROOT_CUSTOMER_NODE_ID      := p2(p).ROOT_CUSTOMER_NODE_ID ;
    t2(k).CUSTOMER_NODE_STATUS_CODE := p_sv_id1 ;
    if p_sv_id1 is null then
    raise exp2;
    end if;
    t2(k).CREATED_DATE     :=          p2(p).CREATED_DATE;
    t2(k).ACTIVE_DATE      :=          p2(p).ACTIVE_DATE ;
    t2(k).PERSON_ID     :=          p2(p).PERSON_ID ;
    t2(k).PRIME_ACCOUNT_ID :=          p2(p).PRIME_ACCOUNT_ID;
    t2(k).REPORT_LEVEL_CODE :=          p2(p).REPORT_LEVEL_CODE;
    t2(k).POSTAL_ADDRESS_ID     :=     p2(p).POSTAL_ADDRESS_ID;
    t2(k).SITE_ADDRESS_ID     :=     p2(p).SITE_ADDRESS_ID ;
    t2(k).CURRENCY_ID      :=          p2(p).CURRENCY_ID;
    t2(k).SCHEDULE_ID     :=          v_sch;
    t2(k).BILLING_PRIORITY     :=     p2(p).BILLING_PRIORITY ;
    t2(k).BILLING_COMPLEXITY:=          p2(p).BILLING_COMPLEXITY ;
    t2(k).BILLING_CONFIGURATION_CODE     := p2(p).BILLING_CONFIGURATION_CODE;
    t2(k).SUPPRESS_IND_CODE           := p2(p).SUPPRESS_IND_CODE ;
    t2(k).SUPPRESS_BILL_CYCLE_COUNT := p2(p).SUPPRESS_BILL_CYCLE_COUNT;
    t2(k).SUPPRESS_UNTIL_ISSUE_DATE := p2(p).SUPPRESS_UNTIL_ISSUE_DATE;
    t2(k).TURNOVER               := p2(p).TURNOVER;
    t2(k).TURNOVER_CURRENCY_ID      :=     p2(p).TURNOVER_CURRENCY_ID ;
    t2(k).CREDIT_LIMIT           :=     p2(p).CREDIT_LIMIT ;
    t2(k).CREDIT_LIMIT_CURRENCY_ID :=     p2(p).CREDIT_LIMIT_CURRENCY_ID;
    t2(k).EXPECTED_REVENUE      :=     p2(p).EXPECTED_REVENUE ;
    t2(k).EXPECTED_REVENUE_CURRENCY_ID     := p2(p).EXPECTED_REVENUE_CURRENCY_ID ;
    t2(k).CREDIT_RATING_CODE      :=     p_sv_id2 ;
    -- if p_sv_id2 is null then
    --raise exp3;
    -- end if;
    t2(k).CREDIT_COMMENTS           := p2(p).CREDIT_COMMENTS ;
    t2(k).TAX_CLASS_CODE          := 1     ;
    t2(k).PAYMENT_METHOD_CODE     :=     p_sv_id3;
    --if p_sv_id3 is null then
    --raise exp4;
    --end if;
    t2(k).PAYMENT_LOCATION_CODE      := v_pay ;
    t2(k).BANK_CODE           :=     NULL;
    t2(k).BRANCH_CODE           :=     NULL ;
    t2(k).BANK_ACCOUNT_NAME     :=     p2(p).NODE_NAME ;
    t2(k).BANK_ACCOUNT_NUMBER     :=     '1000000';
    t2(k).BANK_ACCOUNT_REF      :=     v_agree;
    t2(k).CARD_TYPE_CODE          := p2(p).CARD_TYPE_CODE     ;
    t2(k).CARD_NUMBER          :=     p2(p).CARD_NUMBER ;
    t2(k).CARD_EXPIRY_DATE          := NULL ;
    t2(k).ASSIGNED_OPERATOR_ID      :=     NULL ;
    t2(k).SALES_CHANNEL_CODE     :=     0;
    t2(k).COMPANY_NUMBER          := NULL;
    t2(k).INDUSTRY_CODE          :=     NULL;
    t2(k).REGION_CODE           :=     NULL;
    t2(k).GENERAL_1          :=     v_vat ;
    t2(k).GENERAL_2           :=     svid_sr ;
    if svid_sr is null then
    raise exp;
    end if;
    t2(k).GENERAL_3           :=     v_social ;
    t2(k).GENERAL_4           :=     v_driver_licence ;
    t2(k).GENERAL_5           :=     v_vat;
    t2(k).GENERAL_6           :=     v_res;
    t2(k).GENERAL_7           :=     null||':'||null||':'||'1000000'||':'||null||':'||null||':'||null||':';
    t2(k).GENERAL_8          :=     '2' ;
    t2(k).GENERAL_9           :=     v_digit;
    t2(k).GENERAL_10          :=     p2(p).CUSTOMER_NODE_ID;
    exception when exp then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;
    when exp1 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'customer_node_type_id is null');
    commit;
    when exp2 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'customer_node_status_code is null');
    commit;
    /*when exp3 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,'credit_rating_code is null');
    commit;
    when exp4 then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;*/
    when others then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,p2(p).customer_node_id
    ,null,null,null);
    commit;
    end;
    if mod(k,v_commit_count)=0 then
    do_bulk_insert;
    t2.delete;
    end if;
    end loop;
    do_bulk_insert;
    exit when c1%notfound;
    end loop;
    t2.delete;
    exception when others then
    p_error:= sqlerrm;
    insert into t2_error_table values ( 'CUSTOMER_NODE_HISTORY','CUSTOMER_NODE_ID',p_error,null
    ,null,null,null);
    commit;
    RAISE;
    end;
    /

    Hi there,
    Following is the description of the error, you are getting.
    ORA-06502:VALUE_ERROR
    An arithmetic, conversion, truncation, or size-constraint error occurs. For example, when your program selects a column value into a character variable, if the value is longer than the declared length of the variable, PL/SQL aborts the assignment and raises VALUE_ERROR. In procedural statements, VALUE_ERROR is raised if the conversion of a character string into a number fails. (In SQL statements, INVALID_NUMBER is raised.)
    Hopefully this will help.

  • Bulk Binding

    The below example is based on an example from Chapter 5 in Release 2 (9.2) documentation (Available in Oracle site).
    But it is failing and throwing the following error:
    "PLS-00435 DML statement without BULK In-BIND cannot be used inside FORALL".
    Can you pl suggest a workaround for this?
    CREATE TABLE test_ravi3 (col1 NUMBER, col2 VARCHAR2(20));
    CREATE TABLE test_ravi4 (col1 NUMBER, col2 VARCHAR2(20));
    INSERT INTO test_ravi3 VALUES(1,'RAVI' );
    INSERT INTO test_ravi3 VALUES(2,'RAVI1' );
    INSERT INTO test_ravi3 VALUES(3,'RAVI2' );
    INSERT INTO test_ravi3 VALUES(4,'RAVI3' );
    INSERT INTO test_ravi3 VALUES(5,'RAVI4' );
    DECLARE
    TYPE RecTabTyp IS TABLE OF test_ravi3%ROWTYPE
    INDEX BY BINARY_INTEGER;
    TYPE NumTabTyp IS TABLE OF NUMBER
    INDEX BY BINARY_INTEGER;
    TYPE CharTabTyp IS TABLE OF VARCHAR2(20)
    INDEX BY BINARY_INTEGER;
    CURSOR c1 IS SELECT col1, col2 FROM test_ravi4;
    rec_tab RecTabTyp;
    BEGIN
    SELECT COL1, COL2 BULK COLLECT INTO REC_TAB FROM TEST_RAVI3
    WHERE COL1 &lt; 9;
    FORALL I IN REC_TAB.FIRST..REC_TAB.LAST
    INSERT INTO TEST_RAVI4 VALUES REC_TAB(I);
    FOR I IN REC_TAB.FIRST..REC_TAB.LAST LOOP
    REC_TAB(I).COL1 := REC_TAB(I).COL1 + 100;
    END LOOP;
    FORALL I IN REC_TAB.FIRST..REC_TAB.LAST
    UPDATE TEST_RAVI3 SET (COL1 ,COL2) = REC_TAB(I);
    OPEN C1;
    FETCH C1 BULK COLLECT INTO REC_TAB;
    CLOSE C1;
    END;

    Is block abc based on Table1? If it is, then you should NOT be issuing ANY update sql statements on the table. This just causes problems.
    Assuming abc is based on Table1, then the block should contain a text item for all three fields: Field1, col1, and col2. Then all you need is:
    Go_block('abc');
    first_record;
    Loop
      exit when :system.record_status='NEW';
      if :abc.field1 = 'Y' then
        :abc.col1 := value1;
      end if;
      exit when :system.last_record='TRUE';
    end loop;
    first_record;
    commit_form;
    Forms will take care of creating and executing the sql update statement, and it will do it using rowid, which is better than "where col2 = :abc.col2;" Also, you will no longer have locking problems.
    ...However... if abc is based on a table other than Table1, then something like your code is what you need to use. The fastest method of execution would be the bulk binding route, but do it from a package procedure on the database that you call from the form.

  • ORA-01502 error in case of unusable unique index and bulk dml

    Hi, all.
    The db is 11.2.0.3 on a linux machine.
    I made a unique index unusable, and issued a dml on the table.
    Howerver, oracle gave me ORA-01502 error.
    In order to avoid ORA-01502 error, do I have to drop the unique index ,and do bulk dml, and recreate the index?
    Or Is there any other solution without re-creating the unique index?
    create table hoho.abcde as
    select level col1 from dual connect by level <=1000
    10:09:55 HOHO@PD1MGD>create unique index hoho.abcde_dx1 on hoho.abcde (col1);
    Index created.
    10:10:23 HOHO@PD1MGD>alter index hoho.abcde_dx1 unusable;
    Index altered.
    Elapsed: 00:00:00.03
    10:11:27 HOHO@PD1MGD>delete from hoho.abcde where rownum < 11;
    delete from hoho.abcde where rownum < 11
    ERROR at line 1:
    ORA-01502: index 'HOHO.ABCDE_DX1' or partition of such index is in unusable stateThanks in advance.
    Best Regards.

    Hi. all.
    The following is from "http://docs.oracle.com/cd/E14072_01/server.112/e10595/indexes002.htm#CIHJIDJG".
    Is there anyone who can show me a tip to avoid the following without dropping and re-creating an unique index?
    •DML statements terminate with an error if there are any unusable indexes that are used to enforce the UNIQUE constraint.
    Unusable indexes
    An unusable index is ignored by the optimizer and is not maintained by DML. One reason to make an index unusable is if you want to improve the performance of bulk loads. (Bulk loads go more quickly if the database does not need to maintain indexes when inserting rows.) Instead of dropping the index and later recreating it, which requires you to recall the exact parameters of the CREATE INDEX statement, you can make the index unusable, and then just rebuild it. You can create an index in the unusable state, or you can mark an existing index or index partition unusable. The database may mark an index unusable under certain circumstances, such as when there is a failure while building the index. When one partition of a partitioned index is marked unusable, the other partitions of the index remain valid.
    An unusable index or index partition must be rebuilt, or dropped and re-created, before it can be used. Truncating a table makes an unusable index valid.
    Beginning with Oracle Database 11g Release 2, when you make an existing index unusable, its index segment is dropped.
    The functionality of unusable indexes depends on the setting of the SKIP_UNUSABLE_INDEXES initialization parameter.
    When SKIP_UNUSABLE_INDEXES is TRUE (the default), then:
    •DML statements against the table proceed, but unusable indexes are not maintained.
    •DML statements terminate with an error if there are any unusable indexes that are used to enforce the UNIQUE constraint.
    •For non-partitioned indexes, the optimizer does not consider any unusable indexes when creating an access plan for SELECT statements. The only exception is when an index is explicitly specified with the INDEX() hint.
    •For a partitioned index where one or more of the partitions are unusable, the optimizer does not consider the index if it cannot determine at query compilation time if any of the index partitions can be pruned. This is true for both partitioned and non-partitioned tables. The only exception is when an index is explicitly specified with the INDEX() hint.
    When SKIP_UNUSABLE_INDEXES is FALSE, then:
    •If any unusable indexes or index partitions are present, any DML statements that would cause those indexes or index partitions to be updated are terminated with an error.
    •For SELECT statements, if an unusable index or unusable index partition is present but the optimizer does not choose to use it for the access plan, the statement proceeds. However, if the optimizer does choose to use the unusable index or unusable index partition, the statement terminates with an error.Thanks in advance.
    Best Regards.

  • Bulk Binding Drawback

    Hi All,
    Seems that Bulk binding of pl/sql do enhance performance, but have no information about its drawback. Does anyone know what drawback that bulk binding have? Thank you.
    CH.

    The only drawback I am aware of is that in some circumstances, using bind variables may cause the optimizer to choose a sub-optimal plan for a query.
    Say you have a table with 1,000,000 rows. 900,000 rows have the value 1 in an indexed column, and the other 100,000 have unique values.
    Clearly, if you issue something like:
    SELECT *
    FROM table
    WHERE indexed_column = 256you would want to use an index. However, if you are looking for indexed_column = 1, then a Full Table Scan would be more efficient. With bind variables, Oracle (prior to 91) will most likely choose the FTS route because of the statisitics. However, if you always query on the unique values, that is not the right plan. In 9i the optimizer "peeks" at the bind variable the first time the statement is parsed and chooses the plan based on that value. In this case, if you always query on the unique values, Oracle is much more likely to get the "correct" plan.
    HTH
    John

  • Error  in  bulk bind

    Hi  All,
    i am  new  for bulk binding  when i am trying  to insert  data  in  table  getting  error  PL/SQL: ORA-00904: : invalid identifier
    i need  to insert  data  in  to one  column below  are  the  desc for the  same .
    OR REPLACE function OMDV4_IDENTITY_OWNER.testing2(enterno in    number ) return number
    TYPE t_tab IS TABLE OF emp.empno%TYPE;
    := t_tab();
    NUMBER; 
    EXCEPTION;
    PRAGMA EXCEPTION_INIT(ex_dml_errors, -01400);
    -- Fill the collection.
    FOR i IN 1 .. 5 LOOP
    .extend;
    (l_tab.last):= i;
    END LOOP;
    delete from emp;
    commit;
    -- Perform a bulk operation.
    BEGIN
    FORALL i IN l_tab.first .. l_tab.last
    INSERT INTO EMP
    VALUES l_tab(i); ------ here  i am  getting  error
    EXCEPTION
    WHEN ex_dml_errors THEN
    := SQL%BULK_EXCEPTIONS.count;
    ('Number of failures: ' || l_error_count);
    FOR i IN 1 .. l_error_count LOOP
    ('Error: ' || i ||
    ' Array Index: ' || SQL%BULK_EXCEPTIONS(i).error_index ||
    ' Message: ' || SQLERRM(-SQL%BULK_EXCEPTIONS(i).ERROR_CODE));
    END LOOP;
    END;
    return 1;
    END;
    Thanks

    I hope that you are just practicing BULK COLLECT. Because what you are doing using bulk collect is completely unnecessary. This can be simply done in SQL.
    What is your DB version. Referring record type directly in value clause is available from 11g onwards I guess. In previous version you get the following error.
    PL/SQL: ORA-03001: unimplemented feature
    So to fix your problem your FORALL code should be like this
    forall i in l_tab.first .. l_tab.last
       insert into emp_t (empno) values (l_tab(i));
    That's because l_tab contains the value of EMPNO alone. so you need to specify the column name in your insert statement. Also you need to use Brackets before and after l_tab(i).

Maybe you are looking for