A newbie for cursors...

Hello,
I have a parameterized cursor that i have successfully opened. However, i wish to return it via the calling procedure's poResult out sys_refcursor .
any ideas please?
Thanks in advance
Alan Seunarayan

Have a look at Tom Kytes detailed HowTo
Getting Result Sets from Stored Procedures
http://asktom.oracle.com/~tkyte/ResultSets/index.html

Similar Messages

  • Use of FOR Cursor and BULK COLLECT INTO

    Dear all,
    in which case we prefer to use FOR cursor and cursor with BULK COLLECT INTO? The following contains two block that query identically where one is using FOR cursor, the other is using BULK COLLECT INTO . Which one that performs better given in the existing task? How do we measure performance between these two?
    I'm using sample HR schema:
    declare
    l_start number;
    BEGIN
    l_start:= DBMS_UTILITY.get_time;
    dbms_lock.sleep(1);
    FOR employee IN (SELECT e.last_name, j.job_title FROM employees e,jobs j
    where e.job_id=j.job_id and  e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name)
    LOOP
      DBMS_OUTPUT.PUT_LINE ('Name = ' || employee.last_name || ', Job = ' || employee.job_title);
    END LOOP;
    DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
    END;
    declare
    l_start number;
    type rec_type is table of varchar2(20);
    name_rec rec_type;
    job_rec rec_type;
    begin
    l_start:= DBMS_UTILITY.get_time;
    dbms_lock.sleep(1);
    SELECT e.last_name, j.job_title bulk collect into name_rec,job_rec FROM employees e,jobs j
    where e.job_id=j.job_id and  e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name;
    for j in name_rec.first..name_rec.last loop
      DBMS_OUTPUT.PUT_LINE ('Name = ' || name_rec(j) || ', Job = ' || job_rec(j));
    END LOOP;
    DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
    end;
    /In this code, I put timestamp in each block, but they are useless since they both run virtually instantaneous...
    Best regards,
    Val

    If you want to get 100% benifit of bulk collect then it must be implemented as below
    declare
         Cursor cur_emp
         is
         SELECT     e.last_name, j.job_title
         FROM     employees e,jobs j
         where     e.job_id=j.job_id
                   and  e.job_id LIKE '%CLERK%'
                   AND e.manager_id > 120
         ORDER BY e.last_name;
         l_start number;
         type rec_type is table of varchar2(20);
         name_rec rec_type;
         job_rec rec_type;
    begin
         l_start:= DBMS_UTILITY.get_time;
         dbms_lock.sleep(1);
         /*SELECT e.last_name, j.job_title bulk collect into name_rec,job_rec FROM employees e,jobs j
         where e.job_id=j.job_id and  e.job_id LIKE '%CLERK%' AND e.manager_id > 120 ORDER BY e.last_name;
         OPEN cur_emp;
         LOOP
              FETCH cur_emp BULK COLLECT INTO name_rec LIMIT 100;
              EXIT WHEN name_rec.COUNT=0;
              FOR j in 1..name_rec.COUNT
              LOOP
                   DBMS_OUTPUT.PUT_LINE ('Name = ' || name_rec(j) || ', Job = ' || job_rec(j));          
              END LOOP;
              EXIT WHEN cur_emp%NOTFOUND;
         END LOOP;
            CLOSE cur_emp;
         DBMS_OUTPUT.put_line('total time: ' || to_char(DBMS_UTILITY.get_time - l_start) || ' hsecs');
    end;
    /

  • How to check with table for cursor..?

    How to check with table for cursor..?
    Here I have Table temp_final_plan
    Here i want to update if already exit...below is the procedure....
    CREATE OR REPLACE PROCEDURE spu_final_profit_plan
    AS
    -- Constant declarations
      ln_errnum number := 0;
    -- Variable declarations
       ls_errmsg app_errors.err_msg%TYPE;
       ls_appmsg app_errors.app_msg%TYPE;
       ls_appid  app_errors.app_id%TYPE;
    -- Cursor declaration for final_update_el
    CURSOR cur_final_update_el IS
        select '910' ent,
               '9127316' center,
               post_acct,
               sum(avg_mtd_01) sum_avg_mtd_01,
               sum(avg_mtd_02) sum_avg_mtd_02,
               sum(avg_ytd_01) sum_avg_ytd_01,
               sum(avg_ytd_02) sum_avg_ytd_02
          from mon_act_cypy
         where rec_type = 'A'
           and sum_flag = 'D'
           and yr = '2008'
           and substr(ctr_or_hier, 1, 2) = 'el'
           and ent || sub_ent in
               (select ent || sub_ent
                  from ent_ref
                 where roll_ent || roll_sub_ent = '999100')
         group by post_acct
        having sum(avg_mtd_01) <> 0
            or sum(avg_mtd_02) <> 0
            or sum(avg_ytd_01) <> 0
            or sum(avg_ytd_02) <> 0;
    -- Cursor declaration for final_update
    CURSOR cur_final_update IS
        select b.plan_ent b_plan_ent,
               b.plan_ctr b_plan_ctr,
               a.post_acct a_post_acct,
               sum(a.avg_mtd_01) sum_avg_mtd_01,
               sum(a.avg_mtd_02) sum_avg_mtd_02,
               sum(a.avg_ytd_01) sum_ytd_mtd_01,
               sum(a.avg_ytd_02) sum_ytd_mtd_02
          from mon_act_cypy a,
               plan_unit_tbl b
         where a.ent || a.ctr_or_hier = b.ent || b.ctr_or_hier
           and a.rec_type = 'A'
           and a.sum_flag = 'D'
           and a.yr = '2008'
           and b.hier_tbl_num = '001'
           and a.ent || a.sub_ent in
               (select ent || sub_ent
                  from ent_ref
                 where roll_ent || roll_sub_ent = '999100')
         group by b.plan_ent, b.plan_ctr, a.post_acct
        having sum(a.avg_mtd_01) <> 0
            or sum(a.avg_mtd_02) <> 0
            or sum(a.avg_ytd_01) <> 0
            or sum(a.avg_ytd_02) <> 0;
    -- Begin the procedure body
       BEGIN
    -- Insert / Update final profit plan for final_update query using cursor
       FOR rec_final_update_el IN cur_final_update_el
       LOOP
       EXIT WHEN rec_final_update_el%NOTFOUND;
       IF rec_final_update_el. THEN
          UPDATE temp_final_plan
             SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
                 sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,       
                 sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,       
                 sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,       
           WHERE ent = rec_final_update_el.ent
             AND center = rec_final_update_el.center
             AND post_acct = rec_final_update_el.post_acct;
       ELSE
          INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
                                             rec_final_update_el.center,
                                             rec_final_update_el.post_acct,
                                             rec_final_update_el.sum_avg_mtd_01,
                                             rec_final_update_el.sum_avg_mtd_02,
                                             rec_final_update_el.sum_avg_ytd_01,
                                             rec_final_update_el.sum_avg_ytd_02);
       END IF;
       END LOOP;
    -- Insert / Update final profit plan for final_update query using cursor
       FOR rec_final_update IN cur_final_update
       LOOP
       EXIT WHEN rec_final_update%NOTFOUND;
       IF rec_final_update. THEN
          UPDATE temp_final_plan
             SET sum_avg_mtd_01 = rec_final_update.sum_avg_mtd_01,
                 sum_avg_mtd_02 = rec_final_update.sum_avg_mtd_02,       
                 sum_avg_ytd_01 = rec_final_update.sum_avg_ytd_01,       
                 sum_avg_ytd_02 = rec_final_update.sum_avg_ytd_02,       
           WHERE ent = rec_final_update.b_plan_ent
             AND center = rec_final_update.b_plan_ctr
             AND post_acct = rec_final_update.a_post_acct;
       ELSE
          INSERT INTO temp_final_plan VALUES(rec_final_update.b_plan_ent,
                                             rec_final_update.b_plan_ctr,
                                             rec_final_update.a_post_acct,
                                             rec_final_update.sum_avg_mtd_01,
                                             rec_final_update.sum_avg_mtd_02,
                                             rec_final_update.sum_avg_ytd_01,
                                             rec_final_update.sum_avg_ytd_02);
       END IF;
       END LOOP;
    -- EXCEPTION handling section
       EXCEPTION
    -- Fire OTHERS Exception case by default
       WHEN OTHERS THEN
    -- ROLL BACK Transaction, if any failure
       ROLLBACK;
       ln_errnum := SQLCODE;
       ls_errmsg := SUBSTR(SQLERRM, 1, 100);
    -- Log the ERRORS into APP_ERRORS table using SPU_LOG_ERRORS procedure
       spu_log_errors(ln_errnum, ls_errmsg, ls_appid, ls_appmsg);
    -- End of the stored procedure
    END spu_final_profit_plan;
    [\pre]                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

    I'm not sure what you mean by, 'How to check with table for cursor..?' but I'll offer a comment on your Code Snippet. I think you want to know how to check if a record exists so you know if you need to perform an INSERT or an UPDATE.
    Here is a snippet of your code. I'll put my comments in "Comment" style in your code.
    -- Insert / Update final profit plan for final_update query using cursor
       FOR rec_final_update_el IN cur_final_update_el
       LOOP
    /* There is no need to test for %NOTFOUND since you are using Cursor FOR Loop! 
    ** This construct automatically exits when the last record is processed. */
       EXIT WHEN rec_final_update_el%NOTFOUND;
    /* Is this where you would like to know how to Check if the record already exist??
    ** I asked this because, 'rec_final_update_el.' is not valid syntax.  Are you looking for
    ** an Cursor Attribute or Method you can check here? 
    ** I would suggest a Primary Key or Unique Index on ENT, CENTER, and POST_ACCT
    ** on the TEMP_FINAL_PLAN table. Then simply perform an INSERT and code an
    ** Exception to UPDATE when you get a DUP_VAL_ON_INDEX exception.  Otherwise,
    ** you will need to simply run an Implicit or Explicit Cursor to test if the row exists and
    ** use this return value to determine if you should INSERT or UPDATE.  */
       IF rec_final_update_el. THEN
          UPDATE temp_final_plan
             SET sum_avg_mtd_01 = rec_final_update_el.sum_avg_mtd_01,
                 sum_avg_mtd_02 = rec_final_update_el.sum_avg_mtd_02,       
                 sum_avg_ytd_01 = rec_final_update_el.sum_avg_ytd_01,       
                 sum_avg_ytd_02 = rec_final_update_el.sum_avg_ytd_02,       
           WHERE ent = rec_final_update_el.ent
             AND center = rec_final_update_el.center
             AND post_acct = rec_final_update_el.post_acct;
       ELSE
          INSERT INTO temp_final_plan VALUES(rec_final_update_el.ent,
                                             rec_final_update_el.center,
                                             rec_final_update_el.post_acct,
                                             rec_final_update_el.sum_avg_mtd_01,
                                             rec_final_update_el.sum_avg_mtd_02,
                                             rec_final_update_el.sum_avg_ytd_01,
                                             rec_final_update_el.sum_avg_ytd_02);
       END IF;
       END LOOP;I hope I've answered your question, but if I haven't please provide more details so we can better understand your request.
    Craig...

  • Alternative for Cursor in SQL Server 2012

    Hi all,
      I keen to know Alternative for Cursor in SQL Server 2012. Why everyone telling Cursor have performance impact. Any other alternative for row by row comparison like Array in SQL 2012 ?
    Thanks

    It is not the cursor that kills you - it is the loop as such. I've seen more than one example of a poor man's cursor, where they have selected TOP 1 from a #temp ORDER BY, and several operations on the temp table - which is completely void of indexes,
    making the operations for the loop control the slowest in the batch. So you use cursor when you need to iterate.
    But in many cases, you should work and think set-based instead.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Newbie for the life of me can't figure out where in contact.php you tell it where to send form?

    Thx for any help.
    I know it's got to be so obbvious.
    Why would you send in php vs html?
    <?php
    if(!$_POST) exit;
    $email = $_POST['email'];
    //$error[] = preg_match('/\b[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}\b/i', $_POST['email']) ? '' : 'INVALID EMAIL ADDRESS';
    if(!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$email )){
    $error.="Invalid email address entered";
    $errors=1;
    if($errors==1) echo $error;
    else{
    $values = array ('name','email','message');
    $required = array('name','email','message');
    $your_email = "[email protected]";
    $email_subject = "New Message: ".$_POST['subject'];
    $email_content = "new message:\n";
    foreach($values as $key => $value){
       if(in_array($value,$required)){
      if ($key != 'subject' && $key != 'company') {
        if( empty($_POST[$value]) ) { echo 'PLEASE FILL IN REQUIRED FIELDS'; exit; }
      $email_content .= $value.': '.$_POST[$value]."\n";
    if(@mail($your_email,$email_subject,$email_content)) {
      echo 'Message sent!';
    } else {
      echo 'ERROR!';
    ?>

    Thanks. I'm working with different hosts and I guess thats where the confusion for me is coming in. In bluehost, I simply submit my form through form action to http://www.bluehost/bluemail. With the php form construction it 's form action is contact.php. Does this mean that the server I'm working with will uinderstand how to process contact.php and where to send it based on paramaters previously submitted? Or do I instruct the server via the php form? Thanks again
    Date: Wed, 8 Feb 2012 13:50:11 -0700
    From: [email protected]
    To: [email protected]
    Subject: Newbie for the life of me can't figure out where in contact.php you tell it where to send form?
        Re: Newbie for the life of me can't figure out where in contact.php you tell it where to send form?
        created by mhollis55 in Dreamweaver - View the full discussion
    The reason why this is done in php is because php is server-side scripting. It's telling your server to do stuff. HTML doesn't tell your server anything, it tells the client (the web browser loading it) to do things. Only your server can send an email.
         Replies to this message go to everyone subscribed to this thread, not directly to the person who posted the message. To post a reply, either reply to this email or visit the message page: http://forums.adobe.com/message/4194407#4194407
         To unsubscribe from this thread, please visit the message page at http://forums.adobe.com/message/4194407#4194407. In the Actions box on the right, click the Stop Email Notifications link.
         Start a new discussion in Dreamweaver by email or at Adobe Forums
      For more information about maintaining your forum email notifications please go to http://forums.adobe.com/message/2936746#2936746.

  • Newbie for load XML to oracle11g

    I'm a newbie for developer.
    Can anyone tell me? Can i load this xml file to oracle11g?
    Can i use sql loader? Or i should convert to other format first?
    the example of xml as below:
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE mdc SYSTEM "MeasDataCollection.dtd">
    -<mdc> -<mfh> <cbt>201207160500</cbt> </mfh> -<md> -<mi> <mts>201207160500</mts> <gp>60</gp> <mt>Average packet throughput in packets/s</mt> <mt>Downlink data forward success ratio</mt> <mt>Downlink dropped data packets with vip mamagement enabled</mt> <mt>Downlink ip address switch traffic in KB</mt> <mt>Downlink ip address switch traffic in MB</mt> <mt>Downlink ip address switch traffic in packets</mt> <mt>Dropped data packets of background class</mt> <mt>Dropped data packets of conversational class</mt> <mt>Dropped data packets of interactive class</mt> <mt>Dropped data packets of streaming class</mt> <mt>Dropped downlink packets with bwm</mt> <mt>Dropped downlink traffic in KB with bwm</mt> <mt>Dropped uplink packets with bwm</mt> <mt>Dropped uplink traffic in KB with bwm</mt> <mt>GGSN traffic in packets</mt> <mt>Gi downlink average throughput in MB/s</mt> <mt>Gi downlink average throughput in packets/s</mt> <mt>Gi downlink error L2TP packets</mt> <mt>Gi downlink L2TP packets</mt> <mt>Gi downlink L2TP packet in MB</mt> <mt>Gi downlink peak throughput in KB/s</mt> <mt>Gi downlink peak throughput in MB/s</mt> <mt>Gi downlink peak throughput in packets/s</mt> <mt>Gi downlink traffic in KB</mt> <mt>Gi downlink traffic in MB</mt> <mt>Gi downlink traffic in packets</mt> <mt>Gi IP data packets discarded for error</mt> <mt>Gi peak throughput in KB/s</mt> <mt>Gi peak throughput in MB/s</mt> <mt>Gi peak throughput in packets/s</mt> <mt>Gi traffic in KB</mt> <mt>Gi traffic in MB</mt> <mt>Gi traffic in packets</mt> <mt>Gi uplink average throughput in MB/s</mt> <mt>Gi uplink average throughput in packets/s</mt> <mt>Gi uplink L2TP packets</mt> <mt>Gi uplink L2TP packet in MB</mt> <mt>Gi uplink peak throughput in KB/s</mt> <mt>Gi uplink peak throughput in MB/s</mt> <mt>Gi uplink peak throughput in packets/s</mt> <mt>Gi uplink traffic in KB</mt> <mt>Gi uplink traffic in MB</mt> <mt>Gi uplink traffic in packets</mt> <mt>Gn downlink average throughput in MB/s</mt> <mt>Gn downlink average throughput in packets/s</mt> <mt>Gn downlink peak throughput in KB/s</mt> <mt>Gn downlink peak throughput in MB/s</mt> <mt>Gn downlink peak throughput in packets/s</mt> <mt>Gn downlink PPP packets</mt> <mt>Gn downlink PPP packet in MB</mt> <mt>Gn downlink traffic in KB</mt> <mt>Gn downlink traffic in MB</mt> <mt>Gn downlink traffic in packets</mt> <mt>Gn peak throughput in KB/s</mt> <mt>Gn peak throughput in MB/s</mt> <mt>Gn peak throughput in packets/s</mt> <mt>Gn traffic in KB</mt> <mt>Gn traffic in MB</mt> <mt>Gn traffic in packets</mt> <mt>Gn uplink average throughput in MB/s</mt> <mt>Gn uplink average throughput in packets/s</mt> <mt>Gn uplink error PPP packets</mt> <mt>Gn uplink peak throughput in KB/s</mt> <mt>Gn uplink peak throughput in MB/s</mt> <mt>Gn uplink peak throughput in packets/s</mt> <mt>Gn uplink PPP packets</mt> <mt>Gn uplink PPP packet in MB</mt> <mt>Gn uplink traffic in KB</mt> <mt>Gn uplink traffic in MB</mt> <mt>Gn uplink traffic in packets</mt> <mt>IPv6 Gi downlink peak throughput</mt> <mt>IPv6 Gi downlink peak throughput in packets/s</mt> <mt>IPv6 Gi downlink traffic</mt> <mt>IPv6 Gi downlink traffic in packets</mt> <mt>IPv6 Gi uplink peak throughput</mt> <mt>IPv6 Gi uplink peak throughput in packets/s</mt> <mt>IPv6 Gi uplink traffic</mt> <mt>IPv6 Gi uplink traffic in packets</mt> <mt>IPv6 Gn downlink peak throughput</mt> <mt>IPv6 Gn downlink peak throughput in packets/s</mt> <mt>IPv6 Gn downlink traffic</mt> <mt>IPv6 Gn downlink traffic in packets</mt> <mt>IPv6 Gn uplink peak throughput</mt> <mt>IPv6 Gn uplink peak throughput in packets/s</mt> <mt>IPv6 Gn uplink traffic</mt> <mt>IPv6 Gn uplink traffic in packets</mt> <mt>Number of packets with quintuple nodes exhausted</mt> <mt>One Tunnel downlink traffic in KB</mt> <mt>One Tunnel uplink traffic in KB</mt> <mt>Packets larger than 1500 bytes</mt> <mt>Peak packet throughput in packets/s</mt> <mt>Received gtp ip fragment flows</mt> <mt>Received ip fragment packets</mt> <mt>Received user ip fragment flows</mt> <mt>Successful reassemblies ip fragment packets</mt> <mt>Unexpected G-PDU messages</mt> <mt>Uplink data forward success ratio</mt> <mt>Uplink dropped data packets with vip mamagement enabled</mt> <mt>Uplink ip address switch traffic in KB</mt> <mt>Uplink ip address switch traffic in MB</mt> <mt>Uplink ip address switch traffic in packets</mt> -<mv> <moid>BFKT PBIHGG301/GGSN Function:BFKT PBIHGG301</moid> <r>883653</r> <r>99</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>453</r> <r>0</r> <r>1.64459e+06</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>3.18115e+09</r> <r>267</r> <r>256384</r> <r>0</r> <r>0</r> <r>0</r> <r>319197</r> <r>319</r> <r>300204</r> <r>9.61367e+08</r> <r>961369</r> <r>9.22983e+08</r> <r>1</r> <r>350403</r> <r>350</r> <r>517625</r> <r>1.06481e+09</r> <r>1.06481e+06</r> <r>1.58823e+09</r> <r>28</r> <r>184789</r> <r>0</r> <r>0</r> <r>34101</r> <r>34</r> <r>217184</r> <r>1.03443e+08</r> <r>103441</r> <r>6.65244e+08</r> <r>267</r> <r>256294</r> <r>319144</r> <r>319</r> <r>300114</r> <r>0</r> <r>0</r> <r>9.61262e+08</r> <r>961262</r> <r>9.22661e+08</r> <r>350585</r> <r>350</r> <r>518934</r> <r>1.06547e+09</r> <r>1.06547e+06</r> <r>1.59293e+09</r> <r>28</r> <r>186184</r> <r>0</r> <r>34310</r> <r>34</r> <r>218581</r> <r>0</r> <r>0</r> <r>1.04211e+08</r> <r>104212</r> <r>6.70265e+08</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>3.35844e+06</r> <r>0</r> <r>0</r> <r>0</r> <r>1.03656e+06</r> <r>7.71771e+06</r> <r>1.54354e+07</r> <r>3.15137e+06</r> <r>1.54354e+07</r> <r>760</r> <r>99</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <sf>false</sf> </mv> -<mv> <moid>BFKT MTGHGGSN01_NEW/GGSN Function:BFKT MTGHGGSN01_NEW</moid> <r>0</r> <r>100</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>12</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>3</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>6</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>3</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>3</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>6</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>3</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <r>100</r> <r>0</r> <r>0</r> <r>0</r> <r>0</r> <sf>false</sf> </mv> </mi> </md> -<mff> <ts>201207160600</ts> </mff> </mdc>

    What do you want to load, into what structure?
    Do you want to insert the data into a (or several) relational table(s)? Or do you want to insert the whole XML document into a database column?
    Give us more details, and the exact database version ("11g" is merely a product name, not a version).

  • Nested table updation in FOR Cursor loop

    Hello,
    I have nested table as follows:
    SQL> desc fp
    Name Null? Type
    ORDER_NUM NOT NULL VARCHAR2(10)
    ORDER_TIE_NUM NOT NULL VARCHAR2(10)
    FACILITY NOT NULL VARCHAR2(10)
    ON_SHORTS NUMBER(2)
    ACTIVE_SHORTS NUMBER(2)
    PARTS DPM_TRANSFORM_CODE.FP_SLC_SHORT
    FIRST_SHORT DATE
    LAST_SHORT DATE
    SQL> desc DPM_TRANSFORM_CODE.FP_SLC_SHort
    DPM_TRANSFORM_CODE.FP_SLC_SHort TABLE OF DPM_TRANSFORM_CODE.FP_SHORT_INFO
    Name Null? Type
    PART_NUM VARCHAR2(7)
    AREA VARCHAR2(7)
    PART_QTY NUMBER(3)
    ON_SHORT_CNT NUMBER(4)
    OFF_SHORT_CNT NUMBER(4)
    FIRST_DATE DATE
    LAST_DATE DATE
    UPDATE TABLE(SELECT PARTS FROM DPM_REPORTING.FP WHERE ORDER_NUM = P.ORDER_NUM AND ORDER_TIE_NUM = P.ORDER_TIE_NUM) PARTS
    SET PARTS.OFF_SHORT_CNT = PARTS.OFF_SHORT_CNT + 1
    WHERE PARTS.last_date < SYSDATE - 2/24;
    This Update Statement is in FOR Cursor Loop
    where select statement for the cursor is
    "SELECT ORDER_NUM,ORDER_TIE_NUM,PARTS FROM DPM_REPORTING.FP WHERE FACILITY = 'PN1'"
    This select statement generates 20000 records & due to which the Update statement gets executed that many times inside FOR loop.The Procedure has become quite slow due to this.
    Please help.
    Thanks,
    Rekha

    You could do it all in one sql update statement, without any pl/sql or cursor or looping:
    UPDATE fp t1
    SET    t1.parts =
           CAST (MULTISET (SELECT part_num, area, part_qty, on_short_cnt,  
                                  CASE WHEN last_date < SYSDATE - 2/24
                                       THEN off_short_cnt + 1
                                       ELSE off_short_cnt
                                  END,  
                                  first_date, last_date
                           FROM   TABLE (SELECT parts
                                         FROM   fp
                                         WHERE  facility = 'PN1'
                                         AND    order_num = t1.order_num
                                         AND    order_tie_num = t1.order_tie_num))    
                 AS fp_slc_short)
    WHERE  t1.facility = 'PN1'
    /

  • Is IN OUT for Cursor variable mandatory?

    Hi all:
    I have a stored procedure which will just return a boolean value after the task is done. And i'm using more than 1 cursor variables in that stored procedure. What my question is
    "Is IN OUT for Cursor variable mandatory from the PROCEDURE i have written?".
    Because in the manual they mentioned that IN OUT should be there for a cursor variable. My PROCEDURE declaration is as below:
    TYPE emp_det IS REF CURSOR;
    PROCEDURE <proc_name>(startdate VARCHAR2, enddate VARCHAR2, ids VARCHAR2, taskdone OUT BOOLEAN,emp IN OUT emp_det);
    Is there any modification in the above declaration if i'm using one cursor and NOT returning that cursor back to the called program. I don't to get returned.
    Hope i made it clear.
    Thanks,
    - Venu

    Venu:
    As far as I know you don't need In Out unless
    you are using that variable to pass values between the two procedures.
    It is so easy to try it , so I suggest you write two small procedures to check this.It should only take a couple of minutes.
    Hope this helps.

  • Nested FOR cursor and now results

    Hi Guys,
    I have a simple nexted FOR cursor but the second cursor does not retrieve
    anything at all. The first cursor retrieves values from a-z in low caps letters.
    If I replace in cursor 2 the clause
    SUBSTR(key#,1,1) = SUBSTR(key_rec1.key#,1,1);
    with
    SUBSTR(key#,1,1) = 'a'
    It works fine, if I leave it without my manuall fix it does not retrieve
    any rows. Anyone an idea? I use Oracle 11g.
    DECLARE
    CURSOR c1 IS
    SELECT DISTINCT(SUBSTR(key#,1,1)) AS key# FROM mytable;
    key_rec1 c1%rowtype;
    CURSOR c2 IS
    SELECT key#,
    FROM mytable
    WHERE
    *SUBSTR(key#,1,1) = SUBSTR(key_rec1.key#,1,1); --key_rec1.key#;*
    key_rec2 c2%rowtype;
    BEGIN
    FOR key_rec1 in c1
    LOOP
    FOR key_rec2 in c2
    LOOP
    INSERT INTO mytable2
    key#
    *          SELECT key#*
    *          FROM mybookingtab bsch*
    *          where bsch.key# = key_rec2.key#*
    END LOOP; -- c2
    *END LOOP; --c1*
    END;
    */*

    One should think you'd have learned how to use tags withing 400+ posts...
    not tested:{code}declare
    CURSOR c1 IS
    SELECT DISTINCT (SUBSTR (key#
                           ,  1
                           ,  1
                      AS key#
      FROM mytable;
    -- key_rec1 c1%ROWTYPE; -- needing this should have triggered some thinking...
    CURSOR c2 (p_key_rec1 c1%ROWTYPE)IS -- declare a parameter
    SELECT key#,
    FROM mytable WHERE SUBSTR(key#,1,1) = SUBSTR(p_key_rec1.key#,1,1);  --key_rec1.key#;
    --key_rec2 c2%ROWTYPE;
    BEGIN
      FOR key_rec1 IN c1 LOOP
        FOR key_rec2 IN c2(key_rec1) LOOP -- pass the outer loops current row
          INSERT INTO mytable2 (key#)* (*
    * SELECT key#*
    * FROM mybookingtab bsch*
    * where bsch.key# = key_rec2.key#*
    END LOOP; -- c2
    END LOOP; --c1
    END;
    /{code}
    bye
    TPD                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help in FOr cursor -

    hi all,
    The follwoing is my req - Below the written proc - can anyone check it is correct .
    1.     Write a procedure to compute the following using FOR cursor. Procedure should take 3 parameters. Empno - IN parameter, Empno IN parameter and this can be a default parameter. The OUT parameter should return the total cost to the company.
    DA = 15% of sal
    HRA = 20% of sal
    TA = 8% of sal
    Special Allowance will be decided based on the service in the company
    < 1 year                Nil
    1 year and < 2 years      10% of salSrividhya Maha...     >2 years and < 4 years      15% of sal
    5 years           20% of salcreate or replace procedure testing(p_empno in number default 10,v_cost out number)
    as
    v_salary number;
    v_months number;
    cursor mycur is
      SELECT salary from emp where empno = p_empno;
    begin
    for emp_rec in mycur
    LOOP
    SELECT round(months_between(sysdate,hire_date))into v_months from emp
      WHERE empno= p_empno;
    IF v_months < 12 then
    v_salary := salary *12;
    elsif
    v_months >12 and v_months <24
    v_salary := salary *12;
    dbms_output.put_line('employee salary'||15/100*salary+20/100*salary+
                                       8/100*salary +v_salary);
    end if;
    end loop;
    end;
    [\pre]
    cheers                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

    1) consider using FUNCTION to return the cost result, rather than an out parameter; that would allow you to call it in SQL (for example in an UPDATE)
    2) Your requirement says THREE parameters - but one of them is EMPNO (twice)
    3) Why allow default of EMPNO to 10?
    4) You have used ROUND - that means 11.6 months is treated as 1 year. You should use FLOOR instead (or jus compare real numbers)
    5) Your requriement leaves out 4-5 years service entirely - was that intentional?
    6) The whole section is incorrect:
    - refer to cursor variables using the record name, eg:
    v_salary := emp_rec.salary * 12;
    - You have assigned to local variable v_salary, but not to OUT variable v_cost.
    - your DBMS_OUTPUT.PUT_LINE gives you salary * (0.15+0.2+0.08) = 0.43*salary - why?
    7) You could put the whole thing into a single piece of SQL
    SELECT case
                  when months_between(sysdate,hire_date) < 12.0 then null
                  when months_between(sysdate,hire_date) < 24.0 then 0.10
                  when months_between(sysdate,hire_date) < 48.0 then 0.15
                  when months_between(sysdate,hire_date) >= 60.0 then 0.20
                 else null
                 end * salary  "Allowance"
    from   emp
    where {your where clause}
    /(multiply by 12 if salary is monthly and you need annual allowance).
    HTH
    Regards Nigel

  • LV7: how to catch 'Value change' event for cursor position in XY graph?

    I try to catch an event when the cursor position of a graph's cursor
    changes. I created a reference for the cursor array and registered a dynamic
    event 'Value change' for it. The event does not fire when the cursor changes
    (either by dragging it with the mouse or by direct entry of a new value in
    the cursor's X or Y fields. In contrast, when I register e.g. the 'Mouse Up'
    event for the cursor array, the event IS detected.
    -Franz

    So this is the same behaviour as that of a regular control which also does
    not fire a 'Value changed' event when it gets updated by e.g. writing to a
    local.
    At least the cursor's behavior is consistent then...
    But unfortunately also the direct user interaction with the cursor's numeric
    field does not fire the event, which is NOT consistent.
    I was trying to catch cursor changes in my event loop and had used a 'Mouse
    Up' event of the graph indicator to look for cursor changes (whose last
    position I had kept in a local or shift reg). In order not to miss a direct
    user interaction in the numeric field I added the dynamic event 'Value
    change' to the same event case, but with no success, it missed the direct
    entry ...
    according to what you say this seems to b
    e a bug then...
    -Franz
    "Greg McKaskle" schrieb im Newsbeitrag
    news:[email protected]..
    > > I try to catch an event when the cursor position of a graph's cursor
    > > changes. I created a reference for the cursor array and registered a
    dynamic
    > > event 'Value change' for it. The event does not fire when the cursor
    changes
    > > (either by dragging it with the mouse or by direct entry of a new value
    in
    > > the cursor's X or Y fields. In contrast, when I register e.g. the 'Mouse
    Up'
    > > event for the cursor array, the event IS detected.
    > >
    >
    > The reason is that value change events fire when user action directly on
    > the control changes its value. They do not fire when other programmatic
    > value changes occur. If you are looking at a value change on the cursor
    > palette, user interaction with the numeric should fire it, but updates
    > due to cursor movement are more like programmatic updates.
    >
    > Additional events will likely be added in future
    releases, and these may
    > make it easier to catch cursor movement events on a graph.
    >
    > Greg McKaskle
    >

  • UA support for cursor properties

    I would like a unique style for links to the articles section
    of a site and
    I was wondering if I could try a small image and if FF and IE
    would support
    that and if not, just default to the pointer image.
    I can't get them to accept an image (may have styled it
    incorrectly) - is
    there a list somewhere of browser support for cursor
    properties?
    I suppose I could use a bg image or colour, etc on the hover,
    but kinda
    liked using a small icon for the cursor instead.
    Cheers,
    Lossed
    __when the only tool you have is a hammer, everything looks
    like a nail __

    tks Gary,
    Well, here goes:
    FF seems to accept many file types, including .png, .cur, and
    regular image
    filetypes, but NOT .ani.
    IE seems to accept only .cur or .ani.
    If I make a 16 x 16 cursor, FF displays it as such.
    IE blows it up to 32 x 32 (so I need to make it 32 x 32 and
    have more
    transparent area).
    FF resolves the path as per normal - relative to the position
    of the css
    file in the file heiracy.
    IE doesn't! It seems to resolve the relative path to the
    cursor image as it
    it's relative to the document the css is imported into, not
    relative to the
    css file itself.
    That is why my cursor files weren't showing in IE - when I
    change the path
    to root relative or absolute, IE shows the cursor. Just why
    it does this for
    cursor images and (thank goodness) no other images called
    from within the
    css file, I have no idea.
    And all this for just IE and FF on PC.
    How other UA's and platforms treat cursor images is unclear.
    "Gary White" <[email protected]> wrote in message
    news:[email protected]..
    > On Thu, 24 Aug 2006 13:53:00 +1200, "Lossed"
    <[email protected]>
    > wrote:
    >
    >>I can't get IE to show any image regardless of format
    >>Must be doing something wrong somewhere I suppose.
    >>I used Axialis AX-Cursor to create the images as .cur
    and .ani, but
    >>neither
    >>show in IE, while the .cur shows in FF OK.
    >
    >
    > No time to test right now, but try using one of the .cur
    files from your
    > Windows\Cursors directory, so you know the problem isn't
    with the file.
    > Just copy one of the .cur files to your site.
    >
    > Gary

  • Better pereform for cursors

    Hi everyone
    I'm new in DataBases with Java and I have a question. In my database, I have two tables that have a relationship one-to-many. That is, a person could have many telephone numbers. On the GUI application, one person's register is shown at time. The user can navigate forward and backward through buttons so that the registers are changed on the window. For each person, his phone numbers are also shown. When the cursor is positioning in a person row, the program has to perform a Select statement to search its telephones in the other table. So, everytime the cursor changes in the person table, I have to perform the Select. Is there a better way? I think mine is very expensive...
    Thanks a lot

    Sorry, "Better PERFORM for cursors"

  • For Cursor

    Hi Team, Can i user exist when cursor will using For Cursor .if possible PLS let me know example.

    ---Brodyaga--- wrote:
    But you can't write
    begin
      for x in (select *
                from scott.emp) loop
        dbms_output.put_line(sql%rowcount);
      end loop;
    end;
    Well you can... but it won't show much...
    SQL> set serverout on
    SQL> ed
    Wrote file afiedt.buf
      1  begin
      2    for x in (select *
      3              from emp)
      4    loop
      5      dbms_output.put_line(sql%rowcount);
      6    end loop;
      7* end;
    SQL> /
    PL/SQL procedure successfully completed.

  • Nested FOR cursor LOOPs, BASIC QUESTION

    Hello,
    I am trying to nest a For-loop using a cursor (see below), but the program is not entering the second (nested) for-loop. This program compiles fine, but during run-time, the nested loop does not execute. I'd rather not use FETCH statements and keep everything in place. I think the solution is rather trivial, but I'm new to PL/SQL. PLEASE HELP!!!!!
    cursor c1 is
    select coi_con_uid,coi_not_code,coi_closed_yn,coi_timestamp
    from s_coi_con_issue
    where coi_not_code = 'NOT107'
    and coi_timestamp <= v_aweekago
    and coi_closed_yn = 'N';
    cursor c2 is
         select tsk_uid
         from s_tsk_task
         where tsk_status in ('C')
         and tsk_tty_code = 'CONTAC'
         and tsk_date_end = '' FOR UPDATE;     
    BEGIN
    select to_date(sysdate - 7) into v_aweekago from dual;
    DBMS_OUTPUT.PUT_LINE('System date used is ' || v_aweekago);
    FOR coi_row in c1 LOOP
    v_tsk_cnt := 0;
    v_coi_row_cnt := v_coi_row_cnt + 1;
    v_con_uid := rtrim(to_char(coi_row.coi_con_uid));
    v_tsk_act_str := ('"CON_UID","' || v_con_uid || '"') ;
    DBMS_OUTPUT.PUT_LINE('COI_CON_UID: ' || v_con_uid);
    DBMS_OUTPUT.PUT_LINE('v_tsk_act_str: ' || v_tsk_act_str);
    -----The Program is not entering into this Loop
              FOR tsk_row in c2 LOOP
              v_update_cnt := v_update_cnt + 1;
                   update s_tsk_task
                   set tsk_status = 'A'
                   where tsk_uid = tsk_row.tsk_uid and
                   tsk_action_string = v_tsk_act_str;     
                   DBMS_OUTPUT.PUT_LINE('----Task updated');                         
              END LOOP;
    END LOOP;
    COMMIT;

    using your query on your cursor c2 when you execute it on sql*plus did it return any rows?
      select tsk_uid
        from s_tsk_task
       where tsk_status in ('C')
         and tsk_tty_code = 'CONTAC'
         and tsk_date_end = ''; if not it might have something to do with the predicates in your where clause
         and tsk_date_end = '';consider revising your c2 cursor select statement to something like:
    cursor c2 is
      select tsk_uid
        from s_tsk_task
       where tsk_status   = 'C'
         and tsk_tty_code = 'CONTAC'
         and tsk_date_end IS NULL
      FOR UPDATE;

Maybe you are looking for

  • APP (f110 ) for customers

    Can we process the APP  (f110 ) even for customers. If yes how can we and in which situation. Kindly answer me...... Regards, Afreen.

  • "created by" in SAP transactions and CE BPM

    Dear all, In most of the transaction e.g. create Purchase Order - "created by" is field available in BAPI. In case of Investment approval processes "created by" is popultaed by the ID assigned to logical destination "BASIC" authorisation. How is this

  • Web module: exporting keywords to a template not possible?

    I want to use the web module to generate my photoblog, however I need to be able to export the keywords or collections used to tag each image. The dialog box for changing the image caption allows you to export all sorts of EXIF and IPTC metadata but

  • Java.lang.NoClassDefFoundError: org/w3c/dom/xpath/XPathEvaluator

    here is the tiresome problem, which has puzzled me for 5 days. 2008-7-11 15:58:03 org.apache.catalina.core.StandardWrapperValve invoke ����: Servlet.service() for servlet MapRequest threw exception java.lang.NoClassDefFoundError: org/w3c/dom/xpath/XP

  • Avoid labview initial window to show up when running a sequence

    Hi, I'm running a testand sequence that calls labview Vi's (not exe not dll) and right when it starts running the main start labview window shows up right in front of testand. I mean the window that appears when you open labview. How can I avoid this