Unable to INSERT PL/SQL  record with EXECUTE IMMEDIATE

Hi All,
I am selecting data from a source table and after some modification inserting into a target table. Source and target table name are available at run time. You can say only source table structure is fixed.
I have crated a pl/sql table of type source record and inserting record by record in target table using execute immediate. But I am not able to write
EXECUTE IMMEDIATE string USING pl_sql_table(index); and getting error as
PLS-00457: expressions have to be of SQL types
Please see the part of code below. Is it possible to use FORALL with dynamic sql like
FORALL pl_sql_table.FIRST .. pl_sql_table.COUNT
EXECUTE IMMEDIATE .... pl_sql_table(j); -- Like this.
Please suggest why I am not able to write record here. I also want to replace 'INSERT in a loop' with a single INSERT statement out of the loop, to upload whole pl_sql table into target table in one go.
Thanks,
Ravi
DECLARE
    TYPE rec_tab_CMP IS RECORD
     model_id          NUMBER(38),   
     absolute_rank          NUMBER(5)         
    v_rec_tab_CMP  rec_tab_CMP;
    TYPE t_rec_tab_CMP IS TABLE OF v_rec_tab_CMP%TYPE INDEX BY BINARY_INTEGER;
    v_records_CMP               t_rec_tab_CMP;
    rc                          SYS_REFCURSOR;
    v_old_table_name            VARCHAR2(30); -- passed from parameter 
    v_new_table_name            VARCHAR2(30); -- passed from parameter 
    dyn_str                     VARCHAR2(500);
    v_columns_str               VARCHAR2(200) := ' model_id, absolute_rank ';
BEGIN
       EXECUTE IMMEDIATE 'CREATE TABLE '|| v_new_table_name || ' AS SELECT * FROM ' || v_old_table_name ||' WHERE 1 = 2 ' ;
     OPEN rc FOR 'SELECT '|| v_columns_str ||' FROM '|| v_old_table_name;
     FETCH rc BULK COLLECT INTO v_records_CMP;
     FOR j IN 1..v_records_CMP.COUNT
     LOOP
        v_records_CMP(j).model_id := 1; -- Do someting here, This thing can be performed in SQL stmt directly.
        dyn_str := 'INSERT INTO '|| v_new_table_name ||' ( '|| v_columns_str || ' ) VALUES (:1, :2) ';
        EXECUTE IMMEDIATE dyn_str USING v_records_CMP(j).model_id          ,
                            v_records_CMP(j).absolute_rank     ;
     -- Here in place of two columns I want to use one record like
     -- EXECUTE IMMEDIATE dyn_str USING v_records_CMP(j);
     -- But it is giving me error like
        --          EXECUTE IMMEDIATE dyn_str USING v_records_st(j);
        --   PLS-00457: expressions have to be of SQL types
     END LOOP;
     CLOSE rc;
END;
/

You cannot bind PL/SQL record types to dynamic SQL.
Possibly you could work around this by declaring the INDEX-BY table of records at package specification level, e.g.
Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
SQL> CREATE PACKAGE package_name
  2  AS
  3     TYPE tt_emp IS TABLE OF emp%ROWTYPE;
  4     t_emp tt_emp;
  5  END package_name;
  6  /
Package created.
SQL> CREATE TABLE new_emp
  2  AS
  3     SELECT *
  4     FROM   emp
  5     WHERE  1 = 0;
Table created.
SQL> DECLARE
  2     v_table_name user_tables.table_name%TYPE := 'NEW_EMP';
  3  BEGIN
  4     SELECT *
  5     BULK COLLECT INTO package_name.t_emp
  6     FROM   emp;
  7
  8     EXECUTE IMMEDIATE
  9        'BEGIN ' ||
10        '   FORALL i IN 1 ..package_name.t_emp.COUNT ' ||
11        '      INSERT INTO ' || v_table_name ||
12        '      VALUES package_name.t_emp (i); ' ||
13        'END;';
14  END;
15  /
PL/SQL procedure successfully completed.
SQL> SELECT empno, ename
  2  FROM   new_emp;
     EMPNO ENAME
      7369 SMITH
      7499 ALLEN
      7521 WARD
      7566 JONES
      7654 MARTIN
      7698 BLAKE
      7782 CLARK
      7788 SCOTT
      7839 KING
      7844 TURNER
      7876 ADAMS
      7900 JAMES
      7902 FORD
      7934 MILLER
14 rows selected.
SQL>

