Procedure Function to dequeue a message and return cursor

Hi Guys,
We are looking for ways to dequeue a message from an oracle queue and pass it to the java code.
Namely we would like to create a procedure/function to dequeue a message which can be called by the java code for further processing.
So far we have the following working example, but it uses DBMS_OUTPUT.PUT_LINE to display values. But the target is to pass it to java...
Our DB - 11gR2
CODE:
create or replace
PROCEDURE PRC_DEQUEUE_EVENT_1
AS
dequeue_options DBMS_AQ.dequeue_options_t;
message_properties DBMS_AQ.message_properties_t;
message_handle RAW(16);
message our_message_type;
BEGIN
dequeue_options.navigation := DBMS_AQ.FIRST_MESSAGE;
DBMS_AQ.DEQUEUE(
queue_name => 'ORDERS_Q',
dequeue_options => dequeue_options,
message_properties => message_properties,
payload => message,
msgid => message_handle);
DBMS_OUTPUT.PUT_LINE('STATUS: '|| MESSAGE.CORDYS_STATUS);
DBMS_OUTPUT.PUT_LINE('CUSTOMERNUMBER: '|| MESSAGE.CUSTOMERNUMBER);
DBMS_OUTPUT.PUT_LINE('EINDDATUM: '|| MESSAGE.EINDDATUM);
DBMS_OUTPUT.PUT_LINE('ERRORCODE: '|| MESSAGE.ERRORCODE);
DBMS_OUTPUT.PUT_LINE('EXTRA1: '|| MESSAGE.EXTRA1);
DBMS_OUTPUT.PUT_LINE('EXTRA2: '|| MESSAGE.EXTRA2);
DBMS_OUTPUT.PUT_LINE('EXTRA3: '|| MESSAGE.EXTRA3);
DBMS_OUTPUT.PUT_LINE('EXTRA4: '|| MESSAGE.EXTRA4);
DBMS_OUTPUT.PUT_LINE('EXTRA5: '|| MESSAGE.EXTRA5);
END;
In a result we get the following on the screen:
STATUS: ORDER_COMPLETE
CUSTOMERNUMBER:
EINDDATUM: 20-DEC-11 12:00:00
ERRORCODE:
EXTRA1:
EXTRA2:
EXTRA3:
EXTRA4:
EXTRA5:
Question is how to sent result into a variable/cursor... whatever which might be read by the java code.
Any help would be much appreciated.
Thanks!
eMarcel
Edited by: eMarcel on Jan 16, 2012 3:56 PM

Thanks:)

Similar Messages

  • Sometimes when I am texting the screen freezes.  I have to go out of messages and return and then I can send.

    Sometimes when I am texting the screen freezes.  I have to go out of messages and return and then I can send.

    Hello mdcrab1,
    Thank you for participating in the Apple Support Communities.
    If your screen freezes sometimes when you're texting until you quit and re-launch Messages, try these troubleshooting steps first:
    Restart your device and check for updates
    Restart your device.
    Check for a carrier settings update.
    Check for an iOS software update.
    You can find these steps and more troubleshooting tips at this link:
    If you can't send or receive messages on your iPhone, iPad, or iPod touch - Apple Support
    If the issue continues, and it only happens in the Messages app, I recommend trying the rest of the steps in the above article.
    If the screen freezes sometimes when you're using other apps, the steps in this article can help:
    If the screen on your iPhone, iPad, or iPod touch doesn't respond to touch - Apple Support
    Sincerely,
    Jeremy

  • How am I to be able a user to grant access only to see a procedure / function without execute,compile,edit and drop?

    how am I to be able a user to grant access only to see a procedure / function without execute,compile,edit and drop?

    Sorry GregV but thank you, are you sure you can only be done by setting a PC? Can not by giving them certain privileges of a PC?
    PL \ SQL that we use a portable version.
    So actually like this, user A is only used by the X, user A wants to provide read-only access to user B is only used by Y (another PC) to the procedures / functions held user A. How do you?

  • Javascript to Display message and return to home page

    Hi
    I have a requirement to display an acknowledgement message after a button has been pressed and return to home page.
    I created some JS and tested on a standalone button.
    <script type="text/javascript">
    function GoToHome_ack()
    alert("Authorisation Created!");
    // goto to page 1
    location.href = "f?p=&APP_ID.:1:&SESSION.";
    </script>
    Now the problem is I need to call this code after I have successfully executed 2 Processes conditionally on a Create Authorisation Button
    The only logical place I tried to place the call was on the conditional Branch URL, because I need the Processes to execute first.
    javascript:GoToHome_ack();
    Unfortunately this failed
    Anybody any suggestions ??
    Regards
    Ade

    Hi,
    Quickly what come my mind is that create blank page and place to HTML header
    <script type="text/javascript">
    alert("Authorisation Created!");
    // goto to page 1
    location.href = "f?p=&APP_ID.:1:&SESSION.";
    </script>Then branch to that page instead javascript:GoToHome_ack();
    br, Jari

  • Dequeue a message, wait 30 second, then dequeue second message and so forth

    Hi,
    I am using Oracle 9i AQ. What configuration i need to achieve this:
    Suppose there are 3 messages in queue.
    1) Dequeue 1st message.
    2) wait 30 seconds
    3) Dequeue 2nd message.
    4) wait 30 seconds
    5) dequeue 3rd message.
    there is the 30 seconds that i want to implement. How do i configure the queue to have this effect?
    I have try to configure latency to 30 seconds, the result is:
    1) wait 30 seconds
    2) dequeue 1st, 2nd and 3rd message.
    Which is the undesirable result.
    Thanks in advance.

    do the dequeue within a dbms-job with the interval of
    30 seconds ?!?How to check if my configuration have this setting? If my configuration have not this setting, how to change it?

  • Error message and set cursor field in subscreen

    hey ,
    i have a program with main screen 500 and many subscreens 501,502 and so own .
    when i  want to validate wrong input in a field and set message type 'E' in the PAI of the subscreen the program
    raise the message and exit from the program .
    if i try to put the message in the PBO of the subscreen it dosn't exit but after the message the program dosn't flow to
    command SET CURSOR FIELD that i wrote after the message .
    how can i solve this ?
    is there somthing that i'm missing in the basic code flow of the program ?
    ( screen 500 PBO - PAI ->  SUBSCREEN 50x PBO - PAI )
    best regards
    ASA

    hello and thanks for the answer
    let me  clarify my problem :
    i want to issue a message ( type e or i ) only if some fields are null and the user pressed on SAVE .
    when i'm in the tab-strip and writing error message in :
    PAI :
    chain.
    field XXX
    field YYY
    module issue_warning_message on chain-request.
    endchain.
    in  module issue_warning_message :  if XXX is initial --> message type E --> set cursor field XXX.
    here i get the message and cursor is set.
    when i try to post the message in without chain or any events :
    module user_command_tab502 .
    the message is issued and it exit the program if the type is e and if type message is I the cursor is not set .
    please advice
    ASA

  • Procedure to take inpot data set and return result set

    Hi all,
    I have a situation where there will be one "standard" set of data (source_data below) and I will need to get information on results for certain groups of clients (client_data being an example). As straight SQL this would be very easy (see below) -- real world problem is a little more complicated. However, what I would like to do is set up a procedure so that I can pass it my variable client data and it will spit back out a data set the same as the output from the given SQL.
    A pointer in the right direction would be appreciated. If I could "pass the client data" as a string containing a SQL query, that would be even better, e.g.
    GetResults('select client_id,min(whatever_date) from some_client_data where .....',MyOutputRefCursor?)
    create table source_data
    (client_id integer,
    tdate date,
    amount number(6,2));
    create table client_data
    (client_id integer,
    critical_date date);
    insert into source_data values(1,to_date('20090104','yyyymmdd'),1000);
    insert into source_data values(1,to_date('20100104','yyyymmdd'),2000);
    insert into source_data values(1,to_date('20110104','yyyymmdd'),3000);
    insert into source_data values(1,to_date('20120104','yyyymmdd'),4000);
    insert into source_data values(2,to_date('20090104','yyyymmdd'),5000);
    insert into source_data values(2,to_date('20090604','yyyymmdd'),1000);
    insert into source_data values(2,to_date('20100104','yyyymmdd'),2000);
    insert into source_data values(3,to_date('20091004','yyyymmdd'),3000);
    insert into source_data values(3,to_date('20091104','yyyymmdd'),4000);
    insert into source_data values(4,to_date('20090104','yyyymmdd'),5000);
    insert into source_data values(4,to_date('20090604','yyyymmdd'),2000);
    insert into client_data values(1,to_date('20110104','yyyymmdd'));
    insert into client_data values(2,to_date('20090604','yyyymmdd'));
    select c.client_id,
      sum(CASE WHEN tdate < critical_date then amount else null end) used_before,
      sum(CASE WHEN tdate >= critical_date then amount else null end) used_after
    from source_data s
    inner join client_data c on s.client_id = c.client_id
    GROUP BY c.client_id;Thanks,
    Jon

    JonWat wrote:
    I have a situation where there will be one "standard" set of data (source_data below) and I will need to get information on results for certain groups of clients > (client_data being an example). As straight SQL this would be very easy (see below) -- real world problem is a little more complicated. Can you give a more accurate representation of the real world problem?
    A pointer in the right direction would be appreciated. If I could "pass the client data" as a string containing a SQL query, that would be even better, e.g.Passing a query as as string for execution is rarely the correct approach. This approach won't scale and most likely will result in maintenance and security problems.
    If you can update your post to have a more accurate representation of the problem you are trying to solve you'll probably get an acceptable answer. Other than that all I can suggest is that you need to rethink the approach a bit. For example, if you know you need to filter out a set of data to join to your SOURCE_DATA table, why couldn't you do that inside the procedure?
    SELECT c.client_id
         , SUM
           ( CASE
             WHEN tdate < critical_date
             THEN amount
             END
           ) AS used_before
        ,  SUM
           ( CASE
             WHEN tdate >= critical_date
             THEN amount
             END
           ) AS used_after
    FROM   source_data s
    JOIN   ( SELECT client_id
                  , MIN(<date column>) AS critical_date
             FROM   client_data
             WHERE  <where clause>
             GROUP BY client_id
           ) c on s.client_id = c.client_id
    GROUP BY c.client_id;

  • Procedure which inserted and returns value

    i don't know english very vell and sorry about it :(((
    i want write a procedure which inserted or updated table and returns it's ID ...
    it's my tabel :
    DROP TABLE T_STUDENT CASCADE CONSTRAINTS;
    CREATE TABLE T_STUDENT
    ID NUMBER(10) NOT NULL,
    NAME VARCHAR2(100) NOT NULL,
    SURNAME VARCHAR2(100) NOT NULL,
    AGE NUMBER(38) NOT NULL,
    CNAUTHORID NUMBER(10) NULL
    and i have procedure which inserted or updated this table and return's ID (if ID<=0 then inserted else updated):
    CREATE OR REPLACE procedure sp_InsertUpdate_T_STUDENT
    nResID in out NUMBER,
    nID in NUMBER,
    vchNAME in VARCHAR2,
    vchSURNAME in VARCHAR2,
    nAGE in NUMBER,
    nCNAUTHORID in NUMBER
    as
    begin
    if nID<=0 then
    insert into T_STUDENT (NAME,SURNAME,AGE,CNAUTHORID) values (vchNAME,vchSURNAME,nAGE,nCNAUTHORID );
    else
    update T_STUDENT set NAME=vchNAME,SURNAME=vchSURNAME,AGE=nAGE,CNAUTHORID=nCNAUTHORID
    where ID=nID;
    end if;
    select ID into nResID from T_STUDENT where NAME=vchNAME and
    SURNAME=vchSURNAME and AGE=nAGE and CNAUTHORID=nCNAUTHORID;
    end;
    this procedure is correct but maybe returns more then one ID and i don't want it :( ....... how i can write this procedure otherwise ???

    First of all does yout insert statement work??
    insert into T_STUDENT (NAME,SURNAME,AGE,CNAUTHORID) values (vchNAME,vchSURNAME,nAGE,nCNAUTHORID )
    Should you not insert also the value ID?
    The way i would do this was first since u have only have one return value is a function like this:
    function sp_InsertUpdate_T_STUDENT
    nID in NUMBER,
    vchNAME in VARCHAR2,
    vchSURNAME in VARCHAR2,
    nAGE in NUMBER,
    nCNAUTHORID in NUMBER
    ) return number
    is
    ln_id number;
    begin
    if nID<=0 then
    insert into T_STUDENT (ID,NAME,SURNAME,AGE,CNAUTHORID) values (SEQ_ID.NEXTVALUE,vchNAME,vchSURNAME,nAGE,nCNAUTHORID ) returning ID into ln_id;
    else
    update T_STUDENT set NAME=vchNAME,SURNAME=vchSURNAME,AGE=nAGE,CNAUTHORID=nCNAUTHORID
    where ID=nID;
    ln_id := nID;
    end if;
    return ln_id;
    end;

  • Creating a function and return something from an XML file

    Hi!
    I'm working with timeline actionscript. I want to create a function that loads my xmlfile and returns an xmlobject with the file's content.
    This is what I got so far:
    my_btn.addEventListener(MouseEvent.CLICK, getXML("myxml.xml")); //1067: Implicit coercion of a value of type void to an unrelated type Function.
    function getXML(fn:String):void{
         var infoLoader:URLLoader = new URLLoader();
         infoLoader.addEventListener(Event.COMPLETE, xmlLoaded);
         infoLoader.load(new URLRequest(fn));
         var myXML:XML = xmlLoaded(); //1136: Incorrect number of arguments.  Expected 1.
         trace(myXML);
    function xmlLoaded(e:Event):XML{
         return e.target.data;
         //trace(e.target.data);
    Can anyone take a look and perhaps point me in the right direction?
    Thanks

    I have never used a listcomponent, so I can only help with the steps before filling it with data.
    I think you should at start of your application load the XML with filenames and just after it's completed, e.g. in Event.COMPLETE handler, load all other XMLs looping through filenamesXML, like this
    var filenamesXML:XML;
    var XMLsToLoad:uint = 0;
    function filenamesXMLLoaded(e:Event):void
         filenamesXML = XML(e.target.data);
         XMLsToLoad =  filenamesXML.filenames.children().length();
         for (var i:uint =1; i < filenamesXML.filenames.children().length(); i++)
                  getXML( filenamesXML.filenames.children()[i] ); // the function from my previous post, don't forget to implement it
    //modify the minor xml load handler from the previous post
    function xmlLoaded(e:Event):void
         var loadedXML:XML = XML(e.target.data);   
         xmlArray.push(loadedXML);
         XMLsToLoad--;
    //assign the one click handler to all buttons, a loop here would be quite handy
    function clickHandler(e:MouseEvent):void
         if (XMLsToLoad == 0) //check if all xmls have been completely loaded
              switch (e.target.name) // swith by clicked button's instance name
                   case "button_1":
                        // here you have to implement supplying listcomponent with data, I think a loop again will be a good idea
                        break;
                   case "button_2":
                        // ibid.
                        break;
    Regards,
    gc

  • OCI8: returning cursors from stored procedures

    The short version of my question is:
    In OCI8, how do open a cursor from the database stored procedure, return it to my C++ program and fetch from it, given that in OCI8 cursors and cursor functions are becoming obsoleted?
    The long version of the same question is:
    I am converting my C++ code from the Oracle 7.3 OCI driver to the Oracle8 OCI driver. One thing I did very frequently in Oracle 7.3 OCI code is open a multi-row select cursor within a stored procedure and return that cursor to my program. In the program, I would then do the fetching with the returned cursor. This was very useful, as it allows me to change the queries in the stored procedure (for example, to append information to certain columns or make some data in all uppercase) without recompiling the application due to a changed SQL string.
    My 7.3 psuedocode is as follows:
    stored procedure def:
    TYPE refCurTyp IS REF CURSOR;
    FUNCTION LoadEmployeeData RETURN refCurTyp;
    stored procedure body:
    FUNCTION LoadEmployeeData RETURN refCurTyp IS
    aCur refCurTyp;
    BEGIN
    OPEN aCur FOR
    SELECT emp_id, emp_name
    FROM employee_table
    ORDER BY emp_name;
    return aCur;
    END;
    OCI code: // all functions are simplified, not actual parameter listing
    // declare main cursor variable #1 and return cursor variable #2
    Cda_Def m_CDAstmt, m_CDAfunction;
    // open both cursors
    oopen(m_CDAstmt, ...);
    oopen(m_CDAfunction, ...);
    // bind cursor variable to cursor #2
    oparse(&m_CDAstmt, "BEGIN :CUR := MYPACKAGE.LoadEmployeeData; END;");
    obindps(&m_CDAstmt, SQLT_CUR, ":CUR", &m_CDAfunction);
    // run cursor #1
    oexn(&m_CDAstmt);
    // bind variables from cursor #2, and fetch
    odefineps(&m_CDAfunction, 1, SQLT_INT, &m_iEmpId);
    odefineps(&m_CDAfunction, 2, SQLT_CHAR, &m_pEmpName);
    while (!ofen(&m_CDAfunction))
    // loop: do something with fetch
    // values placed in m_iEmpID and m_pEmpName
    This works perfectly, and has really helped to make my code more maintainable. Problem is, in Oracle 8 OCI both cursors and the cursor functions (such as oopen()) are becoming obsoleted. Now it uses statement and environment handles. I know I can still use Cda_Def and cursors--for a while--within OCI8, but I need to know the official up-to-date method of returning a cursor from the database and fetching within my C++ code. Any code fragment, or explanation of what I need to do in OCI8 would be appreciated (perhaps I need to bind to a statement handle instead? But the stored procedure still returns a cursor.)
    The Oracle8 OCI has a new SQLT_ type, SQLT_RSET, which the header file defines as "result set type". Unfortunately, it's almost completely undocumented in the official documentation. Am I supposed to use this instead of the obsolete SQLT_CUR?
    Thanks,
    Glen Mazza

    Email me diorectly and I will get you some code that might help. I fail to see the relevance of posting this type of information in the JDeveloper forum.

  • Dequeuing the message using Non Sys user

    Hi all,
    I've implemented Advanced Queuing in one Schema(Say "temp") which has AQ privileges. My requirement is Asynchronous Communication between two programs.
    In One program i've DBMS_AQ.ENQUEUE to put the message onto the queue. The user "temp" enqueued the message.
    I've a anonymous PL/SQL callback procedure registered to dequeue the message. but while dequeuing the message, the user is "SYS". Immediately after dequeuing the message, i've a call to the second program which uses some views. In my application we have dba policies applied to these views. So only temp user can access those views where SYS user doesnt have any access to these views.
    we already have one solution i.e., giving access to SYS user also but this will result in some other security concerns for the application
    Another solution could be dequeuing the message with "temp" user (NON sys user).
    So i would like to know whether it is possible to dequeue the message with NON-SYS user ? i've tried searching the dequeue options and message properties but couldn't get anything..
    can anyone help me in solving this problem??

    Hi paul,
    Thanks for the response :). I've tried this already but still the dequeue user id "SYS". i'll explain you in detail with the code.
    I've create queue table and queue with the following code :
    create or replace TYPE temp_msg_type as object (seq_no NUMBER(10),
    req_type varchar2(6))
    begin
    dbms_aqadm.create_queue_table(
    queue_table => 'test_queue_tab',
    queue_payload_type => 'temp_msg_type',
    multiple_consumers => true);
    dbms_aqadm.create_queue(
    queue_name => 'test_queue',
    queue_table => 'test_queue_tab');
    dbms_aqadm.start_queue(
    queue_name => 'test_queue');
    end;
    After this an Agent is subscribed to this queue.
    begin
    dbms_aqadm.add_subscriber(
    queue_name => 'test_queue',
    subscriber => sys.aq$_agent('recipient', null, null));
    end;
    Then registered an PL/SQL callback procedure to this queue.
    begin
    dbms_aq.register(aq$_reg_info_list(
    aq$_reg_info('test_queue:RECIPIENT',
    DBMS_aq.NAMESPACE_AQ,
    'plsql://notifyCB_prd',
    HEXTORAW('FF')) ) ,
    1);
    end;
    The follwing procedure will enqueue the message. in the below code before i enqueue it i am inserting the current sessions' user, it got printed as "SCOTT".
    create or replace procedure enqueue_msg_prd( O_status_code IN OUT varchar2 )
    as
    enqueue_options dbms_aq.enqueue_options_t;
    message_properties dbms_aq.message_properties_t;
    message_handle RAW(16);
    message temp_msg_type;
    begin
    --enqueue_options.visibility := DBMS_AQ.IMMEDIATE;
    message := temp_msg_type(112, user);
    O_status_code := 'S';
    dbms_aq.enqueue(queue_name => 'test_queue',
    enqueue_options => enqueue_options,
    message_properties => message_properties,
    payload => message,
    msgid => message_handle);
    end;
    The following procedure will dequeue the message. this procedure will be automatically triggered when i commit the enqueue transaction since there is anonymous callback procedure registered for this queue. In the below code after i dequeue it i am inserting the sessions' user, it got printed as "SYS".
    create or replace
    procedure notifyCB_prd( context raw,
    reginfo aq$_reg_info,
    descr aq$_descriptor,
    payload raw,
    payloadl number)
    as
    dequeue_options dbms_aq.dequeue_options_t;
    message_properties dbms_aq.message_properties_t;
    message_handle raw(16);
    message temp_msg_type;
    begin
    dequeue_options.msgid := descr.msg_id;
    dequeue_options.consumer_name := descr.consumer_name;
    --execute immediate 'conn  session set current_user= scott';
    DBMS_AQ.DEQUEUE(
    queue_name => descr.queue_name,
    dequeue_options => dequeue_options,
    message_properties => message_properties,
    payload => message,
    msgid => message_handle);
    insert into temp values(message.seq_no,user);
    commit;
    end;
    Even i queried the aq$test_queue_Tab view. in this view, value in deq_user_id is "SYSS"
    is there any way to get the users session as 'SCOTT' ??

  • How to dequeue a message which does not have namespace ?

    I am trying to dequeue message from b2b ip_in_queue using AQ adapter.
    The message does not have namespace.
    Schema definition in BPEL has namespace.
    Is there anyway to dequeue the message and use it in BPEL ?

    I found the fix in other thread. Adding below lines fixed my issue.
    xmlns:nxsd="http://xmlns.oracle.com/pcbpel/nxsd"
    nxsd:version="DTD"
    Thankyou.

  • User defined function and returning resultset

    Hi all,
    Following query, if I comment the statement in where clause which refers to a returning value of a function in the subquery, it takes 1 sec to finish. when uncomment it however, can't finish in 30 mins. Please help me on finding out the problem.
    I'm also wondering how to get a returning cursor in this case(to bypass above trouble)..
    Many thanks
    -s
    --pseudocode for how can I get a cursor in an anonymous block for host app
    begin
    -- get the resultset1 in someway
    select t1.showit,...
    from t1..;
    -- based on resultset1
    open myrefcursor for
    select * from resultset1 -- what is the resultset1?
    where resultset1.showit=1;
    end;
    --end pseudocode for getting a cursor
    -- hanging(takes too long) query (simplified)
    select t1.*,t2.account,t2.showit
    from (select t3.account,myfunc(t3.account) showit
    from tbl2 t3) t2,
    tbl1 t1
    where t1.account=t2.account
    and ...
    /* "hang" this query by uncomment this */
    -- and t2.showit=1;
    -- functions
    function myfunc(p_acc varchar2)
    return number is
    v_tmpdate date;
    v_invdate date;
    v_tmpcount number(8);
    v_accid number(8);
    v_curodisp number(14,4);
    v_curdisp number(14,4);
    v_curdisprev number(14,4);
    v_rowcount number(8);
    v_tmpshow number(8);
    p_vkey number(8);
    p_inv varchar(50);
    cursor cur(cv_vkey number, cv_accid number, cv_lastdate date) is
    select a.vkey vkey,a.invdate invdate, b.odisp odisp
    from inv a, recon b
    where a.vkey=cv_vkey
    and a.akey = cv_accid
    and a.invdate between to_date('01/01/2000','DD/MM/YYYY')
    and cv_lastdate
    and b.vkey = a.vkey
    and b.inv# = a.inv#
    order by invdate DESC;
    begin
    select vkey,inv#,akey, invdate into p_vkey,p_inv,v_accid, v_invdate
    from inv
    where akey = p_acc;
    v_tmpdate := add_months(v_invdate, 1);
    select count(*) into v_tmpcount
    from recon a, inv b
    where b.vkey = p_vkey
    and b.akey = v_accid
    and b.invdate between to_date('01/01/2000','DD/MM/YYYY')
    and v_tmpdate
    and a.inv# = b.inv#
    and a.vkey = b.vkey;
    if v_tmpcount = 0 then
    return 0;
    end if;
    v_rowcount := 0;
    for c1 in cur(p_vkey,v_accid,v_tmpdate) loop
    v_rowcount := v_rowcount + 1;
    v_curdisp := getcurdisp(c1.vkey,c1.inv#);
    v_curdisprev := getcurdisprev(c1.vkey,c1.inv#);
    v_curodisp := nvl(c1.odisp, 0) - v_curdisp - v_curdisprev;
    if v_curodisp >= 1000 then
    return 1;
    elsif v_curodisp = 0 then
    return 0;
    end If;
    end if;
    if extract(month from c1.invdate) in ('1','01')
    and extract(year from c1.invdate) = '2000' then
    select a.showodisp into v_tmpshow
    from acc a, inv b
    where b.vkey = c1.vkey
    and b.inv# = c1.inv#
    and a.akey = b.akey;
    return v_tmpshow;
    end If;
    end loop;
    return 0;
    end myfunc;
    function getcurdisp(p_vkey,p_inv)
    return number is
    v_tmp number(15,4);
    begin
    select sum(amount) into v_tmp
    from cost
    where vkey=p_vkey
    and inv#=p_inv
    and desc like '%disp';
    return v_tmp;
    end;
    function getcurdisprev(p_vkey,p_inv)
    return number is
    v_tmp number(15,4);
    begin
    select sum(amount) into v_tmp
    from cost
    where vkey=p_vkey
    and inv#=p_inv
    and desc like '%disprev';
    return v_tmp;
    end;

    Autotrace only showed the index usage on the main query, but nothing on the queries within the functions, so here is the tkprof that shows index usage on the queries within the functions.
    TKPROF: Release 9.2.0.1.0 - Production on Mon Jan 17 00:31:39 2005
    Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.
    Trace file: ora92_ora_4092.trc
    Sort options: default
    count    = number of times OCI procedure was executed
    cpu      = cpu time in seconds executing
    elapsed  = elapsed time in seconds executing
    disk     = number of physical reads of buffers from disk
    query    = number of buffers gotten for consistent read
    current  = number of buffers gotten in current mode (usually for update)
    rows     = number of rows processed by the fetch or execute call
    alter session set sql_trace=true
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        0      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        0      0.00       0.00          0          0          0           0
    total        1      0.00       0.00          0          0          0           0
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 59 
    select t1.*, t2.account, t2.showit
    from   tbl1 t1,
           (select account, myfunc(account) showit
            from   tbl2) t2
    where  t1.account = t2.account
    and    t2.showit = 1
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.11       1.81          0          1          0           0
    total        3      0.11       1.81          0          1          0           0
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 59 
    Rows     Row Source Operation
          0  NESTED LOOPS 
          0   INDEX FULL SCAN OBJ#(69662) (object id 69662)
          0   INDEX RANGE SCAN OBJ#(69661) (object id 69661)
    select user#
    from
    sys.user$ where name = 'OUTLN'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        1      0.00       0.00          0          2          0           1
    total        3      0.00       0.00          0          2          0           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: SYS   (recursive depth: 2)
    Rows     Row Source Operation
          1  TABLE ACCESS BY INDEX ROWID USER$
          1   INDEX UNIQUE SCAN I_USER1 (object id 44)
    select a.vkey, a.invdate, b.odisp, a.inv#
         from   inv a, recon b
         where  a.akey = :b1
         and    a.invdate between to_date ('01/01/2000', 'DD/MM/YYYY')
                          and     add_months (a.invdate, 1)
         and    b.vkey = a.vkey
         and    b.inv# = a.inv#
         order  by a.invdate DESC
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.10          0          0          0           0
    Execute    105      0.00       0.01          0          0          0           0
    Fetch      105      0.01       0.01          0        309          0         100
    total      211      0.01       0.13          0        309          0         100
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
        100  SORT ORDER BY
        104   TABLE ACCESS BY INDEX ROWID RECON
        313    NESTED LOOPS 
        104     INDEX FULL SCAN INV_IDX (object id 69658)
        104     INDEX RANGE SCAN RECON_IDX (object id 69659)
    SELECT sum (amount)
      from   cost
      where  vkey = :b2
      and    inv# = :b1
      and    descr like '%disp'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.00       0.00          0          0          0           0
    Fetch      100      0.01       0.00          0        100          0         100
    total      201      0.01       0.01          0        100          0         100
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
        100  SORT AGGREGATE
          0   TABLE ACCESS BY INDEX ROWID COST
          0    INDEX RANGE SCAN COST_IDX (object id 69657)
    SELECT sum (amount)
      from   cost
      where  vkey = :b2
      and    inv# = :b1
      and    descr like '%disprev'
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.00       0.00          0          0          0           0
    Fetch      100      0.01       0.00          0        100          0         100
    total      201      0.01       0.01          0        100          0         100
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
        100  SORT AGGREGATE
          0   TABLE ACCESS BY INDEX ROWID COST
          0    INDEX RANGE SCAN COST_IDX (object id 69657)
    SELECT a.showodisp
          from   acc a, inv b
          where  b.vkey = :b2
          and    b.inv# = :b1
          and    a.akey = b.akey
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute    100      0.01       0.00          0          0          0           0
    Fetch      100      0.03       0.00          0        299          0          99
    total      201      0.04       0.01          0        299          0          99
    Misses in library cache during parse: 1
    Optimizer goal: CHOOSE
    Parsing user id: 59     (recursive depth: 1)
    Rows     Row Source Operation
         99  TABLE ACCESS BY INDEX ROWID ACC
        299   NESTED LOOPS 
        100    INDEX RANGE SCAN INV_IDX (object id 69658)
         99    INDEX RANGE SCAN ACC_IDX (object id 69660)
    begin
        for x in ( select * from session_trace_file_name )
        loop
            if ( dbms_lob.fileexists( bfilename('UDUMP_DIR', x.filename ) ) = 1 )
            then
                insert into avail_trace_files (filename) values (x.filename);
            end if;
        end loop;
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.01       0.00          0          0          0           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.01       0.00          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 736     (recursive depth: 1)
    select *
    from
    session_trace_file_name
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          0           0
    Fetch        2      0.00       0.00          0          0          0           1
    total        4      0.00       0.00          0          0          0           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 736     (recursive depth: 2)
    INSERT into avail_trace_files (filename)
    values
    (:b1)
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      1      0.00       0.00          0          0          3           1
    Fetch        0      0.00       0.00          0          0          0           0
    total        2      0.00       0.00          0          0          3           1
    Misses in library cache during parse: 0
    Optimizer goal: CHOOSE
    Parsing user id: 736     (recursive depth: 2)
    OVERALL TOTALS FOR ALL NON-RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        1      0.00       0.00          0          0          0           0
    Execute      2      0.00       0.00          0          0          0           0
    Fetch        1      0.11       1.81          0          1          0           0
    total        4      0.11       1.81          0          1          0           0
    Misses in library cache during parse: 0
    OVERALL TOTALS FOR ALL RECURSIVE STATEMENTS
    call     count       cpu    elapsed       disk      query    current        rows
    Parse        8      0.00       0.11          0          0          0           0
    Execute    409      0.02       0.04          0          0          3           2
    Fetch      408      0.06       0.03          0        810          0         401
    total      825      0.08       0.19          0        810          3         403
    Misses in library cache during parse: 4
        9  user  SQL statements in session.
        1  internal SQL statements in session.
       10  SQL statements in session.
    Trace file: ora92_ora_4092.trc
    Trace file compatibility: 9.00.01
    Sort options: default
           1  session in tracefile.
           9  user  SQL statements in trace file.
           1  internal SQL statements in trace file.
          10  SQL statements in trace file.
          10  unique SQL statements in trace file.
         945  lines in trace file.

  • Returning both raise_application_error and return value from db function...

    Hi ,
    I use Oracle 10g and forms10g.
    I have written a db packaged function such as:
    function fnc_ipologismos_xiliometron(code_poleis_apo_var in varchar2,code_poleis_pros_var in varchar2)
       return number
       is
        apostasi_var ref_apostaseis_poleon.apostasi%type;
        onomasia_pol_apo_var ref_poleis.onomasia%type;
        onomasia_pol_pros_var ref_poleis.onomasia%type;
        begin
         begin
            select onomasia into onomasia_pol_apo_var
              from ref_poleis
              where code_poleis=code_poleis_apo_var;
         end;
         begin
            select onomasia into onomasia_pol_pros_var
              from ref_poleis
              where code_poleis=code_poleis_pros_var;
         end;
         begin
          select apostasi into apostasi_var
           from ref_apostaseis_poleon
           where code_poleis_apo=code_poleis_apo_var and code_poleis_pros=code_poleis_pros_var;
          exception
           when no_data_found
    then
    apostasi_var:=0;
    return apostasi_var;
    raise_application_error(-20015,'a message');
    --return apostasi_var;
    end;      return apostasi_var;
        end;The problem is that when the exception written above (in bold) returns 0 and exits the function.... whereas i want this value to be returned as well as the message in the raise_application_error....
    I call this function in WHEN-VALIDATE-ITEM of a block item... such as:
    if pkg_mod3_general.fnc_ipologismos_xiliometron
    (:mod3_entoli_metakinisis.code_poleis_apo_type_id,:mod3_entoli_metakinisis.code_poleis_type_id)=0
                  and :mod3_entoli_metakinisis.seq_code_meso_metakin_type_id=2
                  then
                    raise form_trigger_failure;
      end if;     When the above condition is true then no message is displayed and the cursor sticks to the item(as the raise_application_error in the db packaged function is after the exit of the function) and when the condition is false then no message is displayed again ... as expected.....
    How is it get the desired result.....- get the message from the raise_application_error and the function returns 0.....?????
    Many thanks,
    Simon

    you cannot RETURN and RAISE a function.
    RETURN ends the function immediately
    RAISE ends the program unit and jumps in the EXCEPTION-Handler, if it exists. Else the function ends

  • How can I remove iTunes 11 and return to a functional version of iTunes?

    So I was really stupid and updated my perfectly operational version of iTunes to version 11.  After discovering that version 11 is almost totally non-functional (missing a number of useful functions that someone decided were too helpful I guess), I want to delete this horrid example of software non-functionality and return to the last functional version (iTunes 10).  Please tell me there's a way to remove this software wart and return to a functional iTunes.

    I found the following way to return to 10.7.  I moved the following directories and files to the desktop before I deleted iTunes 11:
    Album Artwork (folder)
    iTunes Media (folder)
    Previous iTunes Libraries (folder)
    The following file is found in the Previous iTunes Libraries:
    iTunes Library 2012-11-29.itl (the date on your file will vary depending on when you decided to add version 11)
    The following are files found in the iTunes directory
    iTunes Library Genus.itdb
    iTunes Library Extras.itdb
    Once you have copied these files to your desktop, you have to remove iTunes 11.  I used the uninstall option in CleanMyMac.
    I used this explanation to return to iTunes 10.7:
    Replace the iTunes 11 application with iTunes 10.7
    https://discussions.apple.com/message/20431349
    iTunes 10.7 for OS X  http://appldnld.apple.com/iTunes10/041-7195.20120912.d3uzQ/iTunes10.7.dmg
    You will have to rescue your old iTunes library from your Previous Libraries folder and rename it iTunes Library.itl because a newer version of iTunes irreversibly updates your library file.  See:
    https://discussions.apple.com/mesage/20401436 - turingtest2 11/2012 post on rebuilding empty/corrupt library after upgrade/crash from previous iTunes library file.
    iTunes: How to re-create your iTunes library and playlists - http://support.apple.com/kb/ht1451
    Other issues:
    https://discussions.apple.com/message/20432309 - solution to mobile devices saying they need to be restored after downgrading
    Once you have reinstalled 10.7, put the files and folders you copied to the desktop back into iTunes overwriting the new files that were created during the install.  Restart iTunes and you should see iTunes start to reinstall all the missing files.  This doesn't seem to recreate the playlists but I can fix that problem myself.
    So far, it seems to be working.  YMMV and I'm not recommending you try this, I'm just saying that it's worked for me.

Maybe you are looking for