Huge insert and passing insert statement in between  in oracle

I need to generate test data , i am making use of level with dual table and want to pass commit let say after 5 records are inserted.. but the problem is that last loop iteration result incorrect inserts.. one can plz help me..
create or replace procedure sp_test_Data_insert (i_no_records number)
as
l_cnt pls_integer:=1;
l_tot pls_integer:=0;
begin
while l_cnt<=i_no_records
loop
insert into test_data
select test_data_seq.nextval
from (select level from dual connect by level <= l_cnt);
dbms_output.put_line (' no.of records in loop : '|| sql%rowcount);
l_tot:=l_tot+sql%rowcount;
l_cnt:=l_cnt+5;
commit;
end loop;
dbms_output.put_line ('Total records : '|| l_tot);
end;
SQL> execute sp_test_Data_insert(10);
no.of records in loop : 1
no.of records in loop : 6
Total records : 7
PL/SQL procedure successfully completed.
issue - since third loop cnt=11, hence incorrect insert... can someone help with this...

knowledgespring wrote:
what if the total number of records is 1m, 10m, would you suggest make db go down or fail with lack of undo!??Clearly you do not know Oracle databases.
10 million records is nothing to an oracle database.
i want to pass commit in between and complete the no.of records count passed to the SP,it may be 1m, 100000,100001, 100005 , 100055, 100099...etc..
what if this is the case!!??
5 is just an example... and it can be 10000, 50000.. plan is to commit after every 25000 records...Committing every X number of records can cause oracle to spawn multiple write processess on the server, and more writer processes = more server resources = slower server.
It's also transactionally inconsistent and can leave you with major headaches if a problem occurs part way through your overall business logical transaction, as you can't rollback etc.
lack of undo is no excuse for committing out of place. resize your undo or scale your hardware according to the needs of the business, but don't write poor code that will break the database even more to try and fudge your way out of it.