Similar Messages

  • Can't create a sequence within a pl/sql block with execute immediate.

    Hi All. I created a user and granted it the 'create sequence' privilege though a role. In a pl/sql block I try to create a sequence using 'execute immediate' but get a 1031-insufficient privileges error. If I grant create sequence directly to the user, the pl/sql block completes successfully. Can anyone explain this behavior? We're running 11.2 Enterprise Editon.
    Thanks,
    Mark

    In a definer's rights stored procedure (the default), you only have access to privileges that have been granted directly, not via a role.
    There are two basic reasons for that. First, roles can be enabled or disabled, default and non-default, password-protected, etc. so the set of roles a particular user actually has is session-specific. Oracle needs to know at compile time what privileges the owner of the procedure has. The only way to do that (without deferring the privilege check) is to ignore privileges granted through roles.
    Second, since 99% of privilege management DBAs do involves granting and revoking roles, it's helpful that changing role privileges will never cause objects to be marked invalid and recompiled which can have side-effects on applications. DBAs only need to worry about causing problems on those rare cases where they are granting or revoking direct privileges to users.
    You can create an invoker's rights stored procedure by adding the clause (AUTHID CURRENT_USER). That defer's the security check to run-time but allows the procedure to see privileges granted through roles in the current session. But that means that the caller of the procedure would need to have the CREATE SEQUENCE privilege through the role, not the owner of the procedure.
    And just to make the point, dynamic object creation in PL/SQL is almost always a red flag that there is something problematic in your design. If you are creating sequences dynamically, that means that you'd have to refer to them dynamically throughout your code which means that your inserts would need to use dynamic SQL. That's not a particularly easy or safe way to develop code.
    Justin

  • Error: Unable to insert new audit record for auditee 21 in repository UPA..

    Hi,
    I've got the error message below. Have you ever got this?
    DEBUG [ACTIVE] ExecuteThread: '18' for queue: 'weblogic.kernel.Default (self-tuning)' XELLERATE.DATABASE - insert into UPA (UPA_KEY,usr_key,EFF_FROM_DATE,SRC,SNAPSHOT,DELTAS) values (?,?,?,?,?,?)
    DEBUG [ACTIVE] ExecuteThread: '18' for queue: 'weblogic.kernel.Default (self-tuning)' XELLERATE.DATABASE - select UPA_seq.nextval from dual
    ERROR [ACTIVE] ExecuteThread: '18' for queue: 'weblogic.kernel.Default (self-tuning)' XELLERATE.DATABASE - Class/Method: tcDataBase/writeStatement encounter some problems: ORA-01461: can bind a LONG value only for insert into a LONG column
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:947)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3462)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1349)
         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:159)
         at com.thortech.xl.dataaccess.tcDataBase.writePreparedStatement(Unknown Source)
         at com.thortech.xl.dataobj.PreparedStatementUtil.executeUpdate(Unknown Source)
         at com.thortech.xl.audit.genericauditor.utils.AuditDataHandler.write(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.updateAuditRecords(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.genericauditor.GenericAuditor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processSingleAudJmsEntry(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processOfflineNew(Unknown Source)
         at com.thortech.xl.audit.engine.jms.XLAuditMessageHandler.execute(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.MessageProcessUtil.processMessage(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.AuditMessageHandlerMDB.onMessage(Unknown Source)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
         at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
         at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    ERROR [ACTIVE] ExecuteThread: '18' for queue: 'weblogic.kernel.Default (self-tuning)' XELLERATE.AUDITOR - Failed to process audit message
    com.thortech.xl.audit.exceptions.AuditMsgProcessingFailedException: Unable to insert new audit record for auditee 21 in repository UPA
    sert statement failed is: insert into UPA (UPA_KEY,usr_key,EFF_FROM_DATE,SRC,SNAPSHOT,DELTAS) values (?,?,?,?,?,?)
    auditRepository=UPA_KEY; auditeeID=21
    auditEpoch=2009-09-05 15:58:37.284; source=User: USER.TEST, API: com.thortech.xl.ejb.beansimpl.tcProvisioningOperationsBean, Method: updateTask
         at com.thortech.xl.audit.genericauditor.utils.AuditDataHandler.write(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.updateAuditRecords(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.genericauditor.GenericAuditor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processSingleAudJmsEntry(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processOfflineNew(Unknown Source)
         at com.thortech.xl.audit.engine.jms.XLAuditMessageHandler.execute(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.MessageProcessUtil.processMessage(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.AuditMessageHandlerMDB.onMessage(Unknown Source)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
         at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
         at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by [Nested Exception]:
    com.thortech.xl.orb.dataaccess.tcDataAccessException
         at com.thortech.xl.dataaccess.tcDataAccessExceptionUtil.createException(Unknown Source)
         at com.thortech.xl.dataaccess.tcDataBase.createException(Unknown Source)
         at com.thortech.xl.dataaccess.tcDataBase.writePreparedStatement(Unknown Source)
         at com.thortech.xl.dataobj.PreparedStatementUtil.executeUpdate(Unknown Source)
         at com.thortech.xl.audit.genericauditor.utils.AuditDataHandler.write(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.updateAuditRecords(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.genericauditor.GenericAuditor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processSingleAudJmsEntry(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processOfflineNew(Unknown Source)
         at com.thortech.xl.audit.engine.jms.XLAuditMessageHandler.execute(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.MessageProcessUtil.processMessage(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.AuditMessageHandlerMDB.onMessage(Unknown Source)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
         at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
         at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
    Caused by [Nested Exception]:
    java.sql.SQLException: ORA-01461: can bind a LONG value only for insert into a LONG column
         at oracle.jdbc.driver.SQLStateMapping.newSQLException(SQLStateMapping.java:70)
         at oracle.jdbc.driver.DatabaseError.newSQLException(DatabaseError.java:112)
         at oracle.jdbc.driver.DatabaseError.throwSqlException(DatabaseError.java:173)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:455)
         at oracle.jdbc.driver.T4CTTIoer.processError(T4CTTIoer.java:413)
         at oracle.jdbc.driver.T4C8Oall.receive(T4C8Oall.java:1030)
         at oracle.jdbc.driver.T4CPreparedStatement.doOall8(T4CPreparedStatement.java:194)
         at oracle.jdbc.driver.T4CPreparedStatement.executeForRows(T4CPreparedStatement.java:947)
         at oracle.jdbc.driver.OracleStatement.doExecuteWithTimeout(OracleStatement.java:1222)
         at oracle.jdbc.driver.OraclePreparedStatement.executeInternal(OraclePreparedStatement.java:3381)
         at oracle.jdbc.driver.OraclePreparedStatement.executeUpdate(OraclePreparedStatement.java:3462)
         at oracle.jdbc.driver.OraclePreparedStatementWrapper.executeUpdate(OraclePreparedStatementWrapper.java:1349)
         at weblogic.jdbc.wrapper.PreparedStatement.executeUpdate(PreparedStatement.java:159)
         at com.thortech.xl.dataaccess.tcDataBase.writePreparedStatement(Unknown Source)
         at com.thortech.xl.dataobj.PreparedStatementUtil.executeUpdate(Unknown Source)
         at com.thortech.xl.audit.genericauditor.utils.AuditDataHandler.write(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.updateAuditRecords(Unknown Source)
         at com.thortech.xl.audit.genericauditor.AuditMessageProcessor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.genericauditor.GenericAuditor.processAuditMessage(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processSingleAudJmsEntry(Unknown Source)
         at com.thortech.xl.audit.engine.AuditEngine.processOfflineNew(Unknown Source)
         at com.thortech.xl.audit.engine.jms.XLAuditMessageHandler.execute(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.MessageProcessUtil.processMessage(Unknown Source)
         at com.thortech.xl.schedule.jms.messagehandler.AuditMessageHandlerMDB.onMessage(Unknown Source)
         at weblogic.ejb.container.internal.MDListener.execute(MDListener.java:466)
         at weblogic.ejb.container.internal.MDListener.transactionalOnMessage(MDListener.java:371)
         at weblogic.ejb.container.internal.MDListener.onMessage(MDListener.java:327)
         at weblogic.jms.client.JMSSession.onMessage(JMSSession.java:4547)
         at weblogic.jms.client.JMSSession.execute(JMSSession.java:4233)
         at weblogic.jms.client.JMSSession.executeMessage(JMSSession.java:3709)
         at weblogic.jms.client.JMSSession.access$000(JMSSession.java:114)
         at weblogic.jms.client.JMSSession$UseForRunnable.run(JMSSession.java:5058)
         at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTuningWorkManagerImpl.java:516)
         at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
         at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)

    Hello Peter:
    Thanks! I tried to input two detail records and still get only one error.
    I don't have pre/post trigger in my form. I use WHEN_BUTTON_PRESSED trigger with the following code:
    if get_block_property('PARENT_DATA',status) = 'CHANGED' or
    get_block_property('DETAIL_DATA',status) in ('CHANGED') then
    COMMIT;
    I also try File -> Save. It does not work either.
    Do I need to pre/and post trigger to check for it? If so, please show me how.
    Thanks again,
    TD

  • Oracle.adfinternal.controller.savepoint.SavePointException: ADFC-08008: The ADF Controller is unable to insert a savepoint record for ID

    I implemented a save point in a task flow by creating a save point in a method action The following is the code from managed bean for creating the save point:
                 ControllerContext cc = ControllerContext.getInstance();
    if (cc != null) {
    SavePointManager mgr = cc.getSavePointManager();
    if (mgr != null) {
    String id = mgr.createSavePoint();
    savePointId = id;
    It worked fine in local (Integrated Weblogic server). It also worked fine initially when I deployed the changes to the DEV weblogic server. But after a couple of days, in DEV server I get the following error everytime when trying to create a save point:
    Caused By: oracle.adfinternal.controller.savepoint.SavePointException: ADFC-08008: The ADF Controller is unable to insert a savepoint record for ID '4d233555-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)
            at 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)
            at 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)
            at org.apache.myfaces.trinidadinternal.webapp.TrinidadFilterImpl$FilterListChain.doFilter(TrinidadFilterImpl.java:468)
            at oracle.adfinternal.view.faces.activedata.AdsFilter.doFilter(AdsFilter.java:60)
            at 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)
            at 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)
            at weblogic.servlet.internal.WebAppServletContext$ServletInvocationAction.wrapRun(WebAppServletContext.java:3715)
            at 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." intrigues me, but why this error occurs after a couple of days or after particular number of connections or access to the application.
    This same issue is also happening in all environments including PROD. Please help. JDeveloper version used is 11.1.2.1.0.

    We got the solution from Oracle support. 
    Passivation Fails With Error "Connection has already been closed" in PoolConnection.checkConnection() (Doc ID 1330271.1). Problem is caused by the WebLogic Server Connection Pool feature "Inactive Connection Timeout". When this parameter is set up, WLS will forcibly release reserved connections back into the pool. This is a problem for ADF BC that relies on keeping the JDBC connection associated to its
    Application Module instance.
    Set the "Inactive Timeout Session" to 0 (default), so that the JDBC connection stays active while
    the corresponding Application Module instance is active:
    Thanks....

  • Difference between regular update and update with execute immediate

    Hi everyone, I have seen some code where developers have executed insert and update statement using execute immediate.
    for example :
    execute immediate ('Update employees set employee_salary = :x');
    I can update record using the following statement where x is a number (salary)
    update employee
    set employee_salary = x;
    It works fine as well
    Whats the difference? and what way is recommended
    Thanks

    My guess is that sqlplus does a commit on exit:
    In session 1:
    SQL> create table test (col1 number);
    Table created.
    SQL> begin
      2    execute immediate 'insert into test values (1)';
      3  end;
      4  /
    PL/SQL procedure successfully completed.In session 2:
    SQL> select * from test;
    no rows selectedIn session 1:
    SQL> exec execute immediate 'insert into test values (2)';
    PL/SQL procedure successfully completed.In session 2:
    SQL> select * from test;
    no rows selectedIn session 1:
    SQL> disconnect
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - 64bit Production
    With the Partitioning, Oracle Label Security, OLAP and Data Mining optionsIn session 2:
    SQL> select * from test;
          COL1
             1
             2

  • Pipelined Function with execute immediate

    Hello Experts,
    I have created a Pipe lined function with execute immediate, due to below requirement;
    1) Columns in where clause is passed dynamically.
    2) I want to know the data stored into above dynamic columns.
    3) I want to use it in report, so I don't want to insert it into a table.
    I have created a TYPE, then through execute immediate i have got the query and result of that query will be stored in TYPE.
    But when calling the function i am getting
    ORA-00932: inconsistent datatypes: expected - got -
    Below is my function and type, let me know i am going wrong, and is my logic correct.
    CREATE OR REPLACE TYPE OBJ_FPD AS OBJECT
                      (LOW_PLAN_NO VARCHAR2 (40),
                       FPD VARCHAR2 (5),
                       SERIAL_NO NUMBER,
                       CEDIA_CODE VARCHAR2 (2),
                       DT DATE);
    CREATE OR REPLACE TYPE FPD_TBL_TYPE AS TABLE OF OBJ_FPD;
    CREATE OR REPLACE FUNCTION FUNC_GET_FPD_DATE (P_LOW_PLAN_NO    VARCHAR2,
                                                  P_CEDIA_CODE     VARCHAR2,
                                                  P_SERIAL_NO      NUMBER)
       RETURN FPD_TBL_TYPE
       PIPELINED
    AS
       CURSOR C1
       IS
              SELECT 'FPD' || LEVEL TBL_COL
                FROM DUAL
          CONNECT BY LEVEL <= 31;
       V_STR        VARCHAR2 (5000);
       V_TBL_TYPE   FPD_TBL_TYPE;
    BEGIN
       FOR X IN C1
       LOOP
          V_STR :=
                'SELECT A.low_PLAN_NO,
               A.FPD,
               A.SERIAL_NO,
               A.cedia_code,
               TO_DATE (
                     SUBSTR (FPD, 4, 5)
                  || ''/''
                  || TO_CHAR (C.low_PLAN_PERIOD_FROM, ''MM'')
                  || ''/''
                  || TO_CHAR (C.low_PLAN_PERIOD_FROM, ''RRRR''),
                  ''DD/MM/RRRR'')
                  DT FROM ( SELECT low_PLAN_NO, '
             || ''''
             || X.TBL_COL
             || ''''
             || ' FPD, '
             || X.TBL_COL
             || ' SPTS, SERIAL_NO, cedia_code FROM M_low_PLAN_DETAILS WHERE NVL('
             || X.TBL_COL
             || ',0) > 0 AND SERIAL_NO = '
             || P_SERIAL_NO
             || ' AND cedia_code = '
             || ''''
             || P_CEDIA_CODE
             || ''''
             || ' AND low_PLAN_NO = '
             || ''''
             || P_LOW_PLAN_NO
             || ''''
             || ') A,
               M_low_PLAN_DETAILS B,
               M_low_PLAN_MSTR C
         WHERE     A.low_PLAN_NO = B.low_PLAN_NO
               AND A.cedia_code = B.cedia_code
               AND A.SERIAL_NO = B.SERIAL_NO
               AND B.low_PLAN_NO = C.low_PLAN_NO
               AND B.CLIENT_CODE = C.CLIENT_CODE
               AND B.VARIANT_CODE = C.VARIANT_CODE
    CONNECT BY LEVEL <= SPTS';
          EXECUTE IMMEDIATE V_STR INTO V_TBL_TYPE;
          FOR I IN 1 .. V_TBL_TYPE.COUNT
          LOOP
             PIPE ROW (OBJ_FPD (V_TBL_TYPE (I).LOW_PLAN_NO,
                                V_TBL_TYPE (I).FPD,
                                V_TBL_TYPE (I).SERIAL_NO,
                                V_TBL_TYPE (I).CEDIA_CODE,
                                V_TBL_TYPE (I).DT));
          END LOOP;
       END LOOP;
       RETURN;
    EXCEPTION
       WHEN OTHERS
       THEN
          RAISE_APPLICATION_ERROR (-20000, SQLCODE || ' ' || SQLERRM);
          RAISE;
    END;Waiting for your views.
    Regards,

    Ora Ash wrote:
    Hello Experts,
    I have created a Pipe lined function with execute immediate, due to below requirement;
    1) Columns in where clause is passed dynamically.No, that's something you've introduced, and is due to poor database design. You appear to have columns on your table called FPD1, FPD2 ... FPD31. The columns do not need to be 'passed dynamically'
    2) I want to know the data stored into above dynamic columns.And you can know the data without it being dynamic.
    3) I want to use it in report, so I don't want to insert it into a table.That's fine, though there's no reason to use a pipelined function.
    You also have an pointless exception handler, which masks any real errors.
    I'm not quite sure what the point of your "connect by" is in your query as we don't have your tables or data or know for sure what the expected output is.
    However, in terms of handling the 'dynamic' part that you've introduced, then you would be looking at doing something along the following lines, using a static query that requires no poor dynamic code, and no pipelined function...
    with x as (select level as dy from dual connect by level <= 31)
    select a.low_plan_no
          ,a.fpd
          ,a.serial_no
          ,a.cedia_code
          ,trunc(c.low_plan_period_from)+a.dy-1 as dt
    from  (select low_plan_no
                 ,dy
                 ,'FPD'||dy as fpd
                 ,spts
                 ,serial_no
                 ,cedia_code
           from (
                 select low_plan_no
                       ,x.dy
                       ,case x.dy when 1 then fpd1
                                  when 2 then fpd2
                                  when 3 then fpd3
                                  when 4 then fpd4
                                  when 5 then fpd5
                                  when 6 then fpd6
                                  when 7 then fpd7
                                  when 8 then fpd8
                                  when 9 then fpd9
                                  when 10 then fpd10
                                  when 11 then fpd11
                                  when 12 then fpd12
                                  when 13 then fpd13
                                  when 14 then fpd14
                                  when 15 then fpd15
                                  when 16 then fpd16
                                  when 17 then fpd17
                                  when 18 then fpd18
                                  when 19 then fpd19
                                  when 20 then fpd20
                                  when 21 then fpd21
                                  when 22 then fpd22
                                  when 23 then fpd23
                                  when 24 then fpd24
                                  when 25 then fpd25
                                  when 26 then fpd26
                                  when 27 then fpd27
                                  when 28 then fpd28
                                  when 29 then fpd29
                                  when 30 then fpd30
                                  when 31 then fpd31
                        else null
                        end as spts
                       ,serial_no
                       ,cedia_code
                 from   x cross join m_low_plan_details
                 where  serial_no = p_serial_no
                 and    cedia_code = p_cedia_code
                 and    low_plan_no = p_low_plan_no
           where  nvl(spts,0) > 0
          ) A
          join m_low_plan_details B on (    A.low_plan_no = B.low_plan_no
                                        and A.cedia_code = B.cedia_code
                                        and A.serial_no = B.serial_no
          join m_low_plan_mstr C on (    B.low_plan_no = C.low_plan_no
                                     and B.client_code = C.client_code
                                     and B.variant_code = C.variant_code
    connect by level <= spts;... so just remind us again why you think it needs to be dynamic?

  • Transaction control with execute immediate

    Hi, What is the correct way to commit/ rollback transactions when executing a dynamic update statement with execute immediate?

    Hi Thanks fo the reply, they don't appear to be. here's my procedure. Is there anything the is obviously wrong?
    PROCEDURE p_move_city_numerics ( p_mode IN VARCHAR2,
    p_schema IN VARCHAR2,
              p_table IN VARCHAR2,
                   p_destination IN VARCHAR2,
                   p_city_name IN VARCHAR2,
                   p_outcome     OUT VARCHAR2)
    IS
    l_valid_object VARCHAR2(200);
         l_error_msg VARCHAR2(200);
         l_outcome     VARCHAR2(2000);
         l_sql_count VARCHAR2(2000);
         l_sql_update VARCHAR2(2000);
         l_record_count NUMBER;
         e_object_error EXCEPTION;
    BEGIN
    l_valid_object := f_is_city_valid (p_schema, p_table, p_destination);
         IF l_valid_object != 'VALID' THEN
         RAISE e_object_error;
         END IF;
         l_sql_count := 'SELECT COUNT(*) FROM ' || p_schema || '.' || p_table;
         l_sql_count := l_sql_count || ' WHERE UPPER(city) LIKE ' || '''' || '%' || UPPER(p_city_name) || '%' || '''';
         l_sql_count := l_sql_count || ' AND ( city LIKE ' || '''' || '%1%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%2%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%3%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%4%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%5%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%6%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%7%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%8%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%9%' || '''';
         l_sql_count := l_sql_count || ' OR city LIKE ' || '''' || '%0%' || '''' || ')';
         l_sql_update := 'UPDATE ' || p_schema || '.' || p_table;
         l_sql_update := l_sql_update || ' SET ' || p_destination || ' = city,';
         l_sql_update := l_sql_update || ' city = ' || '''' || p_city_name || '''';
         l_sql_update := l_sql_update || ' WHERE UPPER(city) LIKE ' || '''' || '%' || UPPER(p_city_name) || '%' || '''';
         l_sql_update := l_sql_update || ' AND ( city LIKE ' || '''' || '%1%' || '''';
         l_sql_update := l_sql_update || ' OR ciity LIKE ' || '''' || '%2%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%3%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%4%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%5%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%6%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%7%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%8%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%9%' || '''';
         l_sql_update := l_sql_update || ' OR city LIKE ' || '''' || '%0%' || '''' || ')';
         IF p_mode = 'SELECT' THEN
         EXECUTE IMMEDIATE(l_sql_count) INTO l_record_count;
         l_outcome := TO_CHAR(l_record_count) || ' records to be updated!';
         ELSIF p_mode = 'UPDATE' THEN
         EXECUTE IMMEDIATE(l_sql_count) INTO l_record_count;
         EXECUTE IMMEDIATE(l_sql_update);
    l_outcome := TO_CHAR(l_record_count) || ' records have been updated!';
         COMMIT;
         ELSE
         l_outcome := ' ERROR - Invalid mode: ' || p_mode || ' has been passed into the function! Valid values are SELECT or UPDATE';
         END IF;
    EXCEPTION
    WHEN e_object_error THEN
         IF l_valid_object = 'INVALID_TABLE' THEN
         l_outcome := 'ERROR - Not a valid table name: ' || p_schema || '.' || p_table;
         ELSIF l_valid_object = 'INVALID_CITY' THEN
         l_outcome := 'ERROR - CITY not a valid field in the table: ' || p_schema || '.' || p_table;
         ELSIF l_valid_object = 'INVALID_DEST' THEN
         l_outcome := 'ERROR - Destination field: ' || p_destination || ' is not a valid field in the table: ' || p_schema || '.' || p_table;
         END IF;
         WHEN OTHERS THEN
         l_error_msg := SQLCODE || '-' || SUBSTR(SQLERRM, 1, 150);
         l_outcome := 'ERROR - ' || l_error_msg;
         ROLLBACK;
    END p_move_city_numerics;

  • Disadvantage with 'Execute Immediate'

    What is the disadvantage with 'EXECUTE IMMEDIATE'.

    I think you guys are missing the point here.
    None of the issues listed are 'EXECUTE IMMEDIATE' disadvantages.
    'EXECUTE IMMEDIATE' is a tool. Like DMS_SQL. Like ref cursors. Like explicit cursor. Like implicit cursors.
    A tool, any tool, needs to be used correctly. If you use a hammer and hit a nail so hard that it bents, causing the hammer to slip doing some serious damage to your thumb... whose fault it is?
    Is it The Hammer that is at fault here? Or is the user of that tool?
    There are no disadvantages to using 'EXECUTE IMMEDIATE'. It is a tool. But like all tools it needs to be used correctly and safely. Things like excessive hard parsing because of a severe lack of bind variables, or opening a hole for SQL injection, etc.. all these are symptoms of - and let's be blunt here - an ignorant developer. It has nothing to do with the tool 'EXECUTE IMMEDIATE'.
    And those same type of errors will be made by Mr Ignorant Developer using other tools in Oracle.
    Shoddy workmanship is not because of poor tools. Shoddy code is not because of using a specific feature (like execute immediate).
    The proper question to ask is thus not "what are the disadvantages of execute immediate", but rather "where should I typically use execute immediate and how?".
    Not every developer will know how to use every single tool in the toolbox (I sure don't know all the tools in the Oracle toolbox). So there is nothing wrong with asking.
    But asking what is "wrong" with a tool (aka "what are the disadvantages") is in my view seriously missing the point that a tool is there to solve very specific types of problems...
    That is what a developer should be after - How to use the tool correctly.

  • Execute a DML query its length exceeds 4000 characters with execute immediate statement.

    I want to execute a DML query with execute immediate statement. That DML query length exceeds 4000 characters. This query has Xquery related conditions, i can not split the query. when i tried execute it is giving "string literal too long".  I tried with DBMS_SQL.Parse() and DBMS_SQL.Execute also, but it is giving same error. I have to execute this DML query inside a Procedure. Please help me to resolve this. We are using oracle 10g version
    Thanks & Regards,
    K.Kedarnadh

    Actually Query is a dynamic query. Query length will exceeds if the no of domains\domain values \products exceeds. Any way Below one is current dynamic query, which is generated within procedure
    SELECT
      IVT.ID_IVT
        ,IVT.ID_INS_IVT
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//productName/text()') AS PRODUCTNAME
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//elementName/text()') AS INSTANCENAME
      ,EXTRACTVALUE(IVT.DOCUMENT_IVT,'//elementInternalName/text()') AS INTERNALNAME
        ,CTG.NAME_CTG
        ,CTR.NAME_CTR
        ,MDL.NAME_MDL
      ,IVT.REEDIT_FLAG_IVT
        FROM  VARIATION_IVT IVT INNER JOIN CATEGORY_CTG CTG ON CTG.ID_CTG=IVT.ID_CTG_IVT
      AND IVT.STATUS_IVT='Active' AND IVT.DELETE_FLAG_IVT=0 AND IVT.ID_PRJ_IVT=1
      AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="Jurisdictions" and (domainValue="Delhi" or domainValue="Bangladesh" or domainValue="Mumbai" or domainValue="India" or domainValue="Pakistan" or domainValue="Nepal" or domainValue="Maldives" or domainValue="Kolkata" or domainValue="Bhutan" or domainValue="Chennai" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="Channels" and (domainValue="Agents" or domainValue="SBI" or domainValue="Maruti" or domainValue="Direct" or domainValue="CitiFinancial" or domainValue="SCB" or domainValue="BankAssurance" or domainValue="CitiBank" or domainValue="Employees" or domainValue="GE" or domainValue="Brokers" or domainValue="Telemarketing" or domainValue="Agency" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//domain[domainName="ModeofDelivery" and (domainValue="Walkin" or domainValue="Internet" or domainValue="ALL")]')=1 AND  IVT.DOCUMENT_IVT.existsnode('.//context[(productName="ALL" or productName="A009" or productName="A010" or productName="A046" or productName="AccidentShieldClassic" or productName="AccidentShieldOnline" or productName="AM01" or productName="AM02" or productName="AME_Cancellation" or productName="ARHG" or productName="ARPA" or productName="B003" or productName="B004" or productName="B007" or productName="B008" or productName="B009" or productName="B010" or productName="B012" or productName="B013" or productName="B015" or productName="B016" or productName="B017" or productName="BC04_PA" or productName="BC06_FDP" or productName="BC06_PA" or productName="BC09" or productName="BC10" or productName="BC12" or productName="BC13" or productName="BF03" or productName="BS01" or productName="BS02" or productName="C017" or productName="C035" or productName="C036" or productName="C037" or productName="C038" or productName="C040" or productName="C041" or productName="C041Gold" or productName="C041New" or productName="C045HomeContents" or productName="C048" or productName="C049" or productName="C054" or productName="C057" or productName="C060Building" or productName="C060Contents" or productName="C060FDP" or productName="C061Building" or productName="C061Contents" or productName="C062" or productName="C063" or productName="C067" or productName="C070" or productName="C072" or productName="C074" or productName="C077" or productName="C081" or productName="C082" or productName="C087" or productName="C088" or productName="CITIFOREVER" or productName="CITISECURE" or productName="CITICHILDPLAN" or productName="D001" or productName="DB01" or productName="DD01" or productName="DD02" or productName="DD03" or productName="DD04" or productName="DD09" or productName="DD10" or productName="E005" or productName="E011" or productName="E016" or productName="E020" or productName="E030" or productName="E034" or productName="E040" or productName="E041" or productName="E045HCP" or productName="E045HSP" or productName="E049" or productName="E049New" or productName="E052" or productName="E053" or productName="E054FDP" or productName="E055" or productName="E056" or productName="E057" or productName="E058" or productName="E061" or productName="E061BATCH" or productName="E062" or productName="E063" or productName="E064HCP" or productName="E064HSP" or productName="E066" or productName="E069" or productName="E073" or productName="E075" or productName="E076" or productName="E088" or productName="E090" or productName="E093A" or productName="E093B" or productName="E095" or productName="E099A" or productName="E099B" or productName="E106" or productName="E107" or productName="E110" or productName="E112" or productName="E114" or productName="E115" or productName="E116" or productName="F001" or productName="FamilyHealthInsurance" or productName="FamilyHospitalBenefits" or productName="FamilyHospitalisationCoverBenefit" or productName="G001" or productName="G002" or productName="HealthShieldOnline" or productName="Health_B005" or productName="Health_S057" or productName="HealthSheild" or productName="HealthWalkin" or productName="HomeContentOnline" or productName="HomeShieldOnline" or productName="HomeShieldWalkin" or productName="HospitalCashOnline" or productName="J001" or productName="J008" or productName="K001" or productName="KV02" or productName="LC03" or productName="ML01" or productName="MP02" or productName="MP03" or productName="MR01" or productName="O005" or productName="PO01" or productName="PO02" or productName="PO03" or productName="PO04" or productName="PO05" or productName="PO06" or productName="RR02" or productName="RR03" or productName="RR04" or productName="S006" or productName="S033" or productName="S049" or productName="S051" or productName="S054" or productName="S057" or productName="S060" or productName="S061" or productName="S065" or productName="S065TM" or productName="S068" or productName="S076" or productName="S077" or productName="S079" or productName="S080" or productName="S081" or productName="S084" or productName="S085" or productName="S086" or productName="S087" or productName="S088" or productName="S091" or productName="S092" or productName="S093" or productName="S094" or productName="S095" or productName="S097" or productName="S098" or productName="S099" or productName="S100" or productName="S101" or productName="S102" or productName="S103" or productName="S104" or productName="S106" or productName="S107" or productName="S108" or productName="S109" or productName="S110" or productName="S111" or productName="S113" or productName="SCBNAC" or productName="SF02" or productName="SS01" or productName="SS02" or productName="SUNFHM" or productName="SurgicalShield" or productName="TD01" or productName="TD02" or productName="TP01" or productName="U002Building" or productName="U002Contents" or productName="U004Building" or productName="U007" or productName="U009" or productName="U013" or productName="U014" or productName="U015" or productName="U016" or productName="V001" or productName="V002" or productName="V005" or productName="V006" or productName="V008" or productName="W008" or productName="W020" or productName="W021" or productName="W022" or productName="W023" or productName="W024" or productName="W026" or productName="W027" or productName="W028" or productName="W029" or productName="W105" or productName="W106" or productName="WI01" or productName="WI02" or productName="WI03" or productName="WI07" or productName="WI08" or productName="WI09" or productName="WI10" or productName="WI11" or productName="WI12" or productName="WI13" or productName="WI14" or productName="WI17" or productName="WI20" or productName="WI21" or productName="WI21_Health" or productName="WI23" or productName="WI24" or productName="WI26" or productName="WI30" or productName="WI31" or productName="WI33" or productName="WI34" or productName="X001" or productName="X002" or productName="X003" or productName="X004" or productName="X005" or productName="X008" or productName="Y001" or productName="Y007" or productName="Y009" or productName="Y010" or productName="Y011" or productName="Y011H" or productName="Y020" or productName="Y020N" or productName="Z008" or productName="ZI001")]')=1
      INNER JOIN CENTER_CTR CTR ON CTR.ID_CTR=CTG.ID_CTR_CTG
        INNER JOIN MODEL_MDL MDL ON  MDL.ID_MDL=CTR.ID_MDL_CTR

  • Newbie - Insert/Update Sql Records

    Is there a good overview available somewhere that I can see the code necessary to insert/ update MSSql records? The selects and data vieing is simple, just need the next step.
    Tx

    Hi there,
    I searched for information about inserting SQL records, too, but did not find a concrete example. There are code samples regarding updating records at:
    http://developers.sun.com/prodtech/javatools/jscreator/reference/codesamples/index.html
    After all I managed to create new data records using this code:
    1. In the constructor of the page:
    // User provided initialization code
    testRowSet.setAutoCommit(true);
    testRowSet.setHoldability(testRowSet.HOLD_CURSORS_OVER_COMMIT);
    testRowSet.setConcurrency(testRowSet.CONCUR_UPDATABLE);
    testRowSet.execute();
    2. Action handler of the submit button:
    public String button1_action() {
    // Add your event code here...
    try {
    String a = (String)textField1.getValue();
    String b = (String)textField2.getValue();
    System.out.println("Werte a + b: "+a+" + "+b);
    testRowSet.moveToInsertRow();
    testRowSet.updateString(1, a);
    testRowSet.updateString(2, b);
    System.out.println("inner Action");
    testRowSet.insertRow();
    return "success";
    catch ( SQLException e) {
    log("speicherfehler", e);
    throw new FacesException(e);
    Because I just worked this out 30 minutes ago, there is still some debug code in it (you noticed that probably) and I do not know if this is the somehow "official" solution for the task, furthermore there might be code that is not necessary.
    Hope this helps
    Bernd

  • Need help with EXECUTE IMMEDIATE

    I have created a CHAR string in my form that contains a UPDATE statement. This statement is passed into my procedure and in the procedure, the EXECUTE IMMEDIATE is supposed to run the UPDATE statement. THIS IS NOT THE CASE for some reason. NEWVALUE is record is also passed into the procedure.
    this is the UPDATE_STATEMENT statement prepared by my forms application:
    'UPDATE xtable SET ACTION_CODE_DESC =''a b c'',INACTIVE =''N'' WHERE ACTION_CODE = newValue.ACTION_CODE'
    The CHAR values are surrounded by a pair of single quotes. The UPDATE statement starts and ends with single quotes.
    In my procedure I have this statement:
    PROCEDURE JKUPD_ACTION_CODE
    ( newValue in etmst_action_code%rowtype
    ,UPDATE_STATEMENT in CHAR
    ,perr_count out number
    AS
    BEGIN
    EXECUTE IMMEDIATE UPDATE_STATEMENT ;
    IF SQL%NOTFOUND
    THEN .......
    I keep getting ORA-00900: invalid SQL statement and dont understand why this is happening.
    Any ideas anyone?
    Thanks :)

    I haven't seen a version indication for this thread, but there should be 2 (different!) functions that come with Oracle that might do what you want.
    If all you want to do is dynamically execute text representing a SQL command check the on-line documentation (if there is any) for dbms_sql.execute and/or dbms_utility.exec_ddl. Make sure the string passed in are syntactically correct :)

  • Help with EXECUTE IMMEDIATE and DROP

    Hi all,
    we are trying to create a procedure to do the following:
    * We have in the database some tables named like C$_XXXXXXXXX
    * We want to drop some of these tables that have a common prefix (f.e C$_1203101)
    DECLARE
    v_sql VARCHAR2(300);
    BEGIN
    SELECT 'DROP TABLE ODISTAG.'|| TABLE_NAME ||';' INTO v_sql FROM USER_TABLES WHERE TABLE_NAME LIKE 'C$_1203101%';
    EXECUTE IMMEDIATE v_sql;
    END;
    But we get this error:
    Error report:
    ORA-00911: invalid character
    ORA-06512: at line 5
    00911. 00000 - "invalid character"
    *Cause:    identifiers may not start with any ASCII character other than
    letters and numbers. $#_ are also allowed after the first
    character. Identifiers enclosed by doublequotes may contain
    any character other than a doublequote. Alternative quotes
    (q'#...#') cannot use spaces, tabs, or carriage returns as
    delimiters. For all other contexts, consult the SQL Language
    Reference Manual.
    *Action:
    Any help on that please?
    Thanks!

    This will not work if you fetch more than one row..instead you can do this..
    DECLARE
         v_sql VARCHAR2(30000);
    BEGIN
         for c2 in (
                        SELECT 'DROP TABLE ODISTAG.'|| TABLE_NAME drp
                        FROM USER_TABLES WHERE TABLE_NAME LIKE 'C$_1203101%'
         loop
              v_Sql := c2.drp;
              EXECUTE IMMEDIATE v_sql;
         end loop;
    END;

  • Problems with execute immediate

    HELLO :
    How can I execute a procedure (with input , output parameters ) , in another schema??
    I have the following code :
    V_SENTENCIA:= 'begin '||v_schema_name|| .DAR_ID('||V_CODE||',:p1); END;';
    EXECUTE IMMEDIATE V_SENTENCIA INTO V_Num
    and the declaration on my proc is the following :
    CREATE PROCEDURE DAR_ID ( p_1 in varchar2 ,p_2 out NUMBER) IS
    NUM NUMBER (5,0);
    BEGIN
    SELECT count (id) INTO p_2 FROM Veh WHERE (Param1=p_1)
    END ;
    Can anyone help me please ?

    Hey,
    this one will work:
    SQL> create or replace procedure pp(p_arg in varchar2, p_res out number)
    2 is
    3 begin
    4 select 1 into p_res from dual where p_arg = '1';
    5 end;
    6 /
    Procedure created
    SQL> set serveroutput on
    SQL> declare
    2 l_ret number;
    3 begin
    4 execute immediate 'begin pp(:p_arg, :l_ret); end;' using
    5 in '1', out l_ret;
    6 dbms_output.put_line(l_ret);
    7 end;
    8 /
    1
    PL/SQL procedure successfully completed
    from a remote db:
    SQL> set serveroutput on;
    SQL>
    SQL> declare
    2 l_ret number;
    3 begin
    4 execute immediate 'begin pp@to_remote(:p_arg, :l_ret); end;'
    5 using in '1', out l_ret;
    6 dbms_output.put_line(l_ret);
    7 end;
    8 /
    1
    PL/SQL procedure successfully completed
    Amiel.

  • Returning (bulk collect) clause with execute immediate

    db version 11.1.0.7
    trying to do a returning bulk collect but it is not working:
    -- my test table
    create table t as
    with f as (select rownum rn from dual connect by rownum <= 10)
    select
    rn,
    lpad('x',10,'x') pad
    from f;
    -- works as expected
    declare
    type aat is table of t%rowtype;
    aay aat;
    begin
    delete from t returning rn,pad bulk collect into aay;
    rollback;
    end;
    -- but the table I really want to do has many columns so I want to dynamically build list of columns for the
    -- returning clause. This way if the table changes the stored proc will not have to be modified
    -- fails PLS-00429: unsupported feature with RETURNING clause
    declare
    type aat is table of t%rowtype;
    aay aat;
    s varchar2(4000);
    begin
    s := 'delete from t returning rn,pad into :1';
    execute immediate s returning bulk collect into aay;
    rollback;
    end;
    -- tried a few other things:
    create or replace type t_obj as object (rn number,pad varchar2(10));
    -- PLS-00497: cannot mix between single row and multi-row (BULK) in INTO list
    declare
    nt t_obj;
    s varchar2(4000);
    begin
    s := 'delete from t returning t_obj(rn,pad) into :1';
    execute immediate s returning bulk collect into nt;
    rollback;
    end;
    -- works, but would require store proc changes if the table changes
    declare
    type t is table of number;
    type v is table of varchar2(10);
    vt v;
    nt t;
    s varchar2(4000);
    begin
    s := 'update t set rn = 10 returning rn,pad into :1,:2';
    execute immediate s returning bulk collect into nt,vt;
    rollback;
    end;
    /basically I want to dynamically build the list of columns with all_tab_cols and put the list into the returning clause
    but seems like I will have to hard code the column lists. This means whenever the table changes I will have to
    modify the store proc .. Any way around this?
    Thanks

    And with object type you were almost there. You forgot to create table of objects type:
    SQL> create or replace type t_obj as object (rn number,pad varchar2(10));
      2  /
    Type created.
    SQL> declare
      2      type aat is table of nt;
      3   aay aat;
      4   s varchar2(4000);
      5  begin
      6   s := 'delete from t returning
    SQL> declare
      2      type aat is table of t_obj;
      3   aay aat;
      4   s varchar2(4000);
      5  begin
      6   s := 'delete from t returning t_obj(rn,pad) into :1';
      7   execute immediate s returning bulk collect into aay;
      8   rollback;
      9  end;
    10  /
    PL/SQL procedure successfully completed.
    SQL> SY.

  • Newbie (View sql statement before execute immediate)

    Here is a sample:
    <code>
    drop table dummy;
    create table dummy(county varchar2(20)
    ,fiscalyear number(4,0)
    ,wavkeyid number(4,0));
    Insert into dummy(county,fiscalyear,wavkeyid)
    values('Jefferson',2012,59);
    commit;
    </code>
    I am trying to use a bind variable in the SQL statement.
    I would like to see the statement before it is executed.
    Example
    Select county from dummy where wavkeyid=59 and fiscalyear=2012
    Is there a way for me to see the line above?
    <code>
    PROCEDURE test_BindVar
    AS
    v_message_tx varchar2(200);
    v_wavkeyid_nr number:=59;
    v_county_tx varchar2(40);
    BEGIN
    v_message_tx:='Select county from dummy '||
    ' where wavkeyid=:x and fiscalyear=2012 ';
    dbms_output.put_line
    ('v_message_tx '||v_message_tx);
    execute immediate v_message_tx into v_county_tx using v_wavkeyid_nr;
    dbms_output.put_line
    ('v_county_tx '||v_county_tx );
    END;
    </code>
    Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - Prod
    PL/SQL Release 10.2.0.4.0 - Production
    "CORE 10.2.0.4.0 Production"
    TNS for 32-bit Windows: Version 10.2.0.4.0 - Production
    NLSRTL Version 10.2.0.4.0 - Production
    TIA
    Steve42

    you missed the forum you are in ;)
    "SQL Developer (Not for general SQL/PLSQL questions)"
    recommend to post your question to the related forum on OTN.

Maybe you are looking for

  • How can I restore a .aplib Aperture library from time machine?

    When I try and restore my Aperture I get folders instead of a single .aplib file.  Does anyone know how I can restore the .aplib file so I can open it?

  • Gmail outgoing server issues with Apple Mail

    Hi, I'm currently running OS X 10.8.5 Mountain Lion, and trying to set up my gmail account in Apple Mail. I can recieve mail just fine, but am not able to send mail. for the outgoing server i typed "smtp.gmail.com." When i look at the Mail Connection

  • Changing fonts in jtextpane

    Hi, I'm new to playing around with JTextPane's and I need to create a basic text editor. The problem I'm having is that when I select a new font and use the backspace, it generates many textUI exceptions (on my pc). When I run the same code on mac os

  • Problem in populating userfields in PO using BAPI_PO_CREATE1

    DATA: lw_poheader type BAPIMEPOHEADER,       lw_poheaderx type BAPIMEPOHEADERX,       lw_poitem type BAPIMEPOITEM,       lt_poitem type standard table of BAPIMEPOITEM,       lw_poitemx type BAPIMEPOITEMX,       lt_poitemx type standard table of BAPIM

  • How to use the action OnExpandAll on UI element Tree

    Hi, experts . I am in WDA developing project and developing the screen which has Tree . I want to expand all nodes when users click the button on the head of Tree . I copied the application `WDT_TREE` and created Tree of my application successfully .