ADF batch insert

Hello

JDeveloper, ADF, BC4J, JSF, Facelets 12.1.3.

A Java bean, we have access to a lot of data. We want to insert data into the tables of database applications. If we do (directly) IE. with jdbc prepared, my experience is that the data inserted will be immediately visible in the application. Is there a better way to do the inserts? That is to say through the entity - or viewobjects?

Best regards

Erik

Instead with jdbc, do the work using the ViewObject of entities.

In this way, the inserted data will be immediately visible in the application.

Tags: Java

Similar Questions

  • TimesTen jdbc batch insert a bug with CallableStatement. Batch insert parameters and inserts dublicates first parameter n times with CallableStatement.

    Hello, below batch insert has a problem with CallableStatement. But PreparedStatement(commented lines) there is no problem. Batch insert parameters and inserts dublicates first parameter n times with CallableStatement. Maybe there is a bug in the driver jdbc TimesTen (ttjdbc7.jar) or some other problem. I use TimesTen version 11.2.2.5.0 and Java 7u51.

    Help, please!

    ...
    //PreparedStatement statement = null;
    CallableStatement statement = null;
    //String sql = "INSERT INTO address_book(id, user_id, phone_number) VALUES (seq_id.nextval, ?, ?)";
    String sql = "{call add_phone_number(?, ?)}";
    try {
        //statement = getConnection().prepareStatement(sql);
        statement = getConnection().prepareCall(sql);
        for (String phoneNumber : list) {
            statement.setLong(1, userId);
            statement.setString(2, phoneNumber);
            statement.addBatch();
        }
        statement.executeBatch();
    } finally {
        if (statement != null) {
            statement.close();
        }
    }
    ...
    
    
    
    

    It is a known problem. We expect to have a fix in a future version, but there is currently no ETA that I can share with you. I recommend that you connect a SR with support so that we can follow the fact that this problem affects you.

    Chris

  • oracle.adfinternal.controller.savepoint.SavePointException: ADFC-08008: the controller of the ADF cannot insert a record of savepoint for ID

    I implemented a save point in a workflow by creating a save point in the method action following is the managed bean code to create check point:

    ControllerContext cc = ControllerContext.getInstance ();

    If (cc! = null) {}
    Bishop SavePointManager = cc.getSavePointManager ();
    If (mgr! = null) {}
    The ID of the string = mgr.createSavePoint ();

    savePointId = id;
    }

    It has worked well in local (integrated Weblogic Server). She also worked fine initially when I deployed the changes to the weblogic DEV Server. But after a few days, in DEV I am getting the following error whenever trying to create a server backup point:

    Caused by: oracle.adfinternal.controller.savepoint.SavePointException: ADFC-08008: the controller of the ADF cannot insert a record of savepoint for the ID 4 d 233555-ea0c-4bae-9f17-cc6c

    7124870f'. oracle.adfinternal.controller.savepoint.SavePointUtil.createAndLogSavePointException(SavePointUtil.java:56)

    at oracle.adfinternal.controller.savepoint.SavePointDBPersistManager.insertSavePoint(SavePointDBPersistManager.java:245)

    at oracle.adfinternal.controller.savepoint.DBSavePointManagerImpl.storeSavePoint(DBSavePointManagerImpl.java:127)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.storeSavePoint(SavePointManagerImpl.java:301)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.createAndStoreSavePoint(SavePointManagerImpl.java:257)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.createSavePoint(SavePointManagerImpl.java:187)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.createSavePoint(SavePointManagerImpl.java:116)

    at view.security.errormanagement.ManageErrorsMB.saveTaskFlow(ManageErrorsMB.java:213)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

    at java.lang.reflect.Method.invoke(Method.java:611)

    at com.sun.el.parser.AstValue.invoke (unknown Source)

    at com.sun.el.MethodExpressionImpl.invoke (unknown Source)

    at oracle.adf.controller.internal.util.ELInterfaceImpl.invokeMethod(ELInterfaceImpl.java:173)

    at oracle.adfinternal.controller.activity.MethodCallActivityLogic.execute(MethodCallActivityLogic.java:163)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.executeActivity(ControlFlowEngine.java:1035)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:926)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.doRouting(ControlFlowEngine.java:824)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.routeFromActivity(ControlFlowEngine.java:554)

    at oracle.adfinternal.controller.engine.ControlFlowEngine.performControlFlow(ControlFlowEngine.java:158)

    at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleAdfcNavigation(NavigationHandlerImpl.java:115)

    at oracle.adfinternal.controller.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:84)

    at org.apache.myfaces.trinidadinternal.application.NavigationHandlerImpl.handleNavigation(NavigationHandlerImpl.java:50)

    at com.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:130)

    at org.apache.myfaces.trinidad.component.UIXCommand.broadcast(UIXCommand.java:190)

    at org.apache.myfaces.trinidad.component.UIXCollection.broadcast(UIXCollection.java:157)

    at org.apache.myfaces.trinidad.component.UIXTable.broadcast(UIXTable.java:279)

    at oracle.adf.view.rich.component.UIXTable.broadcast(UIXTable.java:145)

    at oracle.adf.view.rich.component.rich.data.RichTable.broadcast(RichTable.java:479)

    at oracle.adf.view.rich.component.fragment.UIXRegion.broadcast(UIXRegion.java:159)

    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:130)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:461)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:134)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:112)

    to oracle.adf.view.rich.component.fragment.ContextSwitchingComponent$ 1.run(ContextSwitchingComponent.java:130)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent._processPhase(ContextSwitchingComponent.java:461)

    at oracle.adf.view.rich.component.fragment.ContextSwitchingComponent.broadcast(ContextSwitchingComponent.java:134)

    at oracle.adf.view.rich.component.fragment.UIXInclude.broadcast(UIXInclude.java:106)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.broadcastEvents(LifecycleImpl.java:1129)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl._executePhase(LifecycleImpl.java:353)

    at oracle.adfinternal.view.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:204)

    at javax.faces.webapp.FacesServlet.service(FacesServlet.java:312)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.adfinternal.view.faces.webapp.rich.RegistrationFilter.doFilter(RegistrationFilter.java:122)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:468)

    at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)

    to org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$ FilterListChain.doFilter (TrinidadFilterImpl.java:468)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl._doFilterImpl(TrinidadFilterImpl.java:293)

    at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl.doFilter(TrinidadFilterImpl.java:199)

    at org.apache.myfaces.trinidad.webapp.TrinidadFilter.doFilter(TrinidadFilter.java:92)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to oracle.security.jps.ee.http.JpsAbsFilter$ 1.run(JpsAbsFilter.java:111)

    at java.security.AccessController.doPrivileged(AccessController.java:284)

    at oracle.security.jps.util.JpsSubject.doAsPrivileged(JpsSubject.java:313)

    at oracle.security.jps.ee.util.JpsPlatformUtil.runJaasMode(JpsPlatformUtil.java:413)

    at oracle.security.jps.ee.http.JpsAbsFilter.runJaasMode(JpsAbsFilter.java:94)

    at oracle.security.jps.ee.http.JpsAbsFilter.doFilter(JpsAbsFilter.java:161)

    at oracle.security.jps.ee.http.JpsFilter.doFilter(JpsFilter.java:71)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at oracle.dms.servlet.DMSServletFilter.doFilter(DMSServletFilter.java:136)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    at weblogic.servlet.internal.RequestEventsFilter.doFilter(RequestEventsFilter.java:27)

    at weblogic.servlet.internal.FilterChainImpl.doFilter(FilterChainImpl.java:56)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.wrapRun (WebAppServletContext.java:3715)

    to weblogic.servlet.internal.WebAppServletContext$ ServletInvocationAction.run (WebAppServletContext.java:3681)

    at weblogic.security.acl.internal.AuthenticatedSubject.doAs(AuthenticatedSubject.java:321)

    at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:120)

    at weblogic.servlet.internal.WebAppServletContext.securedExecute(WebAppServletContext.java:2277)

    at weblogic.servlet.internal.WebAppServletContext.execute(WebAppServletContext.java:2183)

    at weblogic.servlet.internal.ServletRequestImpl.run(ServletRequestImpl.java:1454)

    at weblogic.work.ExecuteThread.execute(ExecuteThread.java:209)

    at weblogic.work.ExecuteThread.run(ExecuteThread.java:178)

    Caused by: java.sql.SQLException: connection has already been closed.

    at weblogic.jdbc.wrapper.PoolConnection.checkConnection(PoolConnection.java:58)

    at weblogic.jdbc.wrapper.Connection.preInvocationHandler(Connection.java:94)

    at weblogic.jdbc.wrapper.Connection.prepareCall(Connection.java:543)

    at oracle.adfinternal.controller.savepoint.SavePointDBPersistManager.insertSavePoint(SavePointDBPersistManager.java:221)

    at oracle.adfinternal.controller.savepoint.DBSavePointManagerImpl.storeSavePoint(DBSavePointManagerImpl.java:127)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.storeSavePoint(SavePointManagerImpl.java:301)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.createAndStoreSavePoint(SavePointManagerImpl.java:257)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.createSavePoint(SavePointManagerImpl.java:187)

    at oracle.adfinternal.controller.savepoint.SavePointManagerImpl.createSavePoint(SavePointManagerImpl.java:116)

    at view.security.errormanagement.ManageErrorsMB.saveTaskFlow(ManageErrorsMB.java:213)

    at sun.reflect.NativeMethodAccessorImpl.invoke0 (Native Method)

    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:60)

    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:37)

    at java.lang.reflect.Method.invoke(Method.java:611)

    At the bottom of the stack, this statement ""caused by: java.sql.SQLException: connection has already been closed. ' that intrigues me, but why this error occurs after a few days or after a particular number of connections or access to the application. "

    This same problem also happening in all environments including PROD. Help, please. JDeveloper version is 11.1.2.1.0.

    We got the support of Oracle solution.

    Passivation fails with the error "Connection has already been closed" in PoolConnection.checkConnection () (Doc ID 1330271.1). Problem is due to the grouping feature of connection for the Server WebLogic "timeout idle." When this is configured, WLS right out the strength of the connections in the pool. It is a problem for BC ADF based on maintaining the JDBC connection, associated with sound

    Instance of Module of the application.

    "Idle Session Timeout" value 0 (default), so that the JDBC connection remains active while

    the instance of the corresponding Application Module is active:

    Thank you...

  • How to manage batch inserts ADF 11 g?

    Hello

    I use JDev 11.1.1.2.0 with oracle 10g.

    I created a simple ADF form based on the continuous component associated with a single master table. I gave the same CRUD functionality.

    I even add button i.e. createInsert operation of the domain controller as well as delete, reset buttons. Further I have provided the "submit" button that has "committed" operation which are linked to him.
    Correct me on my understanding is as follows.

    When the user clicks on the button "add".
    1. my model will be updated with a blank record to the side server.
    2. the user will fill in the various fields available

    User follow the 2 steps above for several times and click on the "submit" button. This will save all records created by the user at one time. I have a few questions
    1. can I prevent a full restore if there is an error in a folder?
    2. is it possible to provide the user with a pop-up message if he or she skips OR closes the screen without clicking "submit"?

    Pls explain step-by-step if possible because I'm new to this format development and coding. Same links explaining the stages will be fine.

    Thanks in advance.

    User,

    Forget the ADF for a moment, to describe how the user interface would work for such a scenario? How do you even show the user steps to cancel? I can't think of a single web application that I used that offers this feature. same office that offer a similar capability (cancellation multi-level think MS Word) don't allow you to 'dismantling' at some point, no choice and choose which steps to cancel.

    As Timo and I said, you write this functionality yourself, such as ADF not in offer not out-of-the-box.

    John

  • ADF fire Insert statement for an update in adf Table

    Hello

    I use Jdeveloper 11.1.2.3.0.

    I have a modifiable on a jsf page table and a button OK to save the changes.

    I replaced the method of doDML in entityImpl just to print if INSERT/UPDATE/DELETE is issued.

    protected void doDML (int i, TransactionEvent transactionEvent) {}

    System.out.println ("Transaction events:" + i);

    super.doDML (i, transactionEvent);

    }

    When I changed to a column value in the table and click validation, the value is 2 (DML_UPDATE) when I run my built-in weblogic server.

    But when I run the application of stand-alone server, the value is 1 (DML_INSERT) and do not display data, below the message belongs.

    Looks like a very strange behavior.

    Can anyone suggest how to get rid of this problem?

    Transaction events: 1

    < 18 July 2013 22:09:35 this > < error > < xxxxxx. XXXXXXBean > < BEA-000000 > < oracle.jbo.DMLException: Houston-26041: failure to publish data from database in "Insert": SQL statement ' INSERT INTO APPS. Table_name (UPDATED_COLUMN_NAME) VALUES (: 1) "." >

    < 18 July 2013 22:09:35 this > < WARNING > < oracle.adf.controller.faces.lifecycle.Utils > < BEA-000000 > < ADF: addition of the JSF error message: ORA-01400: cannot insert NULL into ('APPS'. "" TABLE_NAME ". ("' FIRST_NOT_NULL_COLUMN")

    java.sql.SQLIntegrityConstraintViolationException: ORA-01400: cannot insert NULL into ('APPS'. "" TABLE_NAME ". ("' FIRST_NOT_NULL_COLUMN")

    Thank you

    Vinod

    The problem is with the primary key used in my OE.

    In my production DB primary key column I used in OT is filled in with the value NULL because it is not marked as PRIMARY KEY in the table.

    ADF BC could not find the primary key update is why trying to insert into the table. After update of the primary key for the database, the problem is resolved.

  • Batch insert filename in textpath script blocks Illustrator

    Hello world!

    First: I'm not a programmer. Just play with the code and trying to make it work for a specific task:

    Here is a script for the purpose of inserting a text specifying the file name in more than 600 files pdf. This is supposed to work on all the files in a selected folder.

    The problem: Illustrator crashes.

    A first test code worked but after a few files published Illustrator crashed, so I tried to introduce a delay after each registered in order to slow down the batch.

    $.setTimeout (function () {sourceDoc.close (SaveOptions.SAVECHANGES)}, 1000);

    Unfortunately, I have not saved the work (work almost ) first to test the code.

    No idea what to do next. The code works if I remove this line: sourceDoc.close (SaveOptions.SAVECHANGES);

    Here's the complete script:

    var destFolder, sourceFolder, files, fileType, sourceDoc, layers, writeText, finLabel;
    
    // Select the source folder.
    sourceFolder = Folder.selectDialog( 'Select the folder with Illustrator files you want to convert to PNG', '~' );
    
    // If a valid folder is selected
    if ( sourceFolder != null )
    {
    files = new Array();
    fileType = prompt( 'Select type of Illustrator files to you want to process. Eg: *.ai', '*.pdf' );
    
    // Get all files matching the pattern
    files = sourceFolder.getFiles( fileType );
    
    if ( files.length > 0 )
    for ( i = 0; i < files.length; i++ )
    {
        sourceDoc = app.open(files[i]); // returns the document object
        layers = unlock();
        writeText = getFilename();
        finLabel = remText();
        sourceDoc.close(SaveOptions.SAVECHANGES);   //if save command line is deleted the code works   WTF???
        $.setTimeout(function () {sourceDoc.close(SaveOptions.SAVECHANGES)}, 1000); // still crashes using delay ...
    }
    //alert( 'Files are saved as PNG in ' + destFolder );
    
    else
    {
    alert( 'No matching files found' );
    }
    }
    
    function unlock()
    {
       //get the total number of layers in the active document
    doc = app.activeDocument;
    var totalLayers = doc.layers.length;
    
    //looping on layers to create one artboard per layer
    for ( var i = 0 ; i < totalLayers ; i++){
        
        var currentLayer = doc.layers[i];
        
        //We don't want to deal with hidden layers
        if(currentLayer.visible == false) continue;
        
        //Unlock the layer if needed
        currentLayer.locked = false;
    
    }
        }
    
    function getFilename()
    {
    // Write text
    var pointTextRef = app.activeDocument.textFrames.add();
    pointTextRef.contents = app.activeDocument.name + "\n" + "YBS";
    pointTextRef.top = 0;
    pointTextRef.left = 0;
    app.activeDocument.textFrames[0].textRange.characterAttributes.textFont=app.textFonts[31];
        
        }
    
    function remText()
    {
    // This works for search and replace :))))))
    
        var active_doc = app.activeDocument;  
          
        var search_string = /_Template.pdf/gi; // g for global search, remove i to make a case sensitive search  
        var replace_string = '';  
          
        var text_frames = active_doc.textFrames;  
          
        if (text_frames.length > 0)  
        {  
            for (var i = 0 ; i < text_frames.length; i++)  
              {  
                  var this_text_frame = text_frames[i];  
                   var new_string = this_text_frame.contents.replace(search_string, replace_string);  
                     
                   if (new_string != this_text_frame.contents)  
                       {  
                            this_text_frame.contents = new_string;  
                       }  
              }  
        }      
     }
    

    Any ideas on what makes Illustrator plant them?

    Note: The application crashes after opening the first file.

    Thanks for helping out!

    the timeout function, that you added is not supported by extendScript,

    your script works well with a few files tested, the problem might be on the large number of files, 600 seems a little too much for illustrator. Re start illustrator, do a little at a time, enough as to not illustrator crash, re - start illustrator... Rinse, repeat.

  • BATCH inserts

    Hello
    9i, a batch is running to isert 25000 lines in a table.
    Of course, you can not see them before final validation.
    Is it possible to see if it is going and how many lines is already inserted?

    Thank you.

    Looking for v$ session_longops. I think that will tell you various operations that run for more than 6 seconds (in absolute time).
    http://docs.Oracle.com/CD/B10501_01/server.920/a96536/ch3175.htm#1123208

    Another good note to the link below:
    http://www.gplivna.EU/papers/v $session_longops.htm

    Concerning
    Girish Sharma

  • ADF Mobile: Insert a record into a table by WS - DC method

    It's something that is very basic and I could not know.

    There is this method of 'create' base on the service project to insert a single record in a table.

    I created a WS - DC on my mobile project. I see my createItem on the list method. But what I have this XItem.xsd.

    So when I get the ValueExpression binding, I don't know how to set the attribute values...

    ValueExpression ve = AdfmfJavaUtilities.getValueExpression ("#{bindings.xItemView1.inputValue}", Object.class);

    PS: GenericType does not work.

    Your service must expose a method create and then you drag this method to your page and call it with an object as a parameter.
    Should be similar to the way in which an update is done here:
    https://blogs.Oracle.com/Shay/entry/adf_mobile_update_through_web

  • Operation with ADF of insertion.

    Hello

    I have this situation:
    -J' have created a table (table of trinidad) with a unique selection and created a button to view the details of the row that the user will choose
    -On the next page I view details, but in this page I want to create a butto to insert a new data of the other display object that uses data of the selected line and data in the user's session.

    How can I do this?

    Thanks in advance.

    Yes this should be possible as well... the createwithParams would be something like #{row.bindings.Product.ProductId} and an expression to get the session ID when it is called from a link.

  • How to automate batch insertion?

    Help me create the batch automate! I want to bug a logo on multi images, preparation for a Web site

    Hello!

    Here are some useful videos on how to automate the batch:

    Please let us know if you have more questions,

    Janelle

  • A kind of Batch Insert

    I need to make a special insert, which will insert a lot of information (lines Millon), so I want to do in some regions, monthly and automatically, because I'm going to put this procedure to run at night.

    What I need is a slider that could travel period by period, like this:

    Insert into une_table
    Select some_fields
    from another_table
    where date_field = 199901

    Insert into une_table
    Select some_fields
    from another_table
    where date_field = 199902


    Insert into une_table
    Select some_fields
    from another_table
    where date_field = 199903
    -... and so on...

    But I would do this automatically, in a cursor, or something like that.
    Is there anyone that could help me please?

    Thank you.

    The version I use is 9.2.0.8.0 Oracle.

    Suppose that you want to transfer, 1999 and 2000 (both 12 months).

    begin
      for year in 1999..2000
      loop
        for month in 1..12
        loop
          insert into some_table
          select some_fields
          from another_table
          where date_field = to_char(year)||lpad(to_char(month),2,'0');
          commit; -- ?
        end loop;
      end loop;
    end;
    /
    

    Not test the lpad...

  • How to remove a line empty without validation error in ADF Table (EMP)

    Hello world

    I use the EMP Table in page jspx ADF to insert data into database.when, I insert a line in the table by createInsert operation, it the insertion of the line. But I need to remove that line immediately with enter them any value.

    But it displays a validation to empno error. Y at - it means to remove the empty line? If not, what are the reasons that we cannot remove the line.

    could someone tell me why!

    Thanks in advance!


    Kind regards
    Amar

    Published by: 973755 on December 11, 2012 06:42

    Amar,

    I'm a bit confused with your logic here...

    But if you try to delete the row by clicking the button Delete you can set the immediate property to true, this function of deletion will take place without performing any validation of the entity...

    R

  • LISTAGG and DBMS_SQL

    Oracle 11 g 2

    It is a check-in process. MY_TAB is the source table and MY_TAB_ARC is the check-in table. MY_TAB_ARC has two additional columns - dt_archived and remarks.

    Currently, these columns are the last columns of the table of check-in, but there is no guarantee of this. Because you can add new columns in the source table in the future.

    create table my_tab
    ( id    number ,
      list  varchar2(50) 
    )
    /
    
    create table my_tab_arc
    ( id    number ,
      list  varchar2(50) ,
      dt_archived date   ,
      remarks     varchar2(255)
    )
    /
    
    insert into my_tab values(1,'abc')
    /
    
    insert into my_tab values(2,'xyz')
    /
    
    insert into my_tab values(3,'123')
    /
    
    commit;
    
    set serveroutput on
    
    declare
       v_query varchar2(4000);
       c_arc_cur       integer ;
       v_tbl_arc varchar2(61) := 'my_tab_arc';
       v_tbl_src varchar2(61) := 'my_tab';
       v_columnOutput  varchar2(4000);
       v_columnValue   varchar2(4000);
       v_status        integer;
       v_col_cnt       number default 0;
       v_separator     varchar2(3) := '';
       v_insert varchar2(4000);
       v_colDesc       dbms_sql.DESC_TAB;
    begin
       v_query :=
      'with data
      as (
      select listagg(trgt.column_name,'','') within group (order by trgt.column_id) tab_columns
       from user_tab_cols  src  
       inner join user_tab_cols trgt
         on trgt.table_name = src.table_name'||'||''_ARC'''||' 
        and src.column_name = trgt.column_name
        where src.table_name = ''MY_TAB'' 
        and trgt.table_name = ''MY_TAB_ARC''
      )
      select d.* ' || ',sysdate,' || '''archived''
      from data d' ;
    
        c_arc_cur     := dbms_sql.open_cursor ;
        dbms_sql.parse( c_arc_cur, v_query, dbms_sql.native );
        
        FOR  i  IN  1 .. v_col_cnt
        LOOP
             dbms_sql.define_column( c_arc_cur, i, v_columnValue, 4000 ) ;
        END LOOP ;
        
        v_status := dbms_sql.execute(c_arc_cur) ;
        dbms_sql.describe_columns(c_arc_cur,v_col_cnt, v_colDesc) ;
        
        FOR i IN 1..v_col_cnt
        LOOP
           v_columnOutput := v_columnOutput || v_separator || Upper(v_colDesc(i).col_name);
           v_separator := ',' || chr(10);
        END LOOP ;
        
        v_columnOutput := TRIM(leading ',' from v_columnOutput);
        
        v_insert  := 'INSERT INTO ' || v_tbl_arc || ' SELECT ' ;
        
        v_insert := v_insert || v_columnOutput || chr(10) || ' FROM ' || v_tbl_src ||
                    ' WHERE content_id = :B1' ;
                    
        dbms_sql.close_cursor(c_arc_cur);
        
        dbms_output.put_line(v_query);
        
        -- verify insert statement is correct
        dbms_output.put_line(v_insert);
        
        EXCEPTION
            when others then
               RAISE ;
    end ;
    /
    
    OUTPUT:
    
    with data
            as (
            select listagg(trgt.column_name,',') within group (order by trgt.column_id) tab_columns
              from
    user_tab_cols  src
              inner join user_tab_cols trgt
                on trgt.table_name = src.table_name||'_ARC'
               and src.column_name
    = trgt.column_name
               where src.table_name = 'MY_TAB'
               and trgt.table_name = 'MY_TAB_ARC'
            )
            select d.*
    ,sysdate,'archived'
            from data d
            
    INSERT INTO my_tab_arc SELECT TAB_COLUMNS,
    SYSDATE,
    'ARCHIVED'
     FROM my_tab WHERE content_id = :B1
    
    
    
    
    

    The insert statement has the alias TAB_COLUMNS, not the real column names.

    Am I missing something here? Or you cannot use LISTAGG in DBMS_SQL?

    I say knock yourself out.

    Dynamic SQL has its place.

    I have it would probably become a procedure you want to call it.

    Things that you can examine and possibly already have:

    This does not cover a deletion, nor is there follow-up to what has or has not been archived.

    Depending on the size, link in bulk and batch inserts may need to be worked in code similar to this one. (Yes, she gets more complicated)

    Make sure you have no constraints on your table to archive. (unless you want to build in the error handling)

    I have built in error management then it throws an exception when a column has not yet been added to the table to archive.

    You can write code to add columns to your table to automatically archive, but I just wanted to show that what you want is possible.

    You a little too much code, but you were close.

    declare
    v_source_table varchar2(30) := 'MY_TAB';
    v_id_to_archive number := 1;
    v_destination_table varchar2(30);
    v_verify_cols varchar2(4000);
    tab_columns varchar2(4000);
    v_sql clob;
    begin
    
    v_destination_table := v_source_table||'_ARC';
    
    select listagg(src.column_name,',') within group (order by src.column_id) tab_columns into v_verify_cols
      from user_tab_cols src
    where not exists (select 1 from user_tab_cols trgt
    where trgt.table_name = src.table_name||'_ARC'
       and src.column_name = trgt.column_name)
       and table_name = v_source_table;
    
    if v_verify_cols is not null
      then raise_application_error(-20001,'Columns Missing In Archive Table: '||v_verify_cols);
    end if;
    
    select listagg(trgt.column_name,',') within group (order by trgt.column_id) into tab_columns
       from user_tab_cols  src
       inner join user_tab_cols trgt
         on trgt.table_name = src.table_name||'_ARC'
        and src.column_name = trgt.column_name
        where src.table_name = v_source_table
        and trgt.table_name = v_destination_table
        and trgt.virtual_column = 'NO';
    
    v_sql := 'insert into '||v_destination_table||' ('||tab_columns||',dt_archived,remarks)
    select '||tab_columns||',sysdate,''ARCHIVED'' from '||v_source_table||' where id = :id';
    
    dbms_output.put_line(v_sql);
    
    execute immediate v_sql using v_id_to_archive;
    commit;
    
    end;
    /
    

    PL/SQL procedure successfully completed.

    insert into MY_TAB_ARC (ID, LIST, dt_archived, remarks)

    SELECT ID, LIST, sysdate, 'ARCHIVED' from MY_TAB where id =: id

    ID LIST DT_ARCHIVED REMARKS
    1 ABC 2015-07-07 19:07:02 ARCHIVED

    Table deleted MY_TAB_ARC.

    create table my_tab_arc
    ( id    number ,
      dt_archived date   ,
      remarks     varchar2(255)
    );
    

    Run the block again.

    Error report-

    ORA-20001: missing columns in Archive Table: LIST

    ORA-06512: at line 20

  • log file sync wait

    Hello world

    DB 11.2.0.1 - hearts 32 - 64 GB of RAM

    I have a database of 1.5 million records are inserting all hours into it. This database is suffering too log sync wait. Googling the question I found that the reason is the way enforcement is the insertion of data in the database that has an insert preceded a commit after each of them. Currently, we are unable to change the method of insertion to use batch inserts instead. The number of files in the database redolog is 22 each of size 200 MB and the log_buffer is about 150 MB.

    is there a solution to reduce the number of log file sync waits?

    I tried to increase the size of log file to roll forward to 700 MB of each, but there was once some claim buffer waits. the SGA is 38 GB.

    Thanks for any guidance

    concerning

    You could try commit year writing setting method. In the example here,.

    One of the ways to eliminate the log_file_sync awaits

    I eliminate log file sync.

  • GoldenGate transactional order of validation

    We have a GoldenGate replicat installer that uses batch inserts to load data. We would like to change this replicat to use the same order of validation as the source applications instead of having an independent validation number. Anyone know if it is possible to configure goldenGate to use the same frequency of posting as transactions of sources?

    Try this:

    GROUPTRANSOPS 1

    By default it is set to 1000, which helps out a lot in performance for single operation operations (or a small number in the game where there are a lot of games). If you have 999 operations and then nothing for a while don't worry; It does not crash. It will make based on the time-out of CHECKPOINTSECS (10 seconds by default).

    Good luck
    -joe

Maybe you are looking for