Similar Messages

  • In jdbc adapter what is the difference between insert and update insert

    in jdbc adapter what is the difference between insert and update insert
    Edited by: katru vijay on Mar 22, 2010 7:43 AM

    Please refer to this Link [Document Formats for the Receiver JDBC Adapter|http://help.sap.com/saphelp_nw04/Helpdata/EN/22/b4d13b633f7748b4d34f3191529946/frameset.htm]
    Hope this helps.
    Regards,
    Chandravadan

  • Difference between Before INSERT and After INSERT trigger?

    What is difference between Before INSERT and After INSERT triggers? Can anyone give me a simple example from SCOTT schema for both of these triggers.

    The documentation gives a good explanation have you looked at....
    http://download.oracle.com/docs/cd/B19306_01/appdev.102/b14251/adfns_triggers.htm#sthref1175

  • Is there a problem with copy paste using Ctrl+insert and Shift+insert

    This is a swing application.
    initially i was using java 1.3 and the copy paste using Ctrl+insert and Shift+insert was working
    then i migrated the same to java 1.5 and this functionality got messed up.

    Include the following in your initialization code, before you create any components:     InputMap im = (InputMap)UIDefaults.get("TextField.focusInputMap");
        im.put(KeyStroke.getKeyStroke("control INSERT"), DefaultEditorKit.copyAction);
        im.put(KeyStroke.getKeyStroke("shift INSERT"), DefaultEditorKit.pasteAction);
        im.put(KeyStroke.getKeyStroke("shift DELETE"), DefaultEditorKit.cutAction); You'll need to add the appropriate imports, too: import javax.swing.InputMap;
    import javax.swing.KeyStroke;
    import javax.swing.UIDefaults;
    import javax.swing.text.DefaultEditorKit; It seems they accidentally removed those bindings from JTextField under MetalLookAndFeel in JDK 1.5. They've been restored in JDK 1.6.

  • What is difference of truncate/insert and delete/insert ?

    hi all:
    what is difference of truncate/insert and delete/insert ?

    Hi,
    Truncate will truncate the table, which means there is a DDL operation to empty the table. DDL operations cannot be rolled back, but truncate is much faster than delete (because of that reason). If you do not require recovery of the deleted records in case of a failure, then truncate/insert is more optimal than delete/insert. Notice that for truncate to work, you cannot have enabled foreign keys pointing to the table. Truncate will never perform cascaded deletes.
    Hope this explains.
    Mark.

  • Using Hibernate Functionality and pass it on to the JCAPS Oracle eWay

    Hi All,
    I need to use the Existing Hibernate API's and pass it on to the JCAPS oracle eWay to persist the Data.
    As the present Application is using the Hibernate for persisting the Data as we have parent child relation with multiple tables , so we need to push the whole thing in to JCAPS.
    Thanks & regards
    Srikanth

    narayanaa wrote:
    Hi,
    You cannot use hibernate using oracle or any other database eWays. If you want to leverage the same or the existing code you have for the Data Access you use JCD.
    So what you can do is have the required jars available for the application and then use the available classes with in the JCD.
    Thanks,
    NarayanaaI don't think that is secesarily true. You can use oracle eWay to handle the database connection, pooling and XA transactions. You just retrieve the java.sql.Connection object from the eWay and use that in you hibernate code.
    -Mario

  • What is differenct between normal insert and forall insert.

    Hi,
    i am little bit confused about following 2 types of inserts.
    insert into TableA
    select * from TableB
    and
    insert using forAll statment.
    which one is faster and why.

    Pankaj M wrote:
    insert into TableA
    select * from TableB
    and
    insert using forAll statment.
    which one is faster and why.The first, insert ... select.
    Because you just insert and don't need to fetch the results anywhere and allocate memory and less code executes in less time.

  • Insert and update tables from SQL server to oracle database tables

    Hi,
    I am having problem while update data from sql server to oracle database tables.
    I am doing one way insert +updates that is from SQL Server tables ==> Oracle database tables
    I am using tools Sql server Integration service. I can insert data from sql server to oracle but update can't. Please help me how can I update + insert from sql server to oracle database tables easily.
    Thanks in advance.

    Hi,
    What about using Oracle SQL Developer for migration
    http://www.oracle.com/technetwork/database/migration/sqlserver-095136.html
    HTH

  • Generic Insert and Update Queries to work on both Oracle and SQLServer

    xMII12.0.2
    I need to write queries which will be able to run on both Oracle and SQLServer database tables without any changes.  It needs to be able to handle dates without including Oracle specific date functions (TO_DATE, TO_CHAR, TO_TIMESTAMP, etc.).
    I did read a post earlier by Jeremy Good regarding the use of ED and SD which invoke the DatePrefix and DateSuffix in the data server configuration.  That seems to work fine in cases of only trying to insert two distinct dates.  However, what do you do in the case of having three or more dates to insert.  An example query might be:
    Insert into ProductionOrder
    (ProdOrdNbr, Plant, Material, Quantity, UOM, DeliveryDate, ProdStartDate, ProdFinishDate, CreateDate, LastModifiedDate)
    Values
    ('0100001001', '001', '000000000007887780', 20.0, 'PC', '21-FEB-08 22:01:19','11-FEB-08 00:01:34', '12-FEB-08 02:44:59', '01-FEB-08 12:00:00', '04-FEB-01 13:22:13')
    So far I have been using the TO_DATE to convert the dates successfully, but SQLServer does not recognize that function (not surprising since it is an Oracle specific function).  So I would have to go through all the transactions/query templates and rebuild them separately to deal with the different database vendors. 
    Any suggestions?
    Thanks,
    Mike

    Hi Rick,
    Are you talking about dynamically building each script based on a server setting and datatype?  If I understand you correctly, I guess it could be done that way, but it would be a royal pain to maintain.  I have done such things before and can see how it could be done. 
    But is there no way to invoke the DatePrefix and DateSuffix besides the SD and ED parameters?  Or did I misunderstand your response?
    I would be perfectly happy to build all the queries inside BLS transactions.  In the few cases, where they are not already contained in the BLS, we could throw a BLS wrapper around it and not pay much of a penalty in performance.
    Thanks,
    Mike

  • How to insert and retrive data from Discussion forum in Oracle Server 10g

    Hi,
    I have successfully deployed discussion forum, in Oracle app server 10g, and its working fine. Now, i have to implement a Moderator in this. but i am not getting an idea, where is the queries and specifications about the tables are given.
    Please help me to to understand the work flow, as well to know, the place where queries are written.
    Thanks in advance,
    Dhananjay

    Hi,
    I have successfully deployed discussion forum, in Oracle app server 10g, and its working fine. Now, i have to implement a Moderator in this. but i am not getting an idea, where is the queries and specifications about the tables are given.
    Please help me to to understand the work flow, as well to know, the place where queries are written.
    Thanks in advance,
    Dhananjay

  • ODBC, bulk inserts and dynamic SQL

    I am writing an application running on Windows NT 4 and using the oracle ODBC driver (8.01.05.00, that inserts many rows at a time (10000+) into an oracle 8i database.
    At present, I am using a stored procedure to insert each row into the database. The stored procedure uses dynamic SQL because I can only determine the table and field names at run time.
    Due to the large number of records, it tends to take a while to perform all the inserts. I have tried a number of solutions such as using batches of SQL statements (e.g. "INSERT...;INSERT...;INSERT..."), but the oracle ODBC driver only seems act on the first statement in the batch.
    I have also considered using the FOR ALL statement and SQL*Loader utility.
    My problem with FOR ALL is that I'm not sure it works on dynamic SQL statements and even if it did, how do I pass an array of statements to the stored procedure.
    I ruled out SQL* Loader because I could not find a way to invoke it it from an ODBC statement. Secondly, it requires the spawining of a new process.
    What I am really after is something similar the the SQL Server (forgive me!) BULK INSERT statement where you can simply create an input file with all the records you want to insert, and pass it along in an ODBC statement such as "BULK INSERT <filename>".
    Any ideas??
    null

    Hi,
    I faced this same situation years ago (Oracle 7.2!) and had the following alternatives.
    1) Use a 3rd party tool such as Sagent or CA Info pump (very pricey $$$)
    2) Use VisualC++ and OCI to hook into the array insert routines (there are examples of these in the Oracle Home).
    3) Use SQL*Loader (the best performance, but no real control of what's happening).
    I ended up using (2) and used the Rouge Wave dbtools.h++ library to speed up the development.
    These days, I would also suggest you take a look at Perl on NT (www.activestate.com) and the DBlib modules at www.perl.org. I believe they will also do bulk loading.
    Your problem is that your program is using Oracle ODBC, when you should be using Oracle OCI for best performance.
    null

  • Bulk inserts and dynamic SQL

    I am writing an application running on Windows NT 4 and using the oracle ODBC driver (8.01.05.00, that inserts many rows at a time (10000+) into an oracle 8i database.
    At present, I am using a stored procedure to insert each row into the database. The stored procedure uses dynamic SQL because I can only determine the table and field names at run time.
    Due to the large number of records, it tends to take a while to perform all the inserts. I have tried a number of solutions such as using batches of SQL statements (e.g. "INSERT...;INSERT...;INSERT..."), but the oracle ODBC driver only seems act on the first statement in the batch.
    I have also considered using the FOR ALL statement and SQL*Loader utility.
    My problem with FOR ALL is that I'm not sure it works on dynamic SQL statements and even if it did, how do I pass an array of statements to the stored procedure.
    I ruled out SQL* Loader because I could not find a way to invoke it it from an ODBC statement. Secondly, it requires the spawining of a new process.
    What I am really after is something similar the the SQL Server (forgive me!) BULK INSERT statement where you can simply create an input file with all the records you want to insert, and pass it along in an ODBC statement such as "BULK INSERT <filename>".
    Any ideas??
    null

    Hi,
    I faced this same situation years ago (Oracle 7.2!) and had the following alternatives.
    1) Use a 3rd party tool such as Sagent or CA Info pump (very pricey $$$)
    2) Use VisualC++ and OCI to hook into the array insert routines (there are examples of these in the Oracle Home).
    3) Use SQL*Loader (the best performance, but no real control of what's happening).
    I ended up using (2) and used the Rouge Wave dbtools.h++ library to speed up the development.
    These days, I would also suggest you take a look at Perl on NT (www.activestate.com) and the DBlib modules at www.perl.org. I believe they will also do bulk loading.
    Your problem is that your program is using Oracle ODBC, when you should be using Oracle OCI for best performance.
    null

  • Post-insert vs pre-insert

    Dear All,
    can anybody explain the difference b/w pre-insert and post-insert trigger ?
    i need such example which process something that becomes possible in one trigger and no possible in other ?
    Regards
    Kashif Butt

    Here is an example. Please remove any syntax errors before running :-)
    create sequence my_seq;
    create table table_a
    (id number(20) constraint pk_table_a primary key,
    text varchar2(100)
    create table table_b
    (id number(20) constraint pk_table_b primary key,
    a_id number(20) constraint fk1_table_b foreign key references table_a(id),
    text varchar2(100)
    Create a form with a block based on table_a with items "id" and "text"
    "id" is on null canvas (not visible), put "text" on a canvas.
    pre-insert:
    select my_seq.nextval into :table_a.id;
    This can't be done in post-insert. Then the insert will fail because it's the primary key and must be "not null"
    post-insert:
    insert into table_b(id, a_id, text)
    values(my_seq.nextval, :table_a.id, 'Inserted automatically by post-insert');
    This can't be done in the pre-insert trigger, because the foreign key constraint will require the record in table_a
    to be inserted first.

  • Call External C++ function and pass XML

    Hi,
    I need to call external C++ function from Oracle and pass to it XML file from Oracle table? Can you give short guide how to do it?
    Regards

    Your question sounds like is about using an Oracle database (or other application), and not about C++ programming or the using the C++ compiler. You are more likely to find a helpful answer in an Oracle database (or other application) forum.

  • Can I insert pretest questions as knowledge checks between content slides and before a graded quiz without affecting the scoring of the graded quiz? Help documentation states that they should be used before a course begins.

    Can I insert pretest questions as knowledge checks between content slides and before a graded quiz without affecting the scoring of the graded quiz? Help documentation states that they should be used before a course begins.
    If I use both pretest questions and graded questions, can I also include remedial with return to quiz for both?

    Sorry, but I gave two workarounds: my preference is custom question slides, but you can also have questions slides where you do not add the score to the Total score. They will not be reported to the LMS and can act as Knowledge slides. Only some quizzing system variables can count all question slides, including the Knowledge slides, but the core variables (score, maximum score, percentage) will be correct. Here some links to my blog, that could help you:
    System variables in Captivate 8 - Captivate blog
    Intermediate Score Slides - Captivate blog
    That each SCORM module can have only one quiz is a SCORM requirement, not a a Captivate specific feature. Camtasia is bit difficult to compare, it is not a fully blown authoring tool although the best video screen capture tool around (video is non interactive by definition). I don't use Storyline, but cannot imagine that they shouldn't create SCORM-compliant files.

Maybe you are looking for