Function "xmlnamespaces" gives PL/SQL: ORA-19102: XQuery string literal....

Below is my script that you can run successfully, and i have version Oracle 11g.
Script has Xml namespace as constant at the moment there:
   xmlnamespaces(default 'http://elion.ee/webservices/Sales/Dynamics')I want to have a variable there instead, like this:
   xmlnamespaces(default    l_sSOAP_Namespace )But if i add such variable there i get such error:
PL/SQL: ORA-19102: XQuery string literal expectedCan i avoid such error somehow and use still the namespace as variable somehow, not the constant?
My script:
declare
   l_resp varchar2(4000);
   l_sSOAP_Namespace varchar2(4000) := 'http://elion.ee/webservices/Sales/Dynamics';
begin
  l_resp :=
  '<ns0:FindItemMetaDataResponse xmlns:ns0="http://elion.ee/webservices/Sales/Dynamics">
        <ns0:ItemMetaData>
          <ns0:ItemMetaData>
            <ns0:ItemGroupId>IT.LS.VS.DSL</ns0:ItemGroupId>
            <ns0:ItemGroupName>IT lisad võrguseadmed DSL</ns0:ItemGroupName>
            <ns0:ItemId>DSLGP603</ns0:ItemId>
            <ns0:ItemName>ADSL SIP ST546</ns0:ItemName>
           <ns0:ItemType>Item</ns0:ItemType>
           <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
           <ns0:SalesUnit>tk</ns0:SalesUnit>
           <ns0:SerialNumMandatory>No</ns0:SerialNumMandatory>
           <ns0:TaxValue>20.00</ns0:TaxValue>
         </ns0:ItemMetaData>
         <ns0:ItemMetaData>
           <ns0:CurrencyCode>EUR</ns0:CurrencyCode>
           <ns0:ItemGroupId>KL.PS.HGW</ns0:ItemGroupId>
           <ns0:ItemGroupName>Ruuterid</ns0:ItemGroupName>
           <ns0:ItemId>DSLGP603NY</ns0:ItemId>
           <ns0:ItemName>ADSL stardikomplekt Thomson ST546 stardi</ns0:ItemName>
           <ns0:ItemType>Item</ns0:ItemType>
           <ns0:MacAddressMandatory>No</ns0:MacAddressMandatory>
           <ns0:PriceWithoutVAT>12.78</ns0:PriceWithoutVAT>
           <ns0:PriceWithVAT>15.34</ns0:PriceWithVAT>
           <ns0:SalesUnit>tk</ns0:SalesUnit>
           <ns0:SerialNumMandatory>Yes</ns0:SerialNumMandatory>
           <ns0:TaxValue>20.00</ns0:TaxValue>
         </ns0:ItemMetaData>
       </ns0:ItemMetaData>
     </ns0:FindItemMetaDataResponse>';
  for rec in
     with xml_doc (doc) as (
        select xmlparse(document
        l_resp)
       from dual
     select x.*
     from xml_doc t
        , xmltable (
            xmlnamespaces(default 'http://elion.ee/webservices/Sales/Dynamics')
          , '/FindItemMetaDataResponse/ItemMetaData/ItemMetaData'
            passing t.doc
            columns
            CurrencyCode varchar2(4000) path 'CurrencyCode',
            ItemGroupId varchar2(4000) path 'ItemGroupId',
            ItemGroupName varchar2(4000) path 'ItemGroupName',
            ItemId varchar2(4000) path 'ItemId',
            ItemName varchar2(4000) path 'ItemName',
            ItemType varchar2(4000) path 'ItemType',
            MacAddressMandatory varchar2(4000) path 'MacAddressMandatory',
            PriceWithoutVAT varchar2(4000) path 'PriceWithoutVAT',
            PriceWithVAT varchar2(4000) path 'PriceWithVAT',
            SalesUnit varchar2(4000) path 'SalesUnit',
            SerialNumMandatory varchar2(4000) path 'SerialNumMandatory',
            TaxValue varchar2(4000) path 'TaxValue'         
          ) x
  ) loop
    dbms_output.put_line('ItemId=' || rec.ItemId);
  end loop;
end;
/* Output:
ItemId=DSLGP603
ItemId=DSLGP603NY
*/Edited by: CharlesRoos on 11.04.2013 14:46

How badly do you need the namespace to be dynamic ?
Is it likely to change that frequently?
The reason for having to hardcode namespace declarations and XQuery string in general is optimization.
By doing so, the CBO is able to analyze the whole expression and apply optimization techniques such as XQuery rewrite.
As said, use dynamic SQL if you really have no way around this requirement.
The other solution I'm reluctent to expose here is to make the whole thing namespace-free by using construct such as "*:element-name" or "*[local-name()="element-name"]".
Both will use XQ functional evaluation and perform worse.

