ORA-14552: cannot perform a DDL in a execute immediate - proc

Hi All,
I am trying to disable triggers in a stored procedure:
PROCEDURE Alter_trigger_DISBALE
IS
BEGIN
     execute immediate ('alter trigger BEI_INS_MY DISABLE');
END;
I get the following error:
ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
Is there a solution for this problem ?
Best Regards
Friedhold

How are you calling the procedure?
I assume that, since your procedure actually compiles, it doesn't have the parenthesis around the EXCEUTE IMMEDIATE string and that there is a CREATE before the PROCEDURE. I hope that "disable" is spelled correctly in the real thing.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC

Similar Messages

  • ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML;;

    Hi all,
    I have a problem!
    I have one PL SQL function doing an Update and insert into some oracle tables, this function return one number (0 or 1 or 2).
    I'm excuting this query from one PHP program to call the function :
    SELECT SALE.DB_FUNC_ASSOCIATE_TB2U('[email protected]',123)
    FROM dual;
    the problem that I have these errors :
    ERROR DB_FUNC_ASSOCIATE_TB2U Level 1 : ORA-01403: no data found
    ERROR DB_FUNC_ASSOCIATE_TB2U : ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
    there's a mean that i can do to call this function from PHP without getting this Error such as I tested this function using the script below and it works fine:
    declare
    a number;
    begin
    a:= SALE.DB_FUNC_ASSOCIATE_TB2U('[email protected]',123) ;
    end;
    Please help me :)
    regards,

    Sure, it works in the sense that you would no longer get an error.
    Creating this as an autonomous transaction, however, is going to blow your transactional integrity. You've now got code that is being called as the result of a SELECT operation (something that everyone that comes after you will assume is read-only) that commits outside of the current transaction scope. That is almost always a bad thing.
    In addition, having a WHEN OTHERS without a RAISE is almost always a bug. You're completely hiding the error message plus you're discarding proper exception handling in order to provide a return code and assuming that the caller is going to check the status. Relying on return status codes is normally a bad idea because it's very easy on the client side to forget to check the return code. Even if the client were to check the return code, it has no idea what went wrong, so it can't even log the root cause of the error.
    Justin

  • ORA-20001: Oracle error -20001: ORA-20001: Oracle error -14552: ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML has been detected in fnd_global.set_nls.set_parameter('NLS_LANGUAGE','AMERICAN'). has been detected in fnd_global.set

    ORA-20001: Oracle error -20001: ORA-20001: Oracle error -14552: ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML has been detected in fnd_global.set_nls.set_parameter('NLS_LANGUAGE','AMERICAN'). has been detected in fnd_global.set_nls.
    this error generates everytime when i run a apex application
    i did call the package in session state with  dbms_session.set_nls('NLS_LANGUAGE','AMERICAN'); but still it shows the error in the report any solution please

    Hi Amrit
    Can you put the FND_GLOBAL calls in a pre map trigger/process rather than as part of the map?
    Cheers
    David

  • ORA-14551: cannot perform a DML operation inside a query

    I have a Java method which is deployed as a Oracle function.
    This Java method parses a huge XML & populates this data
    into a set of database tables.
    I have to call this Oracle function in a unix shell script using sqlplus.
    Value returned by this function will be used by the shell script to decide
    what to do next.
    I am calling the Oracle Java function as follows in the shell script:
    echo "SELECT XML_TABLES.RUN_XML_LOADER('$P1','$P2','$P3','$P4') FROM DUAL;\n" | sqlplus $DB_USER > $LOG
    This gives error - "ORA-14551: cannot perform a DML operation inside a query".
    If I have to add a AUTONOMOUS_TRANSACTION pragma to this Java function,
    where to I add it considering, that the definition of the function is in a Java class.
    Can we do it in call spec?
    create or replace package XML_TABLES is
    function RUN_XML_LOADER(xmlFile IN VARCHAR2,
    xmlType IN VARCHAR2,
    outputDir IN VARCHAR2,
    logFileDir IN VARCHAR2) RETURN VARCHAR2 AS
    LANGUAGE JAVA NAME 'XmlLoader.run
    (java.lang.String, java.lang.String, java.lang.String, java.lang.String)
    return java.lang.String';
    end XML_TABLES;
    If not is there any other way to acheive this?
    Thanks in advance.
    Sunitha.

    If I have to add a AUTONOMOUS_TRANSACTION pragma to this Java function,You'd have to write a PL/SQL function that calls the JSP. But I would caution you about using that pragma. It does introduce tremendous complexity into processing.
    As I see it you only need a function to return the result code so why not use a procedure with an OUT parameter?
    Cheers, APC
    Of course Yoann's suggestion of using an anonymous block would work too.
    Message was edited by:
    APC

  • Getting error SQL Error : ORA-14551: cannot perform a DML operation inside a query

    Hi gurus ,
    Your help is greatly appreciated ..
    I am doing some changes in the fucntion for an existing package .Introducing the new below check , am updating one of the tables based on a if condition ..
           IF  numALLOWED_COUNT >= numLAST_COUNT_ADDED+1  THEN
                     blnGDS_Allowed :=True;
                      varSTMT := 'UPDATE PROD.TMS_PROCESS_COUNTER ';
                      varSTMT := varSTMT ||' SET last_count_added = last_count_added+1';
                      varSTMT := varSTMT ||' WHERE process_name = ''DAILY_GDS_COUNT''';
                      varSTMT := varSTMT ||' AND COUNTER_IND = ''750FD130''';
                     PROC_LOG('Update Tms_Process_counter varSTMT --' || varSTMT);
                     IF INSERT_BATCH(99,varSTMT) > 0 THEN
                        NULL;
                     END IF;
    Function for insert_batch :
    UNCTION INSERT_BATCH(numTABLE_ID IN NUMBER, varSQL_STATEMENT IN VARCHAR2) RETURN NUMBER IS
    varINSERT_BATCH_STMT  VARCHAR2(32767)     := NULL;
    varADD_REC_TYPE       BATCH_TABLES.ADD_REC_TYPE%TYPE;
    BEGIN
        PROC_LOG( 'INSIDE INSERT_BATCH IRC : ' || varSQL_STATEMENT );  --IRC 9/20 UC
        INSERT INTO BATCH_STATEMENT(QUEUE_ID,TABLE_ID,STATEMENT,QUEUE_SEQUENCE_ID)
        VALUES (numQUEUE_ID,numTABLE_ID,varSQL_STATEMENT,1);
    RETURN 1;
    EXCEPTION WHEN OTHERS THEN
        PROC_LOG('Failed in INSERT_BATCH');
        PROC_LOG('SQL Error : ' || SUBSTR(SQLERRM,1,1000));
        RETURN -1;
    END INSERT_BATCH;
    desc PROD.BATCH_STATEMENT
      QUEUE_ID           NUMBER(15)                 NOT NULL
      TABLE_ID           NUMBER(2)                  NOT NULL
      STATEMENT          VARCHAR2(4000 BYTE)        NOT NULL
      QUEUE_SEQUENCE_ID  NUMBER(5)                  NOT NULL
    Some how when its calling the insert_batch , its giving me the error in the logs as below:
    04:01:41 - Update Tms_Process_counter varSTMT --UPDATE PROD.TMS_PROCESS_COUNTER  SET last_count_added = last_count_added+1 WHERE process_name = 'DAILY_GDS_COUNT' AND COUNTER_IND = '750FD130'
    04:01:41 - INSIDE INSERT_BATCH IRC : UPDATE PROD.TMS_PROCESS_COUNTER  SET last_count_added = last_count_added+1 WHERE process_name = 'DAILY_GDS_COUNT' AND COUNTER_IND = '750FD130'
    04:01:41 - Failed in INSERT_BATCH
    04:01:41 - SQL Error : ORA-14551: cannot perform a DML operation inside a query

    Some how when its calling the insert_batch , its giving me the error in the logs as below:
    04:01:41 - SQL Error : ORA-14551: cannot perform a DML operation inside a query
    Yes - and the exception is telling you EXACTLY what the problem is. You have a query
    IF INSERT_BATCH(99,varSTMT) > 0 THEN
    And you are performing a DML operation inside that query:
    INSERT INTO BATCH_STATEMENT(QUEUE_ID,TABLE_ID,STATEMENT,QUEUE_SEQUENCE_ID)
        VALUES (numQUEUE_ID,numTABLE_ID,varSQL_STATEMENT,1);
    Like the exception says: you can't do that.
    You need to call the function using PL/SQL and capture the return value into a variable. Then test that variable:
    myVar := INSERT_BATCH(99,varSTMT);
    if myVar > 0 THEN

  • Cannot perform DDL DML inside a query

    Hi,
    I am using Tom Kyte's in_list function to create a select list inside a select query in one of the reports in my application, given as follows:
    SELECT col1, col2,...htmldb_item.select_list_from_query(1,NULL,
    '(SELECT column_value d,column_value r FROM the((SELECT CAST
    (mypackage.in_list(''||colon_delimited_list||'') AS
    myTableType) FROM dual) ))' )...FROM A, B WHERE ...
    But the following error appears:
    report error:
    ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML
    ORA-06512: at "FLOWS_020200.WWV_FLOW", line 7002
    ORA-06512: at "FLOWS_020200.WWV_FLOW_UTILITIES", line 113
    ORA-06550: line 1, column 45:
    PLS-00103: Encountered the symbol "(" when expecting one of the following:
    begin case declare exit for goto if loop mod null pragma
    raise return select update while with
    If I replace the query passed to function select_list_from_query, with some simple dummy query, then it works fine.
    Please tell me is there any limitation of its use as this case?
    What may be the possible best solution?
    Regards,
    Amir Aman

    I have tried Scott's parenthesis solution first.
    It is working but with making an additional change, i.e., passing '||''''||colon_delimited_list||''''||' instead just ''||colon_delimited_list||''.
    Denes, I have also seen your examples, really a helpful resource.
    Thank you very much!
    Amir Aman

  • Calling procedure from RPD. Error ORA-14552 as it has a commit.

    Hi All,
    I have implemented the calling of procedure functionality from rpd.
    But our data base procedure that is called has commit in it which I guess is not allowed & so we are getting this error.
    We need to commit once we finish off the procedure. Please suggest how we can achieve this.
    State: HY000. Code: 10058. [NQODBC] [SQL_STATE: HY000] [nQSError: 10058] A general error has occurred. [nQSError: 16001] ODBC error state: S1000 code: 14552 message: [Oracle][ODBC][Ora]ORA-14552: cannot perform a DDL, commit or rollback inside a query or DML ORA-06512: at "DWH.DWH_PA_TC_ACCRUAL_PKG", line 1565 ORA-14551: cannot perform a DML operation inside a query ORA-06512: at "DWH.TRAILING_COST_FUNCTION", line 8. [nQSError: 16011] ODBC error occurred while executing SQLExtendedFetch to retrieve the results of a SQL statement. (HY000)
    Thanks.
    pankaj

    This is we are using from RPD to call the function:
    SELECT trailing_cost_function('USD', 'JUN-08', ' POC', '', 'DJRC46', '') AS RET_VAL
    FROM dual
    Now this is the structure of the function which is in back end db:
    CREATE OR REPLACE Function
    Trailing_Cost_Function(a IN varchar2,b IN varchar2,c IN varchar2,d IN varchar2,e IN varchar2,
    f IN varchar2) return
    varchar2 IS
    ret_o varchar2(50);
    begin
    test123; -- calling the procedure
    ret_o:='0';
    return ret_o;
    end;
    And the procedure is:
    create or replace procedure test123 is
    begin
    insert into test_123 values ('asssd');
    end test123;
    Thanks,
    Pankaj

  • Cannot perform DML inside a query

    Hi,
    I have a Function and I am trying to execute an "Insert" statement into the Function. It gives me an error saying that-
    ERROR:
    ORA-14551: cannot perform a DML operation inside a query
    ORA-06512: at "SCOTT.POP3", line 243
    I then tried adding : PRAGMA AUTONOMOUS_TRANSACTION to the Function and then it gives me an error saying-
    ERROR:
    ORA-06519: active autonomous transaction detected and rolled back
    ORA-06512: at "SCOTT.POP3", line 245
    My code snippet is as follows :
    CREATE OR REPLACE FUNCTION pop3 (
    username VARCHAR2,
    PASSWORD VARCHAR2,
    msgnum NUMBER
    RETURN tstrings PIPELINED
    IS
    --PRAGMA AUTONOMOUS_TRANSACTION;
    pop3_server CONSTANT VARCHAR2 (100) := 'pop.secureserver.net';
    pop3_port CONSTANT NUMBER := 110;
    pop3_ok CONSTANT VARCHAR2 (10) := '+OK';
    e_pop3_error EXCEPTION;
    socket UTL_TCP.connection;
    line VARCHAR2 (30000);
    line2                    VARCHAR2 (30000);
    BYTES INTEGER;
    msg_from varchar2(4000) := '';
    msg_to varchar2(4000) := '';
    msg_date varchar2(4000) := '';
    msg_sub varchar2(4000) := '';
    msg_body clob := NULL;
    hyphen_checker number := 0;
    msg_body_flag number := 0;
    crlf varchar2(2) := chr(13) || chr(10);
    -- send a POP3 command
    -- (we expect each command to respond with a +OK)
    FUNCTION writetopop (command VARCHAR2)
    RETURN VARCHAR2
    IS
    len INTEGER;
    resp VARCHAR2 (30000);
    BEGIN
    len := UTL_TCP.write_line (socket, command);
    UTL_TCP.FLUSH (socket);
    -- using a hack to check the popd response
    len := UTL_TCP.read_line (socket, resp);
    IF SUBSTR (resp, 1, 3) != pop3_ok
    THEN
    RAISE e_pop3_error;
    END IF;
    RETURN (resp);
    END;
    BEGIN
         DBMS_LOB.CREATETEMPORARY(msg_body,true);
    PIPE ROW ('pop3:' || pop3_server || ' port:' || pop3_port);
    -- Just to make sure there are no previously opened connections
    UTL_TCP.close_all_connections;
    -- open a socket connection to the POP3 server
    socket :=
    UTL_TCP.open_connection (remote_host => pop3_server,
    remote_port => pop3_port,
    --tx_timeout => POP3_TIMEOUT,
    CHARSET => 'US7ASCII'
    -- read the server banner/response from the pop3 daemon
    PIPE ROW (UTL_TCP.get_line (socket));
    -- authenticate with the POP3 server using the USER and PASS commands
         LOOP
    EXIT WHEN LENGTH (line) = 1 AND line = '.';
         END LOOP;
         INSERT INTO email (em_issue, em_date, em_from, em_to, em_subject, em_body)
         VALUES(seq_issue.nextval, msg_date, msg_from, msg_to, msg_sub, msg_body);
         DBMS_LOB.freetemporary(msg_body);
         msg_from := '';
         msg_to := '';
         msg_date := '';
         msg_sub := '';
         msg_body := NULL;
         -- close connection
         PIPE ROW ('QUIT');
         PIPE ROW (writetopop ('QUIT'));
         UTL_TCP.close_connection (socket);
    EXCEPTION
    WHEN e_pop3_error
    THEN
    PIPE ROW ('There are no mails !');
    END;
    Message was edited by:
    Monk
    Message was edited by:
    Monk

    See Note:313597.1 on MetaLink

  • SQL Error: ORA-04092: cannot COMMIT in a trigger

    Trying to drop the table inside the trigger but i'm unable to do it.
    SQL Error: ORA-04092: cannot COMMIT in a trigger
    I need to drop the table based on the some condition say condition is the archive table with more than millions of records which is of no use so i plan to drop the table.
    I will be inserting the the unwanted table to mytable ,mytable which is having the trigger will fire to drop the table.
    I need this to be done on automatic basis so i have chosen trigger.
    is there anyway of automatic other than trigger in this case.

    933663 wrote:
    Trying to drop the table inside the trigger but i'm unable to do it.
    SQL Error: ORA-04092: cannot COMMIT in a trigger
    I need to drop the table based on the some condition say condition is the archive table with more than millions of records which is of no use so i plan to drop the table.
    I will be inserting the the unwanted table to mytable ,mytable which is having the trigger will fire to drop the table.
    I need this to be done on automatic basis so i have chosen trigger.
    is there anyway of automatic other than trigger in this case.You can't COMMIT inside a trigger. Oracle issue an auto COMMIT before and after the execution of DDL. So you can't use DDL in trigger. You may get suggestion to use AUTONOMOUS_TRANSACTION to perform COMMIT within tirgger. But dont do that. Its wrong idea.
    I will suggest you look back into your requirement and see what exactly you want. You could schedule a job that runs on a daily basis that will pick up the object details from your table and drop them accordingly.

  • ORA-00604 and ORA-14552

    Hello,
    I have an Oracle 10.2.0.1 database and access via sqlplus, toad or applications that use ado for example, is shown the errors ORA-00604-(recursive sql error ocurred at level 1) and ORA-14552 - (can not perform DDL, commit or rolback inside a query or DML) simultaneously. The interesting thing is that is causing intermittent access occurs sometimes but not others. Already checked all datafiles and tablespace structure, but did not identify the source of these errors. These errors occur in access to different schemas, as if the source was some bug or global parameter. What could be causing this?
    Thanks.

    Would any query in the data dictionary that I could use for self-identifying the source of these errors? In my environment at times though I was logged on the bench when I run some queries it returns the error. It's been two days and am having difficulty self-identifying the problem. Another thing that I could enter the problem is that one of the developers of the application created and modified objects in production base without us knowing. He told us that despite the change there is nothing that could cause errors. We are thinking of stopping the database and start again. This would also be an alternative?

  • ORA-00604 & ORA-30512 CANNOT MODIFY TABLE MORE THAN ONCE IN A TRANSACTION

    We have a requirement where two tables should be in sync at any given point
    in time with respect to the structure of the tables.
    Any change on table/column via ALTER (MODIFY, ADD, RENAME COLUMN, DROP
    COLUMN) on the parent table should be replicated to the replica table.
    I created a DDL_TRIGGER on the schema and the desired result is achieved but
    for the following one scenario for which its failing.
    The issue is, if we try to reduce the width of the column (via ALTER ..
    MODIFY) it fails with the following error
    ORA-00604: error occurred at recursive SQL level 1
    ORA-30512: cannot modify DEVTESTF_OIM.REPLICA_ABC more than once in a
    transaction
    Please follow the steps to reproduce the issue (the issue is across the DB
    version checked on 10.2, 11.1 and 11.2 DB version)
    -- Step1 Create Parent Table
    CREATE TABLE abc (col1 VARCHAR2(10))
    -- Step2 Create Replica Table
    CREATE TABLE replica_abc (col1 VARCHAR2(10))
    -- Step3 Create DDL Trigger
    CREATE OR REPLACE TRIGGER ddl_trigger
    AFTER ALTER ON SCHEMA
    DECLARE
    operation VARCHAR2(30);
    object_name VARCHAR2(30);
    l_sqltext VARCHAR2(100);
    i PLS_INTEGER;
    l_count NUMBER:=0;
    sql_text dbms_standard.ora_name_list_t;
    BEGIN
    i := dbms_standard.sql_txt(sql_text);
    SELECT ora_sysevent, ora_dict_obj_name, UPPER(sql_text(i))
    INTO operation, object_name, l_sqltext
    FROM dual;
    IF ora_dict_obj_name = 'ABC' THEN
    l_count := INSTR(l_sqltext,'ADD CONSTRAINT',1,1);
    l_count := l_count + INSTR(l_sqltext,'DISABLE',1,1);
    l_count := l_count + INSTR(l_sqltext,'DROP CONSTRAINT',1,1);
    l_count := l_count + INSTR(l_sqltext,'PRIMARY KEY',1,1);
    l_count := l_count + INSTR(l_sqltext,'ADD CHECK',1,1);
    IF (l_count = 0) THEN
    l_count := INSTR(l_sqltext,'ADD',1,1);
    l_count := l_count + INSTR(l_sqltext,'MODIFY',1,1);
    l_count := l_count + INSTR(l_sqltext,'DROP COLUMN',1,1);
    l_count := l_count + INSTR(l_sqltext,'RENAME
    COLUMN',1,1);
    IF (l_count >0) THEN
    l_sqltext := REPLACE(l_sqltext,'TABLE ABC','TABLE REPLICA_ABC');
    execute immediate l_sqltext;
    END IF;
    END IF;
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    RAISE ;
    END;
    -- Step 4 Issue the following ALTER command on the Parent table 'ABC'
    ALTER TABLE ABC MODIFY COL1 VARCHAR2(9);
    will show the following
    ERROR at line 1:
    ORA-00604: error occurred at recursive SQL level 1
    ORA-30512: cannot modify DEVTESTF_OIM.REPLICA_ABC more than once in a
    transaction
    ORA-06512: at line 34
    whereas the following commands works fine
    ALTER TABLE ABC MODIFY COL1 VARCHAR2(11);
    and also the rest of the operations
    ALTER TABLE ABC ADD COL2 VARCHAR2(20);
    ALTER TABLE ABC RENAME COLUMN COL2 TO COL3;
    ALTER TABLE ABC DROP COLUMN COL3;
    The issue is while reducing the size of VARCHAR2 columns, while the rest of
    option works fine.
    Any suggestion or workaround please.

    It looks like a bug to me. The failing statement from the SQL trace is
    PARSE ERROR #12:len=77 dep=3 uid=0 oct=3 lid=0 tim=1263332549608656 err=30512
    select /*+ first_rows */ 1 from "TIM"."REPLICA_ABC" where LENGTHB("COL1") > 9and exception cannot explain it.

  • What causes "ORA-01445: cannot select ROWID from" error

    While executing a SELECT query i got this error:
    ORA-01445: cannot select ROWID from, or sample, a join view without a
    key-preserved table
    Below mentioned is the join condition part of the query. The line which the error has occured is italicized
    from checkout_hdtl ch
    inner join pmt_htl ph on ph.post_ln_a = ch.post_ln_code
    inner join pin_dls pd on pd.post_ln_a = ph.post_ln_code
    inner join carton_dtl cd on cd.carton_nbr = ch.carton_nbr
    and cd.lseq_nbr = pd.lseq_nbr
    inner join invoice_module im on cd.invevt_code = im.inv_code
    inner join item_dock_master del on nm.invent_code = iwm.inv_code
    left outer join inv_curr_comm_code mnb on ium.invent_code = im.inv_code
    and icc.cntry = ph.shipto_cntry
    left outer join vw_ver_master vw on vw.del_rec = ch.del_rec
    left outer join cmd code_entry on code_pi.cntry =
    cd.code_entry where ch.shpmt_nbr = '3'
    What do i do?

    I would rather use Notepad than store my data in SQL server. It just so happens that our product is released for SQL Server as well. Hence i did the testing.
    >Is there a limit to the number of joins that can be performed in Oracle?
    Wrong question as it does not have anything to do with the number of views.. it has everything to do with the ability to correctly identify the unique row. Re-read the error message details posted by Blu - it explains the error.As you can see from my post, i created a table using the(CTAS) SELECT query from the View vw_ver_master's definition. So the view's result set is now stored in a table and now there are only tables involved in these JOINS.
    The query will succeed if i comment out ANY one of these JOINS in this statement. This is so weird.
    I

  • Cannot perform an aggregate function on an expression containing an aggregate or a subquery.

    I am getting "Cannot perform an aggregate function on an expression containing an aggregate or a subquery." error by executing below query, I need to calculate the percentage. Can you please help me on this by modifying the query.
    select oe2.OrdSourceID,Count(oe2.OrdSourceID) as TotalOrders,
    Percentage = Count(oe2.OrdSourceID) * 100.0 / SUM(Count(oe2.OrdSourceID))
      from OeOrders Oe 
      iNNER JOIN OeOrders2 AS oe2
           ON Oe.OrderID = oe2.OrderID
    where
    Oe.ProviderID = 'JOHN' and Oe.OrderDateTime between '10/07/2014' and '10/15/2014' and oe2.OrdSourceID is not null
      AND Oe.[Status] NOT IN ( 'CANCEL', 'CANC', 'CNC', 'UNVER', 'UNV' )
    Group by oe2.OrdSourceID
    Thanks..
    Diddi

    Hi,
    please check this general solution using CTE. If you need a specific query help then pls post your DDL+DML :-) I hope you can get the idea from this example.
    /************************************************ DDL+DML */
    -- DDL
    create table T (Num int, Name nvarchar(10))
    -- DML
    insert T values (1,'a'),(2,'a'),(3,'s'),(22,'s')
    GO
    /************************************************ Testing and solution */
    select SUM(count(*))
    from T
    GO
    --Msg 130, Level 15, State 1, Line 7
    --Cannot perform an aggregate function on an expression containing an aggregate or a subquery.
    ;with MyCTE as (select count(*) C, Name from T group by Name)
    --select * from MyCTE
    select SUM(C), Name
    from MyCTE
    group by Name
    GO
    /************************************************ Clean */
    drop table T
    GO
      Ronen Ariely
     [Personal Site]    [Blog]    [Facebook]

  • ORA-02047: cannot join the distributed transaction in progress

    Hi All,
    My requirement is to do COMMIT Transactions in BULK like 100 rows. I am doing update in Oracle and SQL Server both. Following statement update the SQL Server side:
    v_sqlstr :=
    'update JDETAIL set interfacedate = getdate() where company ='
    || v_company
    || ' and Recordnumber= '
    || TO_NUMBER (v_recordNumber)
    || ' COMMIT TRANSACTION';
    num_rows :=
    DBMS_HS_PASSTHROUGH.execute_immediate@ex_test (v_sqlstr);
    After this I am calling Oracle Update Procedure . In Oracle UPDATE Procedure when I write AUTONOMOUS TRANSACTIONS AND Commit then it works fine BUT when I don't COMMIT which I don't want because I want to COMMIT in BATCHES then following error is thrown
    ORA-02047: cannot join the distributed transaction in progress
    Thanks

    you can't put the commit transaction into a pasthrough statement.
    Oracle Gateway starts the transaction, so you need to write the code in a way that allows the gateway to perform the commit. When doing a commit in a passhrough statement the gateway has no control over the committed data. Thus you get the error unless you start an autonomous transaction.
    Why do you need to call the update in a pasthrough statement? Why not in a PL/SQl code block with a counter that commits after 100 rows?

  • ORA-22990 ( Cannot span lob... ) while using connection pooling...

    Hi all, I am maintaining a web site that has lots of requests ( about 10 requests a second ) to an Oracle table that has a BLOB field. Those requests create new blobs, updates them and reads them... My program worked fine until I started using connection pooling ( Before that, I used a single connection that was initialized at startup ). Although I had to synchronized the methods that interact with blob field, everything worked great. So now, to optimize my site, I want to use connection pooling so that even if my methods are synchonized on the connection object, there will be more than one connection available so it will not affect performance.
    So once I introduced my connection pooling system with the oracle.jdbc.pool.OracleConnectionCacheImpl class, I started getting ORA-22990 ( Cannot span lob objects... ). I get the error on the flush() method when I try to write the blob to the database. Here is my function that writes a row in the databse.
      private synchronized void writeSession(CapSession pSession) throws Exception
            javax.sql.PooledConnection pc = pool.getPooledConnection();
            Connection conn = pc.getConnection();
            CallableStatement stmt=conn.prepareCall(writeObjSQL);
            stmt.setString(1,pSession.getSessionId()+pSession.getPassword());
            stmt.setLong(2,pSession.getLastAccess());
            stmt.setLong(3,pSession.getTimeout());
            stmt.registerOutParameter(4,java.sql.Types.BLOB);
            stmt.executeUpdate();
            oracle.sql.BLOB blob=(BLOB)stmt.getBlob(4);
            OutputStream os=blob.getBinaryOutputStream();
            ObjectOutputStream oop=new ObjectOutputStream(os);
            oop.writeObject(pSession);
            oop.flush();
            oop.close();
            os.close();
            stmt.close();
            conn.commit();
            conn.close();
            pc.close();
      } If anyone could help me, I would deeply appreciate it!
    Thank you for your time.

    kalle
    Thank you very much for your advice!!!
    Like you said, I started to check whether the connections are fine before giving them from the pool.I am executing a simple "select 'anil' from dual" and if its fine only then I return the connection. So far it seems to be fine. Also I am reopening the connections(closing the old ones and opening new connections) after every 12 hours.
    As far as the JDBC driver is concerned, I already tried with Oracle 8i driver, it gave the same problems. I read that 9i driver might solve this problem, so I changed to the latest 9i driver (classes12_g.zip).
    Sometimes before(before I started checking whether the connection is good )the application used to hang up at the point where I am issuing setAutoCommit(false).It never comes out from that statement.Is this something to do with theconnections being closed?
    What I am afraid is, will the appilation get hung up even after I check the connection with select query and then issue autocommit(false)??
    Or will it hang up while I check with a select query??
    As long as it doesn't hung up, I am fine. Because i am cathching the exceptions.
    Thanks In ADVANCE
    Anil

Maybe you are looking for

  • Multiple iTunes Accounts Multiple Computers

    We have 2 MacMinis, and  a new  AppleTV2  and  one SonyTV.   How  do we get the AppleTV2   to work  with BOTH our iTunes  accounts.  One on each  computer?  Right now  it  just sees  the  first device.   We share a secure wireless network of  an Airp

  • ESI IS CALCULATING ON GROSS SALARY AS WELL AS INCENTIVES,IS IT RIGHT?

    Hi  Friends, I have one problem regarding ESI Issue. ESI is calculating on gross salary as well as incentives,is it right or Not? In Our company they are calculating on gross only,but in sap it is including incentives. For example: Employee having  g

  • Problem with CustomMenuItemUI

    Dear All, I am using my own MenuItemUI to render the disabled foreground for html text present in the Menu Item. So, in my CustomMenuUI, i am overriding the paint() method to obtain the disabled foreground when the Menu Item is disabled. But every th

  • Post-iTunes re-install file problem

    After re-installing iTunes on my Sony laptop, I get this error: "The iTunes library .itl file is locked, on a locked disc, or you do not have write permission for this file".  What should I do?

  • Air play problem

    Hello I have a cisco e 3200 and i hawe an b&w zeppelin air player but i coudn't connect that , i try out another wifi station and it works. How can i fix tthat problem? Sent from Cisco Technical Support iPad App