Got error when use case statement in oracle stored procedure

Hi,
I have a query like:
select merchant_id,
case
when product_type='K' then 'Production'
when product_carrier='UC' THEN 'Shipping'
end the_type
from product_tbl
where merchant_id=10114
It works fine. But as soon as I put it into a stored procedure, I got error like:
Encountered the symbol "CASE" when expecting one of the following:
( - + mod null <an identifier>
Please help!

Oracle 8i doesn't support CASE into PL/SQL, so as Kamal said, create a view with the CASE, and use this view into your PL/SQL.
Nicolas.
And an example here :
Re: Execute Immediate doesnot work in 8i (8.1.7) and Ref Cursor not exec qu
Sorry Kamal.
Message was edited by:
N. Gasparotto

Similar Messages

  • Error When using web services on Oracle Application

    we are getting this error when we deployed code on Oracle Application, but same code working fine on Jdev.
    Exception java.rmi.RemoteException: ; nested exception is:
    HTTP transport error: javax.xml.soap.SOAPException: java.security.PrivilegedActionException: javax.xml.soap.SOAPException: Message send failed: For input string: ""
    [546]:ERROR:[fnd.common.Message.auto_log]:FNDICX_JAVASCRIPT_DISCLAIMER
    Regards,
    Vivek Gautam

    Are you sure that you have posted your question to the correct forum? This forum is only for Oracle Enterprise Manager related issues.

  • Extraction SQL statement from oracle stored procedure stored in file

    Hi,
    I am newbie to oracle stored procedure. I need to extract the list of sqls present in oracle stored procedure. Besides that I also want to parse these sql statements to get the list of tables and columns used. Is there any tool which can help me in doing thats.
    thanks,
    govind

    why don't check on user_dependencies table instead?
    select referenced_name,referenced_type
    from user_dependencies
    where name='<your stored procedure name in upper case>'
    and referenced_type = 'TABLE'HTH,
    Prazy

  • ADO memory leak when getting Recordset from an Oracle stored procedure?

    I am programming in C++ (VC 6) and using ADO 2.7 to
    access Oracle 9i database. My connection string looks
    like this:
    Provider=MSDAORA.1;Persist Security Info=True;User ID=scott;Password=tiger;Data Source=blahblah
    I have Oracle stored procedure that returns data in a
    REF CURSOR output parameter. Since the stored procedure
    takes input parameters, I prepare a Command object with
    Parameters initialized and attached to it. I use the
    Recordset Open method to execute the call. This approach
    works because I get correct data back from the call in
    the Recordset, but the problem is when I do this in a
    infinite loop and watch the process in Windows Taks
    Manager, I see 4k or 8k memory delta all the time and
    the Peak Memory Usage of the process keeping going up.
    I hope someone knows something in this scenario and points
    me to the right direction.
    Thanks, please see the following code for specifics.
    HRESULT CallSP3Params(VARIANT vp1, VARIANT vp2, int spretcode, LPDISPATCH ppRSet, char *pCmdLine)
         _RecordsetPtr     pRs;
         _CommandPtr     pCmd;
         _ParameterPtr     paramVProfiler[3];
         bstrt          strMissing(L"");
         *ppRSet = NULL;
         variantt          ErrConn;
         ErrConn.vt = VT_ERROR;
         ErrConn.scode = DISP_E_PARAMNOTFOUND;
         try {
         //Create instance of command object
         pCmd.CreateInstance(__uuidof(Command));
         pRs.CreateInstance(__uuidof(Recordset));
              if ( vp1.vt == VT_BSTR ) {
                   paramVProfiler[0] = pCmd->CreateParameter("P1",adVarChar,adParamInput,SysStringLen(vp1.bstrVal) + 10,strMissing );
                   paramVProfiler[0]->Value = vp1;
              else if ( vp1.vt == VT_I4 )
                   paramVProfiler[0] = pCmd->CreateParameter("P1",adNumeric,adParamInput,15,vp1);
              else
                   TESTHR( PARAMETER_OPERATION_ERROR );
              pCmd->Parameters->Append(paramVProfiler[0]);
              if ( vp2.vt == VT_BSTR ) {
                   paramVProfiler[1] = pCmd->CreateParameter("P2",adVarChar,adParamInput,SysStringLen(vp2.bstrVal) + 10,strMissing );
                   paramVProfiler[1]->Value = vp2;
              else if ( vp2.vt == VT_I4 )
                   paramVProfiler[1] = pCmd->CreateParameter("P2",adNumeric,adParamInput,15,vp2);
              else
                   TESTHR( PARAMETER_OPERATION_ERROR );
              pCmd->Parameters->Append(paramVProfiler[1]);
              paramVProfiler[2] = pCmd->CreateParameter("RETCODE",adNumeric,adParamOutput,10);
              pCmd->Parameters->Append(paramVProfiler[2]);
         //Catch COM errors
         catch( comerror &e) {
         try {
         // I manage my connection through this little C++ class of my own
         CCUsage myconnection( &Connectionkeeper[0] );
         //Set the active connection property of command object to open connection
         pCmd->ActiveConnection = myconnection.m_conn;
         //The command type is text
         pCmd->CommandType = adCmdText;
         //Set command text to call the stored procedure
         pCmd->CommandText = pCmdLine;
         //Open the Recordset to get result
         pRs->Open( variantt((IDispatch *)pCmd,true), ErrConn, adOpenStatic, adLockReadOnly, adOptionUnspecified );
         //Disconnect the command object
         pCmd->PutRefActiveConnection( NULL );
         if ( GetSPRetCode( pCmd, "RETCODE", spretcode ) != S_OK )
              TESTHR(DB_OBJECT_OPERATION_ERROR);
         // pRs->QueryInterface(IID_IDispatch, (void**) ppRSet);
         // I return the Recordset by calling QueryInterface, but even without that, closing the Recordset right here still shows memory leak.
         pRs->Close( );
         pRs = NULL;
         //Catch COM errors
    catch (_com_error e) {
         return S_OK;
    }

    Whenever large numbers of BSTRs are allocated and freed quickly the process memory will continue to climb towards a stabalizing value. BSTRs are not freed until the system frees them. You can see this by making many calls allocating and freeing BSTRs, memory will climb, but when you stop for a while the gargage collection of the sys strings will take place. I've done much research to see that a server doing many queries very rapidly is not leaking memory, but out pacing the garbage collection, it will stabilize and when the process has some "rest time" the processes memory usage will decline.
    In my research a suspected memory leak was not one.

  • Statement closed when using callable statements with oracle xe

    hi all, i've got this problem with oracle express edition 10g. I am using also oc4j v10.1.2.0.2. When working with a normal oracle database it was working fine (i think the code was the same, it's some time since i last tried, but you can see the code is very simple).
    So i just create a callable statement like this:
    CallableStatement cs = con.prepareCall(sentencia.toString(), ResultSet.TYPE_SCROLL_INSENSITIVE, ResultSet.CONCUR_UPDATABLE, ResultSet.HOLD_CURSORS_OVER_COMMIT);
    and then when trying to access the statement to register an out parameter like this
    cs.registerOutParameter(1, parámetros[0].getTipo());
    it gives this error:
    java.sql.SQLException: Statement was closed
    It's puzzling me because, as i said before, i think the same code was working ok with a normal oracle database.
    Any idea what can it be?
    cheers

    Ah okay, sorry I've re-read your post.
    I believe you need to create a clob object that encapsulates your xml file.
    I've never done this but I would image it involves creating a class that implements the clob interface and passing an instantiation of this class to the callablestatement.
    Let me know how you get on.

  • Compiler error when useing switch statements in an inner class

    I have defined several constants in a class and want to use this constans also in an inner class.
    All the constants are defined as private static final int.
    All works fine except when useing the switch statement in the inner class. I get the compiler error ""constant expression required". If I change the definition from private static final to protected static final it works, but why?
    What's the difference?
    Look at an example:
    public class Switchtest
       private static final int AA = 0;     
       protected static final int BB = 1;     
       private static int i = 0;
       public Switchtest()
          i = 0; // <- OK
          switch(i)
             case AA: break; //<- OK, funny no problem
             case BB: break; //<- OK
             default: break;
      private class InnerClass
          public InnerClass()
             i = 0; // <- OK: is accessible
             if (AA == i) // <- OK: AA is seen by the inner class; i  is also accessible
                i = AA + 1;
             switch(i)
                case AA: break; // <- STRANGE?! Fail: Constant expression required
                case BB: break; // <- OK
                default: break;
    }Thank's a lot for an explanation.

    Just a though:
    Maybe some subclass of Switchtest could decalare its own variable AA that is not final, but it can not declare its own BB because it is visible from the superclass. Therefore the compiler can not know for sure that AA is final.

  • Corrupt data error when using Windows backup on Oracle

    Our SAP servers include a SDLT internal tape drive that we use for doing a complete system backup.  When using Windows Backup we get the following message in the backup log:
    WARNING: Portions of "\oracle\T00\sapdata1\protd_2\PROTD.DATA2" cannot be read.  The backed up data is corrupt or incomplete.
    This file will not restore correctly.
    This is occuring on a couple of different systems but the wierd thing is when this happens in occurs on one Oracle drive in one system and the other Oracle drive on another system i.e. the G: drive on our TST sysytem and the E: drive on another.  The E: and G: drives contain the main Oracle datafiles.
    Has anybody ever encounter something like this and what can I do about it?
    Thanks;
    Gale S.

    Especially no backup tool would know about the
    fact
    that a Oracle block had been changed after it was
    copied.
    Now I have to contracdict
    There are backup tools (e. g. OpenFile Manager from
    Legato/EMC), that track the filesystem changes and
    makes sure, the backups are consistent in sense of
    filesystem blocks. We´re backing up some ORA
    databases (non-SAP, 7.3.4 and 8.1.7) for ages now -
    and I never saw this kind of corruptions.
    Well, these Backup-Tools do perform copies I/O-Consistent. That's different than DB-Block-consistent in the first place. Anyhow due to the fact that the DBMS do have a syncronizing between I/Os and writing out the blocks this leads both to consistent blocks.
    I just wonder, how the database would deal with such
    "inconsistent" files. Given the fact, you start a
    backup at filesystem block 0, the database is being
    backed up and a transaction is committed and
    something is written to block 100, 200 and 500. The
    backup is on block 300. If you now restore the
    database, it has the already commited block 500 in
    the file but 100 and 200 are not yet written in the
    database file. The redo will then find an already
    commited transaction on 500. What magic will tell the
    engine, that this is due to an online database
    backup? I mean, if you set the tablespace to backup,
    the engine "knows" the state - but if you just backup
    the file, the engine is unaware of that... I´m just
    curious how this is handled...
    Well the trick here is: we tell the database before we plan to copy the data. When a ONLINE backup is done, the tablespaces are set into BACKUP mode. This changes two things for us:
    1. The datafile headers of these tablespaces are not updated anymore although dirty blocks are still written out to these files. Since the control files that keep the SCN (system change number) are updated nevertheless, the database will know at recovery time that these files had been in online backup mode and do need recovery to become consistent again.
    2. The UNDO-information is not only written out to the UNDO/ROLLBACK-Tablespace but additionally to the REDOLOGS. So, for the time where the tablespaces are in BACKUP mode, we have all information needed to make a block consistent again - regardless if a transaction had been commited or rolled back - in the redolog. So a full recovery of all changes is possible with
    that.
    That's basically the "magic" behind this.
    If the copy of the datafile is done without this - well, then there's no magician in the world that would been able to get it consistent again. Online Backups with Oracle are only possible with BACKUP mode or RMAN (ok, and possible some 3rd party hacks...).
    KR Lars

  • Callable statement with oracle stored procedure error

    i'm calling a stored procedure in java with the following code. However i constantly recieve this error
    so what is going on please HELP
    Parameter Type Conflict: sqlType=2006
    my call statement would be this:
    call Statement = {call getUserByLogin(?,?,?,?)}
    if(storedProcedureName=="getUserByLogin"){
    strCStmt = ("{call " + storedProcedureName +"(?,?,?,?) }");
    cStmt.setObject(1, "system");
    cStmt.setObject(2, "username");
    cStmt.setObject(3,"password");
    cStmt.registerOutParameter(4, java.sql.Types.REF);
    rs = cStmt.executeQuery();
    i've also tried it with a setString as the IN parameter:
    here's the stored procedure:
    CREATE OR REPLACE PROCEDURE getUserByLogin (
    arg_subscriptionName IN varchar,
    arg_loginName IN varchar,
    arg_password IN varchar,
    arg_rec_userinfo_valLanguage OUT types.rec_userinfo_valLanguage
    ) AS
    var_userNum int;
    BEGIN
    select
    u.userNum into var_userNum
    from
    userInfo u,
    subscription s
    where
    s.subscriptionName = arg_subscriptionName AND
    s.subscriptionNum = u.subscriptionNum AND
    u.loginName = arg_loginName AND
    u.password = arg_password;
    if (var_userNum is null) then
    var_userNum := 0;
    end if;
    getUser(var_userNum, arg_rec_userinfo_valLanguage);
    END;

    i'm calling a stored procedure in java with the
    following code. However i constantly recieve this
    error
    so what is going on please HELP
    Parameter Type Conflict: sqlType=2006
    my call statement would be this:
    call Statement = {call getUserByLogin(?,?,?,?)}
    if(storedProcedureName=="getUserByLogin"){
    strCStmt = ("{call " + storedProcedureName +"(?,?,?,?)
    cStmt.setObject(1, "system");
    cStmt.setObject(2, "username");
    cStmt.setObject(3,"password");
    cStmt.registerOutParameter(4, java.sql.Types.REF);
    rs = cStmt.executeQuery();
    i've also tried it with a setString as the IN
    parameter:
    here's the stored procedure:
    CREATE OR REPLACE PROCEDURE getUserByLogin (
    arg_subscriptionName IN varchar,
    arg_loginName IN varchar,
    arg_password IN varchar,
    arg_rec_userinfo_valLanguage OUT
    types.rec_userinfo_valLanguage
    ) AS
    var_userNum int;
    BEGIN
    select
    u.userNum into var_userNum
    from
    userInfo u,
    subscription s
    where
    s.subscriptionName = arg_subscriptionName AND
    s.subscriptionNum = u.subscriptionNum AND
    u.loginName = arg_loginName AND
    u.password = arg_password;
    if (var_userNum is null) then
    var_userNum := 0;
    end if;
    getUser(var_userNum, arg_rec_userinfo_valLanguage);
    END;
    /Hai,
    Try with this if u are using Oracle.
    import oracle.sql.*;
    import oracle.jdbc.driver.*;
    (inbetween ur code)
    cStmt.registerOutParameter(4, OracleTypes.CURSOR);
    //in place of "cStmt.registerOutParameter(4, java.sql.Types.REF);"
    Hope u reply with joy.
    regards,
    Siva Kumar Annavaram

  • Received error when using Execute_Immediate proc in Oracle 8.0

    Hi,
    I was trying to use the execute_immediate proc (slightly
    revised, for testing). When I run it with a 'Delete' statement
    in it (or passed in), it works fine. But, when I use
    an 'Update' or 'Insert' statement in it, I get the error below,
    even though the proc compiled okay and it's in the database okay.
    SQL> exec Exec_Immed;
    begin Exec_Immed; end;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00905: object TEST.EXEC_IMMED is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I tried using both the SQL stmts below (one at a time), but got
    the same error.
    CREATE OR REPLACE PROCEDURE Exec_Immed /*(v_SQLStmt IN VARCHAR2)
    IS
    v_CursorID INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    v_SQLStmt VARCHAR2(100);
    v_RetRows INTEGER;
    BEGIN
    v_SQLStmt := 'Update emp SET fname = ''David'' WHERE empno =
    40';
    v_SQLStmt := 'Insert into softlookup
    (softno,softname,updatedon,updatetype) values
    (50,''VS7'',sysdate,''A'')';
    DBMS_SQL.PARSE (v_CursorID, v_sqlstmt, DBMS_SQL.native);
    v_RetRows := DBMS_SQL.EXECUTE(v_CursorID);
    DBMS_SQL.CLOSE_CURSOR(v_CursorID);
    END;

    The simplest way to do what you are doing is to use a SQL
    statement by itself, either from the SQL prompt or from a .sql
    file:
    SQL> Update emp
      2  SET    ename = 'David'
      3  WHERE  empno = 40
      4  /
    0 rows updated.
    SQL> Insert into softlookup
      2    (softno,softname,updatedon,updatetype)
      3  values (50,'VS7',sysdate,'A')
      4  /
    1 row created.
    Or, if you want to do it from an anonymous pl/sql block:
    SQL> BEGIN
      2    Update emp
      3    SET    ename = 'David'
      4    WHERE  empno = 40;
      5    Insert into softlookup
      6      (softno,softname,updatedon,updatetype)
      7    values (50,'VS7',sysdate,'A');
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    Or, if you want to do it in a procedure:
    SQL> CREATE OR REPLACE PROCEDURE procedure_name
      2  AS
      3  BEGIN
      4    Update emp
      5    SET    ename = 'David'
      6    WHERE  empno = 40;
      7    Insert into softlookup
      8      (softno,softname,updatedon,updatetype)
      9    values (50,'VS7',sysdate,'A');
    10  END procedure_name;
    11  /
    Procedure created.
    SQL> EXEC procedure_name
    PL/SQL procedure successfully completed.
    If you want to use DBMS_SQL to do it, even though it is
    unnecessary:
    SQL> CREATE OR REPLACE PROCEDURE procedure_name
      2  IS
      3    v_CursorID        INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
      4    v_RetRows         INTEGER;
      5    v_SQLStmt         VARCHAR2 (4000);
      6  BEGIN
      7    v_SQLStmt := 'Update emp
      8                 SET    ename = ''David''
      9                 WHERE  empno = 40';
    10    DBMS_OUTPUT.PUT_LINE (v_SQLStmt);
    11    DBMS_SQL.PARSE (v_CursorID, v_SQLStmt, DBMS_SQL.NATIVE);
    12    v_RetRows := DBMS_SQL.EXECUTE (v_CursorID);
    13    DBMS_SQL.CLOSE_CURSOR (v_CursorID);
    14    v_SQLStmt := 'Insert into softlookup '
    15               || ' (softno,softname,updatedon,updatetype) '
    16             || ' values (50,''VS7'',sysdate,''A'')';
    17    v_CursorID := DBMS_SQL.OPEN_CURSOR;
    18    DBMS_OUTPUT.PUT_LINE (v_SQLStmt);
    19    DBMS_SQL.PARSE (v_CursorID, v_SQLStmt, DBMS_SQL.NATIVE);
    20    v_RetRows := DBMS_SQL.EXECUTE (v_CursorID);
    21    DBMS_SQL.CLOSE_CURSOR (v_CursorID);
    22  END procedure_name;
    23  /
    Procedure created.
    SQL> EXEC procedure_name
    Update emp
                   SET    ename = 'David'
                   WHERE  empno =
    40
    Insert into softlookup  (softno,softname,updatedon,updatetype) 
    values
    (50,'VS7',sysdate,'A')
    PL/SQL procedure successfully completed.
    Since you are using Oracle 8.0 and cannot use EXECUTE IMMEDIATE,
    if you want to use some variation, which is also unnecessary,
    then you can do something like I have shown below.  Note that
    the Exec_Immed procedure needs to be a procedure all by itself
    and not be modified.  Otherwise, you are defeating the purpose
    of substituting it for EXECUTE IMMEDIATE and not having to
    duplicate code.  The idea of using the Exec_Immed is to only
    create that procedure which contains all of the DBMS_SQL once,
    then use the really simple code below that to execute SQL
    statements from a pl/sql block.  If you are going to modify it,
    then you might as well use the DBMS_SQL method listed above.  In
    the version below, I have used the variable names and so forth
    that you have substituted for the original, as much as possible:
    SQL> CREATE OR REPLACE PROCEDURE Exec_Immed
      2    (v_SQLStmt IN VARCHAR2)
      3  IS
      4    v_CursorID       INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
      5    v_RetRows        INTEGER;
      6  BEGIN
      7    DBMS_SQL.PARSE (v_CursorID, v_SQLStmt, DBMS_SQL.NATIVE);
      8    v_RetRows := DBMS_SQL.EXECUTE (v_CursorID);
      9    DBMS_SQL.CLOSE_CURSOR (v_CursorID);
    10  END Exec_Immed;
    11  /
    Procedure created.
    Then, to use your Exec_Immed procedure from an anonymous pl/sql
    block:
    SQL> BEGIN
      2    Exec_Immed ('Update emp
      3                 SET    ename = ''David''
      4                 WHERE  empno = 40');
      5    Exec_Immed ('Insert into softlookup
      6                   (softno,softname,updatedon,updatetype)
      7                 values (50,''VS7'',sysdate,''A'')');
      8  END;
      9  /
    PL/SQL procedure successfully completed.
    Or, to call your Exec_Immed procedure from another procedure:
    SQL> CREATE OR REPLACE PROCEDURE procedure_name
      2  AS
      3  BEGIN
      4    Exec_Immed ('Update emp
      5                 SET    ename = ''David''
      6                 WHERE  empno = 40');
      7    Exec_Immed ('Insert into softlookup
      8                   (softno,softname,updatedon,updatetype)
      9                 values (50,''VS7'',sysdate,''A'')');
    10  END procedure_name;
    11  /
    Procedure created.
    SQL> EXEC procedure_name
    PL/SQL procedure successfully completed.

  • Invalid number error when using case when

    I have table called NATIONAL_RARE_ECOSYSTEMS which has 1 column called TEST_COLUMN (data type: varchar2):
    TEST_COLUMN
    rare ecosystem
    rare
    0
    0
    (null)
    (null)
    what I want is a query which will add a column called NRE_SCORE which will give each row instance a score of 0 if it null.
    If it is 0 then score should be 0.
    If the row contains any text then score should be 1
    I have written the query:
    SELECT
    (CASE WHEN test_column is null THEN 0
    WHEN test_column = 0 THEN 0
    WHEN test_column > 0 THEN 1
    END) AS NRE_SCORE
    FROM NATIONAL_RARE_ECOSYSTEMS;
    I get the error message:
    ORA-01722: invalid number
    01722. 00000 - "invalid number"
    I think this is because on the 2nd and 3rd line I'm trying to do arithmetic on a column which is varchar2 which I know I cant do.
    How do I write a query which says: if the row contains text then give score of 1?
    I'm using oracle 11g.

    Hi,
    993451 wrote:
    I have table called NATIONAL_RARE_ECOSYSTEMS which has 1 column called TEST_COLUMN (data type: varchar2):
    TEST_COLUMN
    rare ecosystem
    rare
    0
    0
    (null)
    (null)
    what I want is a query which will add a column called NRE_SCORE which will give each row instance a score of 0 if it null.
    If it is 0 then score should be 0.
    If the row contains any text then score should be 1Any text other than '0', you mean. I assume it doesn't matter if that text happens to be all digits, such as '9876', or something with no digits, such as 'rare'.
    I have written the query:
    SELECT
    (CASE WHEN test_column is null THEN 0
    WHEN test_column = 0 THEN 0
    WHEN test_column > 0 THEN 1
    END) AS NRE_SCORE
    FROM NATIONAL_RARE_ECOSYSTEMS;
    I get the error message:
    ORA-01722: invalid number
    01722. 00000 - "invalid number"
    I think this is because on the 2nd and 3rd line I'm trying to do arithmetic on a column which is varchar2 which I know I cant do.You're actually not doing any arithmetic, but you are comparing your VARCHAR2 column to a NUMBER, so it tries to convert the string to a NUMBER, and that's why you get the ORA-01722 error.
    >
    How do I write a query which says: if the row contains text then give score of 1?
    I'm using oracle 11g.Here's one way:
    SELECT       CASE
               WHEN  NVL (test_column, '0') = '0'
               THEN  0
               ELSE  1
           END          AS nre_score
    ,       ...          -- you must want other columns, too
    FROM       national_rare_ecosystems
    ;Since you don't really care about the numeric value, don't use NUMBERs anywhere; stick with VARCHAR2s, such as '0'.
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only), and also post the results you want from that data.
    Point out where the query above is getting the wrong results, and explain, using specific examples, how you get those results from the sample data in those palces.
    See the forum FAQ {message:id=9360002}

  • Received error when using Execute_Immediate proc in Oracle 8.0.3

    Hi,
    I was trying to use the execute_immediate proc (slightly
    revised, for testing). When I run it with a 'Delete' statement
    in it (or passed in), it works fine. But, when I use
    an 'Update' or 'Insert' statement in it, I get the error below,
    even though the proc compiled okay and it's in the database okay.
    SQL> exec Exec_Immed;
    begin Exec_Immed; end;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00905: object TEST.EXEC_IMMED is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I tried using both the SQL stmts below (one at a time), but got
    the same error.
    CREATE OR REPLACE PROCEDURE Exec_Immed /*(v_SQLStmt IN VARCHAR2)
    IS
    v_CursorID INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    v_SQLStmt VARCHAR2(100);
    v_RetRows INTEGER;
    BEGIN
    v_SQLStmt := 'Update emp SET fname = ''David'' WHERE empno =
    40';
    v_SQLStmt := 'Insert into softlookup values
    (50,''VS7'',sysdate,''A'')';
    DBMS_SQL.PARSE (v_CursorID, v_sqlstmt, DBMS_SQL.native);
    v_RetRows := DBMS_SQL.EXECUTE(v_CursorID);
    DBMS_SQL.CLOSE_CURSOR(v_CursorID);
    END;

    Hi,
    I was trying to use the execute_immediate proc (slightly
    revised, for testing). When I run it with a 'Delete' statement
    in it (or passed in), it works fine. But, when I use
    an 'Update' or 'Insert' statement in it, I get the error below,
    even though the proc compiled okay and it's in the database okay.
    SQL> exec Exec_Immed;
    begin Exec_Immed; end;
    ERROR at line 1:
    ORA-06550: line 1, column 7:
    PLS-00905: object TEST.EXEC_IMMED is invalid
    ORA-06550: line 1, column 7:
    PL/SQL: Statement ignored
    I tried using both the SQL stmts below (one at a time), but got
    the same error.
    CREATE OR REPLACE PROCEDURE Exec_Immed /*(v_SQLStmt IN VARCHAR2)
    IS
    v_CursorID INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
    v_SQLStmt VARCHAR2(100);
    v_RetRows INTEGER;
    BEGIN
    v_SQLStmt := 'Update emp SET fname = ''David'' WHERE empno =
    40';
    v_SQLStmt := 'Insert into softlookup values
    (50,''VS7'',sysdate,''A'')';
    DBMS_SQL.PARSE (v_CursorID, v_sqlstmt, DBMS_SQL.native);
    v_RetRows := DBMS_SQL.EXECUTE(v_CursorID);
    DBMS_SQL.CLOSE_CURSOR(v_CursorID);
    END;

  • Trying to get prior error when using deferred constaint on Oracle database

     

    Hi Greg,
    There is no direct way to retrieve a error as an original exception
    is wrapped. Also, it's problematic to report constraint violations
    in general as different DB vendors use different ways to report them.
    You may try to correct problem by extracting text of the exception
    and looking for certain string patterns using direct string parsing
    or regexps.
    Regards,
    Slava Imeshev
    "Sanjeev Chopra" <[email protected]> wrote in message
    news:3d5aa128$[email protected]..
    posting to ejb newsgroup
    "Greg James" <[email protected]> wrote in message
    news:[email protected]..
    I'm using an Oracle database which has deferred constraints enabled. I'musing
    Weblogic 5.1 and Java. The problem is that the deferred constraints
    don't
    report
    errors until a commit. This makes all errors report back to the java EJBcode
    as error code 2091: Transaction Rolled Back. Both errors show up in theWeblogic
    log file so there must be some way for my EJB to access it. How can I
    get
    the
    error code of the actual cause?

  • Stange error when using dbms_metadata.get_ddl in PL/SQL procedure

    Basic info:
    Oracle 10.2.0.4.0 on linux.
    I'm trying to extract ddl of indexes that I drop and recreate frequently during monthly loads and store it in a table.
    This statement works on the command line:
    insert into saved_indexes
    select index_name,dbms_metadata.get_ddl('INDEX',index_name,owner_name)
    from sys.all_indexes
    where owner = owner_name
    and table_name = table_name;
    commit;
    The table 'saved_indexes' is a two column table with a varchar2(40) and a CLOB.
    When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.
    PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2) IS
    v_errorcode number(8);
    v_errortext varchar2(1000);
    v_start_time date;
    BEGIN
    insert into saved_indexes
    select index_name,dbms_metadata.get_ddl('INDEX',index_name,v_owner)
    from sys.all_indexes
    where owner = v_owner
    and table_name = v_table;
    commit;
    EXCEPTION
    WHEN others THEN
    v_errorcode := sqlcode;
    v_errortext := substr(sqlerrm, 1, 1000);
    dbms_output.put_line(v_errortext || ' ' || v_errorcode);
    END;
    Alternatively I have tried it this way:
    PROCEDURE SAVE_INDEXES (v_table IN VARCHAR2, v_owner IN VARCHAR2 ) IS
    v_errorcode number(8);
    v_errortext varchar2(1000);
    v_index_ddl CLOB;
    BEGIN
    for x in (select index_name
    from sys.all_indexes
    where owner = v_owner
    and table_name = v_table)
    loop
    select dbms_metadata.get_ddl('INDEX',x.index_name,v_owner) into v_index_ddl from dual;
    insert into saved_indexes
    values(v_table,v_index_ddl);
    end loop;
    commit;
    EXCEPTION
    WHEN others THEN
    v_errorcode := sqlcode;
    v_errortext := substr(sqlerrm, 1, 1000);
    dbms_output.put_line(v_errortext || ' ' || v_errorcode);
    END;
    Always with the same result. I have poured over the documentation on this and have not found anything. All objects are in the same schema, so there is not an issues with invokers rights, or privileges.
    Any suggestions would be helpful...

    qwe11126 wrote:
    When I use the following procedure, I get 'ORA-04044 procedure, function, package, or type is not allowed here -4044' every time.There is nothing wrong with SP. Post a snippet of SQL*Plus code showing how you call SP along with errors.
    SY.

  • Case Statement in Oracle Query.

    Hello Oracle Gurus,
    I need suggestion on whether I should use Case statement in Oracle queries.
    I have a sql statement which inserts the data by selecting data from other table. While selecting the data I have put a logic in the select statement for one column which is something like this and there are some more similar statements in the same query.
    CASE
                   WHEN (b.ACCOUNT = 'FIN' or b.ACCOUNT ='FIN ACC' or b.ACCOUNT like '%Global Eq%' or b.ACCOUNT like '%Flexible Bond%')
                   THEN
                        'MTM'
                             WHEN (substr(a.CTC,-3)='MTM')
                   THEN
                        'MTM'
                             WHEN (substr(a.CTC,-3)='AFS' or substr(a.CTC,-3)='HTM' OR substr(a.CTC,-3)='ACC' OR substr(a.CTC,-3)='HFI' )
                   THEN
                        'ACC'
                   ELSE
                                  'OTH'
              END,
    I wanted to get an suggestion about how much performance issue can I have due to this in my insert statement.
    Let me know if you need any other information.All comments are really appreciated.

    Hi,
    It's depends on the joins how you have performed with source table, stats and existing of indexes. If the volume of data is high - in case of any performance issue - why can't you perform the required things of logical conditions of data and popualte in one cluster so - that you can fetch out the chunks of required information with better way and in support with indexes.
    Let us know the ful query your working on
    Oracle version
    Explain plans - get it from dbms_xplan.
    - Pavan Kumar N
    - ORACLE - 9i/10g - OCP
    RHCE - Enterprize Linux 5.4

  • Not able to retrive the recordset from oracle stored procedure in VC++

    Hi,
    I am trying to retrieve the records from the reference cursor which is an out parameter for an oracle 9i store procedure in VC++ application. But it is giving the record count as -1 always. Meanwhile i am able to get the required output in VB application from the same oracle 9i store procedure .
    Find the code below which i used.
    Thanks,
    Shenba
    //// Oracle Stored Procedure
    <PRE lang=sql>CREATE OR REPLACE
    PROCEDURE GetEmpRS1 (p_recordset1 OUT SYS_REFCURSOR,
    p_recordset2 OUT SYS_REFCURSOR,
    PARAM IN STRING) AS
    BEGIN
    OPEN p_recordset1 FOR
    SELECT RET1
    FROM MYTABLE
    WHERE LOOKUPVALUE > PARAM;
    OPEN p_recordset2 FOR
    SELECT RET2
    FROM MYTABLE
    WHERE LOOKUPVALUE >= PARAM;
    END GetEmpRS1;</PRE>
    ///// VC++ code
    <PRE lang=c++ id=pre1 style="MARGIN-TOP: 0px">ConnectionPtr mpConn;
    _RecordsetPtr pRecordset;
    _CommandPtr pCommand;
    _ParameterPtr pParam1;
    //We will use pParam1 for the sole input parameter.
    //NOTE: We must not append (hence need not create)
    //the REF CURSOR parameters. If your stored proc has
    //normal OUT parameters that are not REF CURSORS, you need
    //to create and append them too. But not the REF CURSOR ones!
    //Hardcoding the value of i/p paramter in this example...
    variantt vt;
    vt.SetString("2");
    m_pConn.CreateInstance (__uuidof (Connection));
    pCommand.CreateInstance (__uuidof (Command));
    //NOTE the "PLSQLRSet=1" part in
    //the connection string. You can either
    //do that or can set the property separately using
    //pCommand->Properties->GetItem("PLSQLRSet")->Value = true;
    //But beware if you are not working with ORACLE, trying to GetItem()
    //a property that does not exist
    //will throw the adErrItemNotFound exception.
    m_pConn->Open (
    bstrt ("Provider=OraOLEDB.Oracle;PLSQLRSet=1;Data Source=XXX"),
    bstrt ("CP"), bstrt ("CP"), adModeUnknown);
    pCommand->ActiveConnection = m_pConn;
    pParam1 = pCommand->CreateParameter( bstrt ("pParam1"),
    adSmallInt,adParamInput, sizeof(int),( VARIANT ) vt);
    pCommand->Parameters->Append(pParam1);
    pRecordset.CreateInstance (__uuidof (Recordset));
    //NOTE: We need to specify the stored procedure name as COMMANDTEXT
    //with proper ODBC escape sequence.
    //If we assign COMMANDTYPE to adCmdStoredProc and COMMANDTEXT
    //to stored procedure name, it will not work in this case.
    //NOTE that in the escape sequence, the number '?'-s correspond to the
    //number of parameters that are NOT REF CURSORS.
    pCommand->CommandText = "{CALL GetEmpRS1(?)}";
    //NOTE the options set for Execute. It did not work with most other
    //combinations. Note that we are using a _RecordsetPtr object
    //to trap the return value of Execute call. That single _RecordsetPtr
    //object will contain ALL the REF CURSOR outputs as adjacent recordsets.
    pRecordset = pCommand->Execute(NULL, NULL,
    adCmdStoredProc | adCmdUnspecified );
    //After this, traverse the pRecordset object to retrieve all
    //the adjacent recordsets. They will be in the order of the
    //REF CURSOR parameters of the stored procedure. In this example,
    //there will be 2 recordsets, as there were 2 REF CURSOR OUT params.
    while( pRecordset !=NULL ) )
    while( !pRecordset->GetadoEOF() )
    //traverse through all the records of current recordset...
    long lngRec = 0;
    pRecordset = pRecordset->NextRecordset((VARIANT *)lngRec);
    //Error handling and cleanup code (like closing recordset/ connection)
    //etc are not shown here.</PRE>

    It can be linked to internal conversion. In some case, the value of internal or extranal value is not the same.
    When you run SE16 (or transaction N), you have in option mode the possibility to use the exit conversion or not.
    Christophe

Maybe you are looking for

  • Jump to wrong location

    I have a project with about 85 slides that was built with Captivate 4. Many of the slides have buttons that jump to other slides for branching within the presentation. On one of the buttons it is jumping to the wrong slide when I deploy it to our LMS

  • Is there a way to automatically collect the log files from a AirPort or TimeCapsule base station?

    Hi there, the headline says basically all: Is there a way to collect the log files from a Time Capsule 7 AirPort from time to time? They are overwritten quite soon but I want a complete log of all activities to my access point. The AirPort Utility sa

  • Photoshop CS4 Extended Crashes Since Updating Acrobat to 9.3

    I have CS4 Web Premium. When I save a document in pdf format from Photoshop(PS) CS4, it normally opens the saved document in Acrobat 9.x. Up until yesterday, when I installed the Acrobat 9.3 update, the results have always been to have then have the

  • Trouble with display

    my ipad mini has a problem with the display. whitelines are going horizontally and colored lines are going vertically. and if i have it on for a minute it starts to get black. can somebbody please tell me why is this happening.

  • All Qualifications date is Maintained as 01.01.1900

    Hi Friends, In Infotype 24 it is displaying as " Change profile period from 01.01.1800" and the qualifications are created from 01.01.1900. I could not understand how to change this. In the relationships there are different dates, qualifictions are a