Similar Messages

  • Error ORA-06502 When using function REPLACE in PL/SQL

    Hi,
    I have a PL/SQL procedure which gives error 'Error ORA-06502 When using function REPLACE in PL/SQL' when the string value is quite long (I noticed this with a string 9K in length)
    variable var_a is of type CLOB
    and the assignment statement where it gives the error is
    var_a := REPLACE(var_a, '^', ''',''');
    Can anyone please help!
    Thanks

    Even then that shouldn't do so:
    SQL> select overload, position, argument_name, data_type, in_out
      2  from all_arguments
      3  where package_name = 'STANDARD'
      4  and object_name = 'LPAD'
      5  order by 1,2
      6  /
    OVERLOAD   POSITION ARGUMENT_NAME                  DATA_TYPE                      IN_OUT
    1                 0                                VARCHAR2                       OUT
    1                 1 STR1                           VARCHAR2                       IN
    1                 2 LEN                            BINARY_INTEGER                 IN
    1                 3 PAD                            VARCHAR2                       IN
    2                 0                                VARCHAR2                       OUT
    2                 1 STR1                           VARCHAR2                       IN
    2                 2 LEN                            BINARY_INTEGER                 IN
    3                 0                                CLOB                           OUT
    3                 1 STR1                           CLOB                           IN
    3                 2 LEN                            NUMBER                         IN
    3                 3 PAD                            CLOB                           IN
    4                 0                                CLOB                           OUT
    4                 1 STR1                           CLOB                           IN
    4                 2 LEN                            NUMBER                         INI wonder what happened?

  • PL/SQL: ORA-00934: group function is not allowed here

    Hi,
    I am writing a PL/SQL procedure. The structure is like :
    SET SERVEROUTPUT ON;
    CREATE OR REPLACE Procedure abc
    IS
    v_total_ip_rec number(14);
    v_total_op_rec number(14);
    v_total_rec number(14);
    BEGIN
    SELECT SUM (CASE
    WHEN <condition 1>
    THEN 1
    ELSE 0
    END
    ) into v_total_ip_rec,
    SUM (CASE
    WHEN <condition 2>
    THEN 1
    ELSE 0
    END
    ) into v_total_op_rec,
    SUM (1) into v_total_rec
    FROM A,B
    WHERE A.Col1=B.Col1;
    EXCEPTION
    WHEN OTHERS THEN
    raise_application_error(-20001,'An error was encountered - '||SQLCODE||' -ERROR- '||SQLERRM);
    END;
    When I run this procedure it gives me following error:
    "PL/SQL: ORA-00934: group function is not allowed here"
    Anybody have any idea?
    Any help would be appreciated.
    Thanks.

    Hi Arunkumar ,
    I think you don't need subquery.
    Regards Salim.
    Or.
    SELECT COUNT (CASE
                     WHEN <condition 1>
                        THEN 1
                  END) v_total_ip_rec,
           COUNT (CASE
                     WHEN <condition 2>
                        THEN 1
                  END) v_total_op_rec,
           COUNT (1) v_total_rec
      FROM a, b
    WHERE a.col1 = b.col1

  • PL/SQL: ORA-00942: table or view does not exist

    Hi
    i have logged into my schema and trying to access the database "DAD" which has the table name "SCHOOL"
    i wrote a function which should give me new_sno when i give it the old_sno
    and i have this errors , pls help
    CREATE OR REPLACE FUNCTION ORIG_SN(OSNO in Number,OTN in Number)
    RETURN Number IS
    NEW_SNO Number:=0;
    BEGIN
    SELECT new_sno AS NEW_SNO
    FROM DAD.SCHOOL
    WHERE ORIG_SNO = OSNO AND ORIG_TN = OTN;
    RETURN NEW_SNO;
    END ORIG_SN;
    Warning: Function created with compilation errors.
    Errors for FUNCTION ORIG_SN:
    LINE/COL ERROR
    5/1 PL/SQL: SQL Statement ignored
    6/15 PL/SQL: ORA-00942: table or view does not exist
    Thanks in advance ..

    Try this,
    CREATE VIEW SCHOOL_VIEW AS SELECT * FROM DAD.SCHOOL;and then change your function like
    CREATE OR REPLACE FUNCTION ORIG_SN(OSNO in Number,OTN in Number)
    RETURN Number IS
    my_new_sno Number:=0;
    BEGIN
    SELECT new_sno INTO my_new_sno FROM SCHOOL_VIEW WHERE ORIG_SNO = OSNO AND ORIG_TN = OTN;
    RETURN my_new_sno;
    END ORIG_SN;and see if it is getting created without any errors.
    -Arun
    Edited by: Arunkumar Ramamoorthy on Aug 15, 2009 1:56 AM

  • PL/SQL :ORA-04052 with Database link

    i have created a database link in my producation database as following
    CREATE PUBLIC DATABASE LINK <NAME>
    CONNECT TO <USER>
    IDENTIFIED BY <P/W>
    USING <CONNECT STRING OF TARGET DATABASE
    oracle version 9.0.2.8
    OS : Windows 2003 EE R2 SP2
    Using oracle failsafe 3.3.4 with windows cluster
    Problem Description :
    whenever i run my pl/sql procecdure to pull the data from the target database i get the following error
    ERROR at line 3
    ORA-06550:line 3 column 2
    PL/SQL : ORA-04052: error occured when looking up remote object _<SCHEMA>.<TABLE>@<DATABASE LINKE NAME>_
    ORA-00604 : ERROR occured at recursive SQL level 1
    ORA-03106 : fatal tow-task communication protocol error
    ORA-02063: preceding line from <DATABASE LINK NAME>
    I have tested the same way in the test environment the same oracle version as well the OS but without oracle failsafe and windows cluster
    the script goes smoothly with out any errors.
    i have google and checked the OTN for all available solutions but still nothing its not getting throw
    i will be very thankful for your replys and solutions
    any farther clarification i am ready
    thanks in advance

    Hi,
    This forum is for issues connecting to non-Oracle databases. As the problem is using PL/SQL to connect to another Oracle database then it would be better to post a thread in the PL/SQL forum -
    PL/SQL
    If you are trying to connect to a non-Oracle database then please give us the details of which non-Oracle database and the software you are trying to use to connect.
    Regards,
    Mike

  • PL/SQL: ORA-22806: not an object or REF  when Using Record in Package

    Oracle Database 11g Enterprise Edition Release 11.1.0.7.0
    I have declared a record type in my package
    create or replace
    PACKAGE MYPKG AS
      TYPE MYREC IS RECORD (VAL1 varchar2(20), val2 date);
      PROCEDURE display_error (pSQLERRM number);
      PROCEDURE P_LOAD_DATA (pStartDate Date, pEndDate Date);
      FUNCTION  F_EPI(refno1 in NUMBER,  refno2 in NUMBER) return MYREC;
    END MYPKG;
    --In My Package Body
    FUNCTION  F_EPI(refno1 in NUMBER,  refno2 in NUMBER) return MYREC is
            F_param MYREC;
            BEGIN
            select myvarchar2, mydate into MYREC from MYTable
              where myrefno1 = refno1
              and myrefno2 = refno2
            Exception
              when others then
              display_error(SQLERRM);
              RETURN F_param;
            END F_EPI ;
      PROCEDURE P_LOAD_DATA (pStartDate Date, pEndDate Date) IS
    insert into atable(myvarchar, mydate)
    select F_EPI(refno1,refno2).val1,F_EPI(refno1,refno2).val2 from tab2;
    END P_LOAD_DATA;
    I get errors
    Error(187,7): PL/SQL: SQL Statement ignored
    Error(225,7): PLS-00382: expression is of wrong type
    Error(225,7): PL/SQL: ORA-22806: not an object or REF
    When I compile the package.
    When I try to call the function from SQL I get an Invalid datatype error.

    Hi,
    Before posting any query/plsql blocks, please ensure that you have written it clean and complete with less syntax errors. ( at least general syntax errors, you can avoid). Then somebody can have an interest to check your logical error.
    About your posting, refer below solution step-by-step. It may help you, about what you are looking for? By the way, you must be knowing, what you are going to to do with. I haven't concentrated about your requirement; as it was not missing in your posting.
    drop table test;
    create table test(myvarchar varchar2(20), mydate date);
    create or replace
        package mypkg as
          type myrec is record (val1 varchar2(20), val2 date);
          --procedure display_error (psqlerrm in number); -- if you are passing sqlerrm, then parameter needs to be string type
       procedure display_error (psqlerrm in varchar2);
          procedure p_load_data (pstartdate in date, penddate in date);
          function  f_epi(refno1 in number,  refno2 in number) return myrec;
       end mypkg;
    Package created.
    --in my package body
    create or replace 
    package body mypkg as -- added
    procedure display_error (psqlerrm in varchar2) -- if you are declared a proc/func in spec, it needs to define in pkg body
    is
    begin
         null; -- you should know, what to do here
      dbms_output.put_line('Err -'||sqlerrm);
    end display_error;
    function  f_epi(refno1 in number,refno2 in number)
    return myrec
    is
    f_param myrec;
    begin
       -- select myvarchar2, mydate into MYREC from mytable
      --  where myrefno1 = refno1
      --  and myrefno2 = refno2;
        select ename, hiredate into f_param from emp -- added demo logic by using emp
        where empno = refno1
         and  mgr  = refno2;
        return f_param;  -- added
    exception
       when others then
         raise; -- if you are using OTHERS then, just raise it
       display_error(sqlerrm);  
       --return f_param; -- what is this?
    end f_epi;
    procedure p_load_data (pstartdate in date, penddate in date) -- you must be knowing the use of 2 params ???
    is
        v_rec myrec; -- added
    begin -- Added
       --insert into atable(myvarchar, mydate)
      -- select f_epi(refno1,refno2).val1,f_epi(refno1,refno2).val1 from tab2;
       -- demo logic added with static params to call f_epi
       v_rec:= f_epi(7499,7698);
       insert into test values v_rec;
        --null; 
    end p_load_data;
    end mypkg;
    Package body created.
    SQL> exec mypkg.p_load_data(null,null);
    PL/SQL procedure successfully completed.
    SQL> select * from test;
    MYVARCHAR            MYDATE
    ALLEN                20-FEB-81
    Thanks!

  • PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got NUMBER

    Hi all,
    Wondering if you could assist? I'm exploring User Types and having a small problem. I'm getting the above error for a user type I have created which I'm calling in a function. Here's what my code looks like which I'm running the 'scott' schema for testing purposes
    SQL> CREATE OR REPLACE TYPE NBR_COLL AS TABLE OF NUMBER;
    2 /
    Type created.
    SQL> create or replace FUNCTION first_rec_only
    2 (
    3 NUM_ID IN NUMBER
    4 ) RETURN NUMBER IS
    5 v_num NBR_COLL;
    6 BEGIN
    7 select deptno into v_num from dept;
    8 RETURN v_num(v_num.FIRST);
    9 END first_rec_only;
    10 /
    Warning: Function created with compilation errors.
    SQL> show errors
    Errors for FUNCTION FIRST_REC_ONLY:
    LINE/COL ERROR
    7/4 PL/SQL: SQL Statement ignored
    7/11 PL/SQL: ORA-00932: inconsistent datatypes: expected UDT got
    NUMBER
    SQL>
    Any clues to what I'm doing wrong? Cheers.

    The deptno column is a number, you cannot directly select a number into your type, you need to use your type's constructor.
    Something like:
    CREATE OR REPLACE FUNCTION first_rec_only (NUM_ID IN NUMBER) RETURN NUMBER IS
       v_num NBR_COLL;
    BEGIN
       SELECT nbr_coll(deptno) INTO v_num from dept;
       RETURN v_num(v_num.FIRST);
    END first_rec_only;Note that although this will compile, it will throw ORA-01422: exact fetch returns more than requested number of rows when you run it. you need to either use the input parameter as a predicate on your query against dept, use rownum = 1 in the query or use bulk BULK COLLECT INTO, depending on what exactly you want to accomplish.
    John

  • PL/SQL: ORA-00947

    Hi,
    I have a package body as given below
    CREATE OR REPLACE PACKAGE BODY DF AS
        FUNCTION T24_GetCOPYBatchKeyAndDate(RECKEY VARCHAR2)
            RETURN RTNVAL
            IS
            RTNVAL1 RTNVAL; 
            DELPOS    INTEGER;
            LISTSTRING VARCHAR2(4000);
        BEGIN
            SELECT XMLRECORD INTO LISTSTRING FROM V_F_RO_COPY_KEYLIST WHERE RECID = RECKEY;
            LISTSTRING := TRIM(LISTSTRING);
            WHILE LENGTH(LISTSTRING) <> 0
            LOOP
              DELPOS := INSTR(LISTSTRING, ' ');
              IF DELPOS = 0 THEN
                 DELPOS := LENGTH(LISTSTRING) + 1;
              END IF;
        --SELECT SUBSTR(LISTSTRING, 9, DELPOS - 9) INTO RTNVAL FROM DUAL;
        SELECT TO_DATE(SUBSTR(LISTSTRING, 1, 8),'YYYYMMDD'), SUBSTR(LISTSTRING, 9, DELPOS - 9) INTO RTNVAL1 FROM DUAL;
              LISTSTRING := SUBSTR(LISTSTRING, DELPOS+1, LENGTH(LISTSTRING)-DELPOS);
            END LOOP;
            RETURN(RTNVAL1);
        END T24_GetCOPYBatchKeyAndDate;
    END DF;
    but i get compilation errors below is the error can anyone let me know whats the exact problem here and earlier i used this fucntion as PIPILINED and PIPE_ROW(RTNVAL).
    It was working fine now i wanted to test this without pipeline fucntion.
    SQL> SHOW ERRORS;
    LINE/COL ERROR
    19/5     PL/SQL: SQL Statement ignored
    19/105   PL/SQL: ORA-00947: not enough values
    SQL>

    Now...if you do a BULK inside the loop, then the collection get's overwritten every loop iteration.
    So going back to the original post
    replacing
    WHILE LENGTH(LISTSTRING) <> 0
    LOOP
    DELPOS := INSTR(LISTSTRING, ' ');
       IF DELPOS = 0 THEN
          DELPOS := LENGTH(LISTSTRING) + 1;
       END IF;
       SELECT TO_DATE(SUBSTR(LISTSTRING, 1, 8),'YYYYMMDD'), SUBSTR(LISTSTRING, 9, DELPOS - 9)) INTO RTNVAL1 FROM DUAL;
       LISTSTRING := SUBSTR(LISTSTRING, DELPOS+1, LENGTH(LISTSTRING)-DELPOS);
    END LOOP;
    with
    WHILE LENGTH(LISTSTRING) <> 0
    LOOP
    DELPOS := INSTR(LISTSTRING, ' ');
       IF DELPOS = 0 THEN
          DELPOS := LENGTH(LISTSTRING) + 1;
       END IF;
       RTNVAL1.EXTEND();
        RTNVAL1(RTNVAL1.COUNT()) := DATEKEYPAIR(TO_DATE(SUBSTR(LISTSTRING, 1, 8),'YYYYMMDD')
                                                                             , SUBSTR(LISTSTRING, 9, DELPOS - 9));
       LISTSTRING := SUBSTR(LISTSTRING, DELPOS+1, LENGTH(LISTSTRING)-DELPOS);
    END LOOP;
    should help
    hth

  • SQL Error: ORA-01704: string literal too long

    select * from table(fn_split('some 10000 characters with comma separation .........................'))
    Error report:
    SQL Error: ORA-01704: string literal too long
    01704. 00000 - "string literal too long"
    *Cause:    The string literal is longer than 4000 characters.
    *Action:   Use a string literal of at most 4000 characters.
    how to pass my 10k record string

    933663 wrote:
    The string is through a user interface.So, that interface is using what datatype for the string? What language is the interface written in?
    insert into table
    select * from table(fn_split('2,4,2,5,7'));Do you understand what a string literal is? You cannot provide a varchar2 string that exceeds 4000 bytes from within SQL. Fact. It just cannot be done.
    If you are passing the string from a user interface using a datatype that supports more than 4000 bytes, and you pass it directly to PL/SQL code by calling the function or procedure directly (not using SQL) then you can use up to 32767 bytes for your VARCHAR2.
    The code you've posted (which happens to be some of my own code posted years ago on these forums) takes a VARCHAR2 as an input. You would have to change that to accept a CLOB datatype and work on the CLOB instead. However, you still wouldn't be able to pass in a string literal of more than 4000 bytes from SQL for it.
    Looking at your other thread: Seperate the string value
    ... it looks like the 'user' is trying to pass in a table definition. What is it your application is trying to do? Surely you are not trying to create a table at run time?
    So explain, what is the business issue you are trying to solve? We may be able to provide a better way of doing it.

  • ORA-04091 (table string.string is mutating) and Function-Based Index

    I've encountered a problem with DELETEing from a table when that table has a function-based index on it. The following demonstrates this:
    SQL> CREATE OR REPLACE FUNCTION get_employee_location(p_empno IN number)
      2  RETURN varchar2
      3  DETERMINISTIC
      4  IS
      5  l_return_value   varchar2(20);
      6  BEGIN
      7  SELECT loc
      8  INTO   l_return_value
      9  FROM   dept
    10  WHERE  deptno = (SELECT
    11                   e.deptno
    12                   FROM emp e
    13                   WHERE empno = p_empno);
    14  return l_return_value;
    15  end;
    16  /
    Function created.
    SQL> create index location_idx on emp (get_employee_location(empno));
    Index created.
    SQL> delete from emp;
    delete from emp
    ERROR at line 1:
    ORA-04091: table SCOTT.EMP is mutating, trigger/function may not see it
    ORA-06512: at "SCOTT.GET_EMPLOYEE_LOCATION", line 7------------------------------------------------
    The question is: How can I successfully DELETE FROM emp but keep my function-based index in place?
    Thanks
    Andy

    'Being able to' is 'being able to', but
    it is dangerous to declare "DETERMINISTIC" for non-deterministic function.
    The following problem happens on non-deterministic function index.
    SQL> update dept set loc = 'NEWYORK' where deptno=10;
    1 row updated.
    SQL> commit;
    Commit complete.
    SQL> select * from emp where get_employee_location(deptno)='NEWYORK';
    no rows selected
    SQL> select * from dept;
        DEPTNO DNAME          LOC
            10 ACCOUNTING     NEWYORK
            20 RESEARCH       DALLAS
            30 SALES          CHICAGO
            40 OPERATIONS     BOSTON
    SQL> select empno,ename from emp where get_employee_location(deptno)='NEW YORK';
         EMPNO ENAME
          7782 CLARK
          7839 KING
          7934 MILLER
    SQL> select empno,ename,get_employee_location(deptno) from emp where deptno=10;
         EMPNO ENAME      GET_EMPLOYEE_LOCATION(DEPTNO)
          7782 CLARK
          7839 KING
          7934 MILLER
    SQL> select empno,ename,get_employee_location(deptno) from emp where get_employee_location(deptno)='NEW YORK';
         EMPNO ENAME      GET_EMPLOYEE_LOCATION(DEPTNO)
          7782 CLARK      NEW YORK
          7839 KING       NEW YORK
          7934 MILLER     NEW YORK
    SQL> drop index location_idx ;
    Index dropped.
    SQL> select empno,ename from emp where get_employee_location(deptno)='NEW YORK';
    no rows selected

  • Log Function behaving diffently in SQL vs Pl/SQL

    Hello
    This equation works OK in SQL but its implementation in PL/SQL throws an error:
    SELECT CAST(LOG(2,32) as FLOAT) FROM DUAL;
    Returns: 5
    vs
    x FLOAT := 0;
    x := CAST(LOG(2,32) as FLOAT) ;
    PLS-00382: expression is of wrong type
    Incidentally I ran into a situation where LOG(2,32) return 5 in SQL but returns 4 where formatted TRUNC(LOG(2,32),0)
    Any assistance would be appreciated

    [email protected] wrote:
    This is not so much specific to LOG function. More a so "rounding behavior" of SQLPLUS due to environment default settings.??? It has nothing to do with rounding. You'll get same PLS-00382 for pretty much any built-in function:
    SQL> declare
      2  x FLOAT := 0;
      3  begin
      4  x := CAST(LOG(2,32) as FLOAT) ;
      5  end;
      6  /
    x := CAST(LOG(2,32) as FLOAT) ;
    ERROR at line 4:
    ORA-06550: line 4, column 11:
    PLS-00382: expression is of wrong type
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    SQL> declare
      2  x FLOAT := 0;
      3  begin
      4  x := CAST(POWER(2,32) as FLOAT) ;
      5  end;
      6  /
    x := CAST(POWER(2,32) as FLOAT) ;
    ERROR at line 4:
    ORA-06550: line 4, column 11:
    PLS-00382: expression is of wrong type
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    SQL> declare
      2  x FLOAT := 0;
      3  begin
      4  x := CAST(mod(3,2) as FLOAT) ;
      5  end;
      6  /
    x := CAST(mod(3,2) as FLOAT) ;
    ERROR at line 4:
    ORA-06550: line 4, column 11:
    PLS-00382: expression is of wrong type
    ORA-06550: line 4, column 1:
    PL/SQL: Statement ignored
    SQL> Oracle still maintains two separate engines for SQL and PL/SQL. And the above bug is obviously related to that. Now same built-in function has separate implementation SQL and PL/SQL. In PL/SQL it is package STANDARD. At first I thought it is where bug manifests itself. However:
    SQL> SELECT CAST(sys.standard.LOG(2,32) as FLOAT) FROM DUAL;
    CAST(SYS.STANDARD.LOG(2,32)ASFLOAT)
                                      5
    SQL> So most likely bug is caused by FLOAT implementation in PL/SQL.
    SY.

  • Function Call returning old SQL Query

    Hello All,
    I have a Pipeline Function which creates a SQL within (Dynamic SQL that gets stored in a LONG variable) based on the parameter STRING passed to the function. Inside this function, once the SQL is built, I am inserting this SQL into a log table, for logging purpose.
    Note: my function has only one parameter which is a string. This string accepts a name:value pairs with a delimiter which I breakdown inside the function. But this functionality is working fine.
    Issue:
    When I run the function with parameter with a STRING say (Age = 20, Gender = M) for the first time, it works.
    <code>SELECT * FROM TABLE (
    PIPE_FUN_SEARCH_PKG.get_search_records ('EMP_AGE:20|EMP_GENDER:M'));
    </code>
    When I change the parameters to (Age = 20, Gender = F), it gives me the results of the earlier function call.
    <code>SELECT * FROM TABLE (
    PIPE_FUN_SEARCH_PKG.get_search_records ('EMP_AGE:20|EMP_GENDER:F'));
    </code>
    When I open the logs, I see the SQL being built is the earlier one.
    As a test I closed the session and ran (Age = 20, Gender = F) first. It works fine. When I run a different parameter string, it always mimics the earlier function call.
    Is CACHING in play here. I tried both the following:
    <code> dbms_result_cache.bypass(FALSE);
    dbms_result_cache.flush;
    </code>
    I tried multiple tests, with different parameters and only the first one runs fine and second one copied the earlier. However, when I open two sessions on two different windows it doesn't happen.
    Also, in the Logging table I am capturing the input string as a confirmation, which is coming correctly. But the SQL being build mimics the earlier call.
    I tried to set the variable which hold the SQL Statement to empty (v_sql := '';) at the beginning and also at the end. Still no use.
    Kindly help if I am over looking anything.
    Regards,
    Aj

    Aj09 wrote:
    I have a Pipeline Function which creates a SQL within (Dynamic SQL that gets stored in a LONG variable) based on the parameter STRING passed to the function. The LONG data type has been replaced by the LOB data type. Oracle specifically recommends not using the old LONG data type.
    Issue:
    When I run the function with parameter with a STRING say (Age = 20, Gender = M) for the first time, it works.
    <code>SELECT * FROM TABLE (
    PIPE_FUN_SEARCH_PKG.get_search_records ('EMP_AGE:20|EMP_GENDER:M'));
    </code>
    When I change the parameters to (Age = 20, Gender = F), it gives me the results of the earlier function call.
    <code>SELECT * FROM TABLE (
    PIPE_FUN_SEARCH_PKG.get_search_records ('EMP_AGE:20|EMP_GENDER:F'));
    </code>The tag is ** - not *<code>*.
    Why a pipeline function? Why dynamic SQL? Are you using +DBMS_SQL+ to create the dynamic cursor? If not, why not? Only +DBMS_SQL+ allows dynamic binding in PL/SQL. Without that, your code will burn a lot of additional CPU on hard parsing and trash and fragment Shared Pool memory.
    When I open the logs, I see the SQL being built is the earlier one.
    How do you record the current SQL? Are you using a static variable to capture the SQL statement generated?
    From what you have described - this is yet another horribly flawed approach in all respects. To data modelling. To relational databases. To Oracle. To SQL.
    Reinventing the SQL language for data retrieval as a pipeline function using a funky parameter interface - sorry, I just don't get that. It is an insane approach.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • Database trigger - PL/SQL: ORA-00984: column not allowed here

    I am trying to create a trigger that will update an employee audit table when a row is changed. Using a sequence number to assign a unique identifier to each row as it is created. Need to capture the user ID, date of the change, and the action (update), plus the before image of the row.
    CREATE SEQUENCE emp_audit_seq START WITH 10;               
    Create table emp (
       empno       NUMBER(4)      Primary Key,
       ename       VARCHAR2(10),
       job            VARCHAR2(9),
       mgr           NUMBER(4),
       hiredate     DATE,
       sal             NUMBER(7,2),
       comm        NUMBER(7,2),
       deptno       NUMBER(2));
    CREATE TABLE emp_audit   (
         audit_uid          NUMBER(15)      Primary Key,
         change_date          DATE,
         change_user          VARCHAR2(30),
         action                  CHAR(1),
         empno                  NUMBER(4),
         ename                  VARCHAR2(10),          
         job               VARCHAR2(9),
         mgr               NUMBER(4),
         hiredate          DATE,
         sal               NUMBER(7,2),
         comm                  NUMBER(7,2),
         deptno                  NUMBER(2));
    CREATE OR REPLACE TRIGGER trig_emp_audit
      BEFORE UPDATE ON emp
      FOR EACH ROW
    BEGIN
      INSERT INTO emp_audit
        VALUES(emp_audit_seq.nextval, change_date, change_user, action, :old.empno, :old.ename, :old.job, :old.mgr, :old.hiredate, :old.sal, :old.comm, deptno);
    END;
    Warning: Trigger created with compilation errors.
    SQL> show errors
    Errors for TRIGGER TRIG_EMP_AUDIT:
    LINE/COL ERROR
    2/3      PL/SQL: SQL Statement ignored
    3/149    PL/SQL: ORA-00984: column not allowed hereCan anyone assist in helping me find what I am doing wrong with the trigger?
    Edited by: LostNoob on Aug 25, 2012 2:24 PM

    First, when you write an INSERT statement, it's always good to list the columns that you're inserting into. That makes the code easier to follow-- you don't have to separately pull up the table definition to know what order columns are inserted. And it makes the code more maintainable since the statement won't become invalid if you add a new column to the table in the future.
    Second, CHANGE_DATE, CHANGE_USER, and ACTION are not (presumably) functions and they are not local variables so it doesn't make sense to use them in an INSERT statement. You would need to write code or leverage existing functions to populate those columns. I'm guessing, for example, that you want to use SYSDATE to populate the CHANGE_DATE and USER to populate the CHANGE_USER column. My guess is that ACTION should always be a 'U' for UPDATE.
    Third, it appears that you left off the :old on the DEPTNO column.
    Putting it all together, you'd have something like
    CREATE OR REPLACE TRIGGER trig_emp_audit
      BEFORE UPDATE ON emp
      FOR EACH ROW
    BEGIN
      INSERT INTO emp_audit(
          audit_uid,
          change_date,
          change_user,
          action,
          enpno,
          ename,
          job,
          mgr,
          hiredate,
          sal,
          comm,
          deptno )
        VALUES(
          emp_audit_seq.nextval,
          sysdate,
          user,
          'U',
         :old.empno,
         :old.ename,
         :old.job,
         :old.mgr,
         :old.hiredate,
         :old.sal,
         :old.comm,
         :old.deptno);
    END;
    / Justin

  • How to catch PL/SQL: ORA-04052 error?

    I need to execute a procedure that select remote objects but the remote db is a RAC DB and I only have access to one of the nodes, the remote RAC have load balancing enabled and the remote DBA can’t create a DB Service for my connection, so, I have to re-run the execution of my procedure until it connects successful to the remote DB through a db link, but I can’t catch the error ORA-12541: TNS:no listener.
    Someone knows how to catch the error??
    set serveroutput on
    declare
    function F_DATE return sysdate
    is
    ld_return date;
    begin
    begin
    select sysdate into ld_return from dual@dbl_bnvalores;
    exception
    when others then
    ld_return := f_date;
    end;
    return ld_return;
    end F_DATE;
    begin
    dbms_output.put_line('Remote sysdate: '||f_date);
    end;
    Error at line 2
    ORA-06550: line 2, column 26:
    PLS-00562: a function must return a type.
    ORA-06550: line 7, column 42:
    PL/SQL: ORA-04052: error occurred when looking up remote object BNSAFI.DUAL@DBL_BNVALORES
    ORA-00604: error occurred at recursive SQL level 1
    ORA-12541: TNS:no listener
    ORA-06550: line 7, column 7:
    PL/SQL: SQL Statement ignored

    I could confirm that you would never branch to the exception in case of no listener!
    So another possibility that comes to mind is to enclose the remote select in an execute immediate and only execute it if you could establish a connection via UTL_TCP:
    Something along those lines:
    michaels>  DECLARE
       conn               UTL_TCP.connection;
       l_date             DATE;
       no_listner_excep   EXCEPTION;
       PRAGMA EXCEPTION_INIT (no_listner_excep, -29260);
    BEGIN
       conn := UTL_TCP.open_connection ('fleet', 1569);
       EXECUTE IMMEDIATE 'select sysdate from dual@fleet_new'
                    INTO l_date;
       UTL_TCP.close_connection (conn);
       DBMS_OUTPUT.put_line (l_date);
    EXCEPTION
       WHEN no_listner_excep
       THEN
          DBMS_OUTPUT.put_line (SQLERRM (SQLCODE));
    END;
    ORA-29260: network error: TNS:no listener
    PL/SQL procedure successfully completed.

  • Error Text = PL/SQL: ORA-00926

    Can some one tell me what the problem is with this, fairly urgent
    ERROR:Line # = 120 Column # = 28 Error Text = PL/SQL: ORA-00926: missing VALUES keyword
    Line # = 120 Column # = 2 Error Text = PL/SQL: SQL [b]Statement ignored
    Oracle Migration Workbench
    CREATE OR REPLACE FUNCTION "SA"."SPCXDB_DELIVERPRJ" (
    CurrUser_ID IN NUMBER DEFAULT NULL,
    Object_ID IN NUMBER DEFAULT NULL,
    Path_ID IN NUMBER DEFAULT NULL,
    IsLastPhase IN NUMBER DEFAULT NULL,
    NewPhase_ID IN NUMBER DEFAULT NULL,
    User_ID IN NUMBER DEFAULT NULL,
    Comment_ IN VARCHAR2 DEFAULT NULL,RC1_CALL IN OUT Omwb_emulation.globalPkg.RCT1 )
    RETURN INTEGER
    AS
    CurrUser_ID_ NUMBER(10,0) := CurrUser_ID;
    Object_ID_ NUMBER(10,0) := Object_ID;
    Path_ID_ NUMBER(10,0) := Path_ID;
    IsLastPhase_ NUMBER(3,0) := IsLastPhase;
    NewPhase_ID_ NUMBER(10,0) := NewPhase_ID;
    User_ID_ NUMBER(10,0) := User_ID;
    Comment__ VARCHAR2(255) := Comment_;
    StoO_selcnt INTEGER;
    StoO_error INTEGER;
    StoO_rowcnt INTEGER;
    StoO_crowcnt INTEGER := 0;
    StoO_fetchstatus INTEGER := 0;
    StoO_errmsg VARCHAR2(255);
    StoO_sqlstatus INTEGER;
    tempVar1 NUMBER :=3;
    tempVar2 NUMBER :=1;
    id NUMBER(10,0);
    CURSOR ptr IS
    SELECT Object_ID
    FROM TT_DVROBJECTS;
    dummy_var1 INTEGER;
    /****** Object: Stored Procedure dbo.spCXDB_deliverprj Script Date: 2003-11-12 14:21:41 ******/
    -- currently logged user id
    BEGIN
    NULL;
    /*[SPCONV-ERR(12)]:(set XACT_ABORT) Manual conversion required*/
    1) update project
    IF SPCXDB_DELIVERPRJ.IsLastPhase_ = 0 THEN
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = SPCXDB_DELIVERPRJ.Path_ID_,
    DvrPhase_ID = SPCXDB_DELIVERPRJ.NewPhase_ID_,
    DvrUser_ID = SPCXDB_DELIVERPRJ.User_ID_
    WHERE Object_ID = SPCXDB_DELIVERPRJ.Object_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 4
    END;
    ELSE
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = 0,
    DvrPhase_ID = 0,
    DvrUser_ID = 0
    WHERE Object_ID = SPCXDB_DELIVERPRJ.Object_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 0
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBDeliverPaths
    SET RefCount = RefCount - 1
    WHERE Path_ID = SPCXDB_DELIVERPRJ.Path_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    2) get all subobjects , subprojects and documents
    END;
    END IF;
    /* Emulating @@TRANCOUNT functionality in Oracle model */
    omwb_emulation.globalPkg.trancount:=omwb_emulation.globalPkg.trancount+1;
    /*[SPCONV-ERR(55)]:CREATE TABLE TT_DVROBJECTS_2-- TT_DVROBJECTS Will be used -- statement passed to ddl file*/
    DELETE FROM TT_DVROBJECTS;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    INSERT INTO TT_DVROBJECTS ; /*ERROR:Line # = 120 Column # = 28 Error Text = PL/SQL: ORA-00926: missing VALUES keyword
    Line # = 120 Column # = 2 Error Text = PL/SQL: SQL Statement ignored
    SQL SERVER 2000
    BEGIN TRAN
    CREATE TABLE #DvrObjects ( Object_ID int NOT NULL )
    NSERT
    #DvrObjects
    EXEC
    spCXDB_expandtree @Object_ID,3,1 */
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    BEGIN
    /* demoDMS*/sa.spCXDB_expandtree(SPCXDB_DELIVERPRJ.Object_ID_,
    tempVar1,
    tempVar2,
    RC1 => RC1_CALL);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    3) put documents and projects onto deliver path
    NULL;/*DECLARE CURSOR ptr */
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    OPEN ptr;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    FETCH ptr INTO
    SPCXDB_DELIVERPRJ.id;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF ptr%NOTFOUND THEN
    StoO_sqlstatus := 2;
    StoO_fetchstatus := -1;
    ELSE
    StoO_sqlstatus := 0;
    StoO_fetchstatus := 0;
    END IF;
    <<i_loop1>>
    WHILE ( StoO_fetchstatus = 0) LOOP
    BEGIN
    -- IF (SELECT Status FROM CXDBObjects WHERE Object_ID = @id) = 4 AND
    BEGIN
    StoO_selcnt := 0;
    StoO_error := 0;
    StoO_rowcnt := 0;
    SELECT 1 INTO StoO_selcnt
    FROM DUAL
    WHERE 0 <> (
    SELECT DvrPhase_ID
    FROM CXDBObjects
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id ) AND SPCXDB_DELIVERPRJ.Path_ID_
    = (
    SELECT DvrPath_ID
    FROM CXDBObjects
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id );
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF StoO_selcnt != 0 THEN
    BEGIN
    BEGIN
    BEGIN
    StoO_selcnt := 0;
    StoO_error := 0;
    StoO_rowcnt := 0;
    SELECT 1 INTO StoO_selcnt
    FROM DUAL
    WHERE 0 = (
    SELECT type_
    FROM CXDBObjects
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id );
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF StoO_selcnt != 0 THEN
    BEGIN
    -- update project data
    IF SPCXDB_DELIVERPRJ.IsLastPhase_ = 0 THEN
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = SPCXDB_DELIVERPRJ.Path_ID_,
    DvrPhase_ID = SPCXDB_DELIVERPRJ.NewPhase_ID_,
    DvrUser_ID = SPCXDB_DELIVERPRJ.User_ID_
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 4
    END;
    ELSE
    BEGIN
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBObjects
    SET DvrPath_ID = 0,
    DvrPhase_ID = 0,
    DvrUser_ID = 0
    WHERE Object_ID = SPCXDB_DELIVERPRJ.id;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    -- Status = 0
    --decrease path reference counter
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    UPDATE sa.CXDBDeliverPaths
    SET RefCount = RefCount - 1
    WHERE Path_ID = SPCXDB_DELIVERPRJ.Path_ID_;
    StoO_rowcnt := SQL%ROWCOUNT;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    END;
    END IF;
    END;
    ELSE
    BEGIN
    BEGIN
    dummy_var1 := /* demoDMS*/sa.spCXDB_deliverdocument(SPCXDB_DELIVERPRJ.CurrUser_ID_,
    SPCXDB_DELIVERPRJ.id,
    SPCXDB_DELIVERPRJ.Path_ID_,
    SPCXDB_DELIVERPRJ.IsLastPhase_,
    SPCXDB_DELIVERPRJ.NewPhase_ID_,
    SPCXDB_DELIVERPRJ.User_ID_,
    SPCXDB_DELIVERPRJ.Comment__);
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    END;
    END IF;
    END;
    END;
    END IF;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    StoO_crowcnt := 0;
    FETCH ptr INTO
    SPCXDB_DELIVERPRJ.id;
    EXCEPTION
    WHEN OTHERS THEN
    StoO_rowcnt := 0;
    StoO_selcnt := 0;
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    IF ptr%NOTFOUND THEN
    StoO_sqlstatus := 2;
    StoO_fetchstatus := -1;
    ELSE
    StoO_sqlstatus := 0;
    StoO_fetchstatus := 0;
    END IF;
    END;
    END LOOP;
    BEGIN
    StoO_error := 0;
    StoO_rowcnt := 0;
    CLOSE ptr;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    StoO_error := SQLCODE;
    StoO_errmsg := SQLERRM;
    raise_application_error(SQLCODE, SQLERRM,true);
    END;
    NULL;
    /* Emulating @@TRANCOUNT functionality in Oracle model */
    IF omwb_emulation.globalPkg.trancount = 1 THEN
    COMMIT WORK;
    END IF;
    IF omwb_emulation.globalPkg.trancount > 0 THEN
    omwb_emulation.globalPkg.trancount:=omwb_emulation.globalPkg.trancount-1;
    END IF;
    RETURN (0);
    END SPCXDB_DELIVERPRJ;
    Thank's

    Hi Hilary,
    This is the original T-SQL code. Please, help me.
    CREATE PROCEDURE spCXDB_deliverPrj
    @CurrUser_ID     int,          -- currently logged user id
    @Object_ID     int,
    @Path_ID     int,
    @IsLastPhase     tinyint,
    @NewPhase_ID int,
    @User_ID     int,
    @Comment     varchar(255) = NULL
    AS
    SET XACT_ABORT ON
         1) update project
    IF @IsLastPhase = 0
    BEGIN
         UPDATE
              CXDBObjects
         SET
              DvrPath_ID = @Path_ID,
              DvrPhase_ID = @NewPhase_ID,
              DvrUser_ID = @User_ID
    --          Status = 4
         WHERE
              Object_ID = @Object_ID
    END
    ELSE
    BEGIN
         UPDATE
              CXDBObjects
         SET
              DvrPath_ID = 0,
              DvrPhase_ID = 0,
              DvrUser_ID = 0
    --          Status = 0
         WHERE
              Object_ID = @Object_ID
         UPDATE
              CXDBDeliverPaths
         SET
              RefCount = RefCount - 1
         WHERE
              Path_ID = @Path_ID
    END
         2) get all subobjects , subprojects and documents
    BEGIN TRAN
    CREATE TABLE #DvrObjects ( Object_ID int NOT NULL )
    INSERT
         #DvrObjects
    EXEC
         spCXDB_expandtree @Object_ID,3,1
         3) put documents and projects onto deliver path
    DECLARE @id int
    DECLARE ptr CURSOR FOR SELECT Object_ID FROM #dvrobjects
    OPEN ptr
    FETCH NEXT FROM ptr INTO @id
    WHILE(@@FETCH_STATUS = 0)
    BEGIN
    --     IF     (SELECT Status FROM CXDBObjects WHERE Object_ID = @id) = 4 AND
         IF     (SELECT DvrPhase_ID FROM CXDBObjects WHERE Object_ID = @id) <> 0 AND
              (SELECT DvrPath_ID FROM CXDBObjects WHERE Object_ID = @id) = @Path_ID
         BEGIN
              IF (SELECT type FROM CXDBObjects WHERE Object_ID = @id) = 0
              BEGIN
                   -- update project data
                   IF @IsLastPhase = 0
                   BEGIN
                        UPDATE
                             CXDBObjects
                        SET
                             DvrPath_ID = @Path_ID,
                             DvrPhase_ID = @NewPhase_ID,
                             DvrUser_ID = @User_ID
    --                         Status = 4
                        WHERE
                             Object_ID = @id
                   END
                   ELSE
                   BEGIN
                        UPDATE
                             CXDBObjects
                        SET
                             DvrPath_ID = 0,
                             DvrPhase_ID = 0,
                             DvrUser_ID = 0
    --                         Status = 0
                        WHERE
                             Object_ID = @id
                        --decrease path reference counter
                        UPDATE
                             CXDBDeliverPaths
                        SET
                             RefCount = RefCount - 1
                        WHERE
                             Path_ID = @Path_ID
                        END
              END
              ELSE
              BEGIN
                   EXEC spCXDB_deliverdocument @CurrUser_ID, @id,@Path_ID,@IsLastPhase,@NewPhase_ID,@User_ID, @Comment
              END
         END
         FETCH NEXT FROM ptr INTO @id
    END
    CLOSE ptr
    DEALLOCATE ptr
    COMMIT TRAN
    RETURN(0)
    Regards,
    Emilia.

Maybe you are looking for

  • Photo quality in Imovie

    I have Imovie HD 6 and Final Cut Express. I am creating the typical slideshow with photos from a digital camera and adding transitions and music, blah, blah. When I export in each application I get the same quicktime export screen. No matter what I d

  • IPod very low on battery and now won't turn on when plugged into PC

    I haven't used my iPod for a few weeks, so now the battery is obviously completely empty. The problem is that it won't turn on when I plug it into my PC to charge, even after half an hour or longer. Is there something I can do, or do I need to get a

  • Photos Display Incorrectly after iPhoto 9.1.2 Update

    Since the latest iPhoto Update (9.1.2) Photos have been displaying incorrectly on AppleTV in Events View. Instead of being organized in events like in iPhoto, the events are displayed with 2 photos in each, creating multiple events for each actual ev

  • How to use oracle rank key word

    I am trying to rank my record using oracle key work row_number() but it just gives me an error message. SELECT  g.csecnum "Section Number", e.iplineno "Line Number",ItemRank,         e.eiitem  "Item Number", (i.idescrl ||'  '|| e.isupdes) "Item Descr

  • Internal and external facing applicaitons on same infrastructure

    I'm looking for suggestions on the best way to architect an apex production environment where you may have two or three apps open to the public and 10 or more for internal access only. All of the apps (regardless of public or private) are running on