Help on Cursors

Hi,
I am having the following cursor, which returns 10000 rows.
Cursor c1 is
select * from emp;
I have the following query on the above cursor.
1) Is there any way by which I can directly go to the 1000th row.
2) Since the above cursor has an Emp_Name column, is there any way by which I can directly go to the row having an Emp_Name='Whatever'.
Thanking you in advance for your kind help.
MAK

for the second point you can simple add the where condition in the cursor query, like:
CURSOR c1 IS
SELECT * FROM emp WHERE emp_name = 'Whatever';
if your value is static you can do it this way, else you can write a parameterized cursor as follows:
CURSOR c1(pEmpName VARCHAR2) IS
SELECT * FROM emp WHERE emp_name = pEmpName;
and then open the cursor like this:
OPEN c1('Whatever');
for the first point, going directly to 1000th row, as far as i know, you have to navigate thru the loop.

Similar Messages

  • Insert record from one table to another with help of cursor

    Plz help!!!
    tables are - 1. country( country_id pk, country_name, region_id)
    2. a( country_id , country_name, region_id)
    table a data are
    1 a 1
    2 b 2
    3 c 3
    null d 4
    5 e 5
    6 f 6
    7 g 7
    insert record from table a to country table with help of cursor, insert all not null records.
    this procedure does not give correct result
    create or replace
    procedure amit as
    cursor c1 is select * from a;
    rw a%rowtype;
    begin
    open c1;
    fetch c1 into rw;
    while(c1%found)
    loop
    insert into countries values(rw.country_id,rw.country_name,rw.region_id);
    commit;
    fetch c1 into rw;
    if rw.country_id is null then
    fetch c1 into rw;
    end if;
    end loop;
    close c1;
    exception
    when others then
    dbms_output.put_line('exception name= '||rw.country_name);
    end;

    bluefrog wrote:
    You don't need cursor at all;
    create or replace procedure amit as
    begin
    insert into countries (Country_ID, Country_Name, Region_ID)
    (select a.Country_ID
    ,a.Country_Name
    ,a.Region_ID
    from a
    dbms_output.put_line('Rows inserted : ' || sql%rowcount);
    commit;
    end;
    Bluefrog you missed where clause. :)
       insert into countries (Country_ID, Country_Name, Region_ID)
       (select a.Country_ID
              ,a.Country_Name
              ,a.Region_ID
        from a
        where country_id is not null
    );

  • Need help with cursor selection in control panels

    I can't get my cursor to work in the control panel at the top of the screen, for example, when I select text and want to change the font size, etc.  It won't even select to change from font to paragraph mode.  Other issues are trying to choose the selection tool, which I can only do with the "V" shortcut tool--escape doesn't work, nor does the cursor choose the  icons.  Help!

    Windows? see InDesign tools and panels don't respond to mouse clicks (Windows 7/Vista)

  • Help please - Cursor not working whilst browsing internet

    Hi
    Not long had my Curve 8520 and afraid I'm a bit of a techno dinosaur so please bear with me ! Wonder if someone can help with this.
    Whilst browsing the internet my "cursor" has suddenly stopped working. My "cursor" - the little black arrow - is still there but when hover over a search box for example and "click" my trackball nothing happens, similarly if the little hand symbol appears on a link if I "click" the trackball nothing happens. I've discovered I can press return when the hand appears and it goes to the link, but this is no use when only the arrow appears.
    Any help greatfully received
    Ken
    Solved!
    Go to Solution.

    Its the sort of thing that could possibly be fixed by a battery pull.
    With the BB powered on, remove the battery and keep it out for a couple of minutes. Let us know how you get on.
    Blackberry Best Advice - Back-up weekly
    If I have helped you please check the "Kudos" star on the right >>>>

  • Need help in cursor.....!

    hi,
    I am working in oracle 8i. I am creating cursor in my pl/sql block for the following requirement.
    I need to update the ex_duty_cb amt and simultaneously i need to assign the ex_duty_cb amt
    for the opening_amt column.
    For ex..
    Below is the actual record
    ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
    1626 2000 50 2200
    1627 3000 250 3300
    1628 4000 200 4400
    1629 5000 100 5500
    This is my requirement
    ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
    1626 2000 50 2050
    1627 2050 250 2300
    1628 2300 200 2500
    1629 2500 100 2600
    Please help me.........!
    Below is the query....Please guide me....?
    declare
    cursor cur
    is select entry_no,excise_duty_ob + cess_on_ed_ob + hecess_on_ed_ob as
    opening_amt, excise_duty_cb
    from cenvat_trans
    where transaction_type = 'I'
    and to_date(to_char(bill_date,'MON'),'MON') = '01-jul-2007';
    begin
    open cur;
    for fr in cur loop
    update cenvat_trans
    set excise_duty_cb = fr.opening_amt;
    exit when cur%notfound;
    end loop;
    close cur;
    end;
    regards,
    jame

    SQL> select * from cenvat_trans;
      ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
          1626        2000          50           2200
          1627        3000         250           3300
          1628        4000         200           4400
          1629        5000         100           5500
    SQL> merge into cenvat_trans c
      2  using (select entry_no,
      3         first_value(opening_amt) over(order by entry_no)+
      4         sum(prev_ex) over(order by entry_no) sm1,
      5         first_value(opening_amt) over(order by entry_no)+
      6         sum(excise_duty) over(order by entry_no) sm2
      7         from(
      8          select rowid,entry_no,opening_amt,
      9            excise_duty,excise_duty_cb,
    10            lag(excise_duty,1,0) over(order by entry_no) prev_ex
    11          from cenvat_trans)) v
    12  on (c.entry_no=v.entry_no)
    13  when matched then
    14  update set c.opening_amt = v.sm1,
    15      c.excise_duty_cb = v.sm2;
    4 rows merged.
    SQL> select * from cenvat_trans;
      ENTRY_NO OPENING_AMT EXCISE_DUTY EXCISE_DUTY_CB
          1626        2000          50           2050
          1627        2050         250           2300
          1628        2300         200           2500
          1629        2500         100           2600
    Message was edited by:
            jeneesh
    Oh..!
    Its too late..                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • HELP w/ Cursor

    Currently we have the following function:
    function GET_main_PHONE (
    p_person_id number) return varchar2 is
    l_per_address_phone varchar2(60);
    l_per_phones_phone varchar2(60);
    cursor csr_phones1 is
    select max(phone_number)
    from per_phones phn,
    fnd_sessions f
    where phn.parent_id = p_person_id
    and phn.parent_table = 'PER_ALL_PEOPLE_F'
    and phn.phone_type in ('H1', 'M')
    and f.effective_date between phn.date_from and
    nvl(phn.date_to,f.effective_date)
    and f.session_id = userenv ('sessionid');
    cursor csr_phones2 is
    select telephone_number_1
    from per_addresses adr,
    fnd_sessions f
    where adr.person_id = p_person_id
    and adr.primary_flag = 'Y'
    and f.effective_date between adr.date_from and
    nvl(adr.date_to,f.effective_date)
    and f.session_id = userenv ('sessionid');
    begin
    open csr_phones1;
    fetch csr_phones1 into l_per_phones_phone;
    close csr_phones1;
    if l_per_phones_phone is not null then
    return l_per_phones_phone;
    else
    open csr_phones2;
    fetch csr_phones2 into l_per_address_phone;
    close csr_phones2;
    return l_per_address_phone;
    end if;
    end get_main_phone;
    this works to pull back the most recent number for the emp record..but I need to ALWAYS pull back the Home number if it is there and I don't know how to do it. I tried to use an if statement w/in the cursor but that didn't work.
    Thanks for ANY help!
    Rob

    Hi,
    Try this (not tested):
    FUNCTION GET_main_PHONE(p_person_id NUMBER) RETURN VARCHAR2 IS
        l_per_address_phone VARCHAR2(60);
        l_per_phones_phone  VARCHAR2(60);
        l_phones            VARCHAR2(121);
        CURSOR csr_phones1 IS
            SELECT MAX(phone_number)
            FROM   per_phones   phn,
                   fnd_sessions f
            WHERE  phn.parent_id = p_person_id
            AND    phn.parent_table = 'PER_ALL_PEOPLE_F'
            AND    phn.phone_type IN ('H1', 'M')
            AND    f.effective_date BETWEEN phn.date_from AND NVL(phn.date_to, f.effective_date)
            AND    f.session_id = USERENV('sessionid');
        CURSOR csr_phones2 IS
            SELECT telephone_number_1
            FROM   per_addresses adr,
                   fnd_sessions  f
            WHERE  adr.person_id = p_person_id
            AND    adr.primary_flag = 'Y'
            AND    f.effective_date BETWEEN adr.date_from AND NVL(adr.date_to, f.effective_date)
            AND    f.session_id = USERENV('sessionid');
    BEGIN
        OPEN csr_phones1;
        FETCH csr_phones1
            INTO l_per_phones_phone;
        CLOSE csr_phones1;
        OPEN csr_phones2;
        FETCH csr_phones2
            INTO l_per_address_phone;
        CLOSE csr_phones2;
        RETURN NVL(l_per_phones_phone, '') || '|' || NVL(l_per_address_phone,'');
    END get_main_phone;Tip: to post formatted code you must enclose it between {noformat}{noformat} tags (start and end tags are the same) :)
    Regards,                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Help in CURSOR when pass parameter for the IN

    Hi,
    Need some help I have CURSOR that takes a VARCHAR2 and NUMBER but when I run my Procedure it gives invalid number. Here is the CURSOR
    CURSOR get_count (p_list VARCHAR2, p_id NUMBER)
          IS
             SELECT COUNT (*) total_rows,
                    NVL
                       (SUM (CASE
                                WHEN UPPER (cdcode) = 'PASS'
                                   THEN 1
                                ELSE 0
                             END
                        0
                       ) tot_returned,
                      COUNT (*)
                    - NVL (SUM (CASE
                                   WHEN UPPER (cdcode) = 'PASS'
                                      THEN 1
                                   ELSE 0
                                END
                           0
                          ) diff
               FROM testtable
              WHERE plistcol IN (p_list)
                AND pidcol = p_id;
    plistcol is of datatype NUMBER
    In my procedure I am building a list to comma separated numbers that goes in p_list parameter of type VARCHAR2 to the cursor i.e.
    I have a for loop to build that list e.g.
    loop
    -- num is of datatype NUMBER
    p_list := p_list || num || ',';
    end loop
    IF (p_list IS NOT NULL)
    THEN
    p_list := SUBSTR (p_list, 1, LENGTH (p_list) - 1);
    END IF;here is how my p_list looks when i pass it on to the cursor
    *12,345,678*
    and here is how open the cursor
    OPEN get_count (p_list, 99999);
    and here is the error I get
    SQLERRM ORA-01722: invalid number
    Now when I hard *12,345,678* in my CURSOR SELECT it works fine, it's only when I pass this as parameter it fails. For example I hard code the values in my CURSOR select it works fine
    CURSOR get_count (p_list VARCHAR2, p_id NUMBER)
          IS
             SELECT COUNT (*) total_rows,
                    NVL
                       (SUM (CASE
                                WHEN UPPER (cdcode) = 'PASS'
                                   THEN 1
                                ELSE 0
                             END
                        0
                       ) tot_returned,
                      COUNT (*)
                    - NVL (SUM (CASE
                                   WHEN UPPER (cdcode) = 'PASS'
                                      THEN 1
                                   ELSE 0
                                END
                           0
                          ) diff
               FROM testtable
              WHERE plistcol IN (12,345,678) -- even '12','345','678' works when hardcoded
                AND pidcol = p_id;I even tried passing the values in the format *'12','345','678'* but still get the above error. So how can I pass the values to cursor IN clause.
    So wondering what might be the issue.
    Thanks

    Why this kind of coding needs to be avoid - here is one demonstration of one aspect ->
    satyaki>
    satyaki>select * from v$version;
    BANNER
    Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Prod
    PL/SQL Release 10.2.0.3.0 - Production
    CORE    10.2.0.3.0      Production
    TNS for 32-bit Windows: Version 10.2.0.3.0 - Production
    NLSRTL Version 10.2.0.3.0 - Production
    Elapsed: 00:00:00.22
    satyaki>
    satyaki>select * from emp;
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          9999 SATYAKI    SLS             7698 02-NOV-08      55000       3455         10
          7777 SOURAV     SLS                  14-SEP-08      45000       3400         10
          7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30
          7566 JONES      MANAGER         7839 02-APR-81       2975                    20
          7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30
          7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30
          7782 CLARK      MANAGER         7839 09-JUN-81       4450                    10
          7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20
          7839 KING       PRESIDENT            17-NOV-81       7000                    10
          7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30
          7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20
         EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO
          7900 JAMES      CLERK           7698 03-DEC-81        950                    30
          7902 FORD       ANALYST         7566 03-DEC-81       3000                    20
    13 rows selected.
    Elapsed: 00:00:01.90
    satyaki>
    --Your query works and here is the slightly modified version of your query
    satyaki>
    satyaki>
    satyaki>declare
      2  
      3   type t_ref_cursor is ref cursor;
      4   l_cursor t_ref_cursor;
      5   l_count number;
      6   l_list varchar2(1000) := '10,20';
      7   v_sql varchar2(1000);
      8  
      9  begin
    10  
    11  v_sql := '';
    12  v_sql := v_sql||'select count(*) as tot_count ';
    13  v_sql := v_sql||'from emp ';
    14  v_sql := v_sql||'where deptno in ('||l_list||')';
    15  
    16  open l_cursor for v_sql;
    17  loop
    18    fetch l_cursor into l_count;
    19    exit when l_cursor%notfound;
    20    dbms_output.put_line('count: '||l_count);
    21  end loop;
    22  close l_cursor;
    23  
    24  end;
    25  /
    count: 8
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.09
    satyaki>
    --Now, modifying the input i can sniff into the entire data
    satyaki>
    satyaki>declare
      2  
      3   type t_ref_cursor is ref cursor;
      4   l_cursor t_ref_cursor;
      5   l_count number;
      6   l_list varchar2(1000) := '10,20) or (1=1';
      7   v_sql varchar2(1000);
      8  
      9  begin
    10  
    11  v_sql := '';
    12  v_sql := v_sql||'select count(*) as tot_count ';
    13  v_sql := v_sql||'from emp ';
    14  v_sql := v_sql||'where deptno in ('||l_list||')';
    15  
    16  open l_cursor for v_sql;
    17  loop
    18    fetch l_cursor into l_count;
    19    exit when l_cursor%notfound;
    20    dbms_output.put_line('count: '||l_count);
    21  end loop;
    22  close l_cursor;
    23  
    24  end;
    25  /
    count: 13
    PL/SQL procedure successfully completed.
    Elapsed: 00:00:00.10
    satyaki>Got me?
    Regards.
    Satyaki De.

  • Urgent help in cursor for loop. PLS HELP HELP HEP

    suppose i got table_a, in table_a i've got abc_id and bcd_name. the data as below:
    abc_id bcd_name
    1 a
    1 b
    1 c
    1 d
    in stored procedure as the statement below, i can only select 1 record into a local variable:
    select bcd_name
    into l_bcd_name
    where abc_id = i_abc_id;
    how am i going to select all the records? i know it's going to use a cursor for-loop statement but i dont know how to use. any1 can help?
    Message was edited by:
    babyekc

    Hi,
    You can do like this.
    Just write the following code in ur Stored Procedure.
    CURSOR C1 IS SELECT ABC_ID, BCD_NAME FROM TABLE_A;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO TEMP_ABCID, TEMP_BCDNAME;
    EXIT WHEN C1%NOTFOUND;
    DBMS_OUTPUT.PUT_LINE('ABC ID is ' || TEMP_ABCID);
    DBMS_OUTPUT.PUT_LINE('BCD NAME is ' || TEMP_BCD_NAME);
    END LOOP;
    CLOSE C1;
    END;
    Before declaring the cursor, declare the variables TEMP_ABCID, TEMP_BCDNAME.
    Thanks.

  • Help with Cursors

    I have a problem with a Patient and a Vaccinations tables whereby I have to have set business rules:
    (a) No more than 2 vaccinations (action) are allowed per day
    (b) for patients over 85, no more than 1 vaccination (action) per day
    (c) vaccination date no earlier than 1st jan 2008
    (d) chlorea and typhoid vaccinations are not permitted on the same day.
    Code so far:
    CREATE OR REPLACE PROCEDURE vacc1 (pat_id in char, vis_vdate in date,
    vis_act in number, vac_vacc in char)
    AS
    patrow patient%rowtype;
    action_over exception;
    vdate_before_jan exception;
    PRAGMA EXCEPTION_INIT(action_over,-20000);
    PRAGMA EXCEPTION_INIT(vdate_before_jan,-20001);
    BEGIN
    SELECT * INTO patrow
    FROM patient WHERE pid = pat_id;
    DBMS_OUTPUT.PUT_LINE ('Patient Name is: ' || patrow.pname);
    DBMS_OUTPUT.PUT_LINE ('Patient's Adress: ' || trim(patrow.address));
    DBMS_OUTPUT.PUT_LINE ('attempting to insert');
    insert into vaccinations(pid,vdate,action,vaccinated)
    values(pat_id,vis_vdate,vis_act,vac_vacc);
    IF vis_act >2
    THEN
    DBMS_OUTPUT.PUT_LINE ('There are more than two vaccinations for this patient');
    RAISE action_over;
    END IF;
    IF vis_vdate < '01-jan-2008'
    THEN
    DBMS_OUTPUT.PUT_LINE ('Visit date is before 1st January 2008');
    RAISE vdate_before_jan;
    END IF;
    COMMIT;
    DBMS_OUTPUT.PUT_LINE ('INSERT SUCESSFUL');
    EXCEPTION
    WHEN no_data_found
    THEN
    DBMS_OUTPUT.PUT_LINE ('Patient not found with ID number suggested');
    ROLLBACK;
    WHEN action_over OR vdate_before_jan
    THEN
    ROLLBACK;
    WHEN OTHERS
    THEN
    DBMS_OUTPUT.PUT_LINE ('SQLCODE' || SQLCODE);
    DBMS_OUTPUT.PUT_LINE ('SQL Error Message' || SQLERRM);
    ROLLBACK;
    END;
    Please help, have to build on this existing code with a cursor/select and create a new table naming it NEW_V_RECORD with appropriate primary key etc.
    Thanks

    Hi,
    I would recommend coding your proc something like this:
    CREATE OR REPLACE PROCEDURE vacc1 (
       pat_id      IN   CHAR
    , vis_vdate   IN   DATE
    , vis_act     IN   NUMBER
    , vac_vacc    IN   CHAR) AS
       patrow                             patient%ROWTYPE;
       action_over                        EXCEPTION;
       vdate_before_jan                   EXCEPTION;
       patient_age_85_vac_limit           EXCEPTION;
    BEGIN
       -- Lock this patient's row in order to prevent concurrent inserts into vaccinations...
       SELECT     *
             INTO patrow
             FROM patient
            WHERE pid = pat_id
       FOR UPDATE;
       DBMS_OUTPUT.put_line ('Patient Name is: ' || patrow.pname);
       DBMS_OUTPUT.put_line ('Patient''s Adress: ' || TRIM (patrow.address));
       DBMS_OUTPUT.put_line ('attempting to insert');
       -- Check for invalid situations BEFORE inserting data...
       CASE
          WHEN vis_act > 2 THEN
             RAISE action_over;
          WHEN     patrow.patient_age >= 85 -- I guessed the field name here...
               AND vis_act > 1 THEN
             RAISE patient_age_85_vac_limit;
          WHEN vis_vdate < TO_DATE ('01-JAN-2008'
                                  , 'DD-MON-YYYY') THEN
             RAISE vdate_before_jan;
       END CASE;
       -- If we got this far - we can safely insert data...
       INSERT INTO vaccinations
                   (pid
                  , vdate
                  , action
                  , vaccinated)
            VALUES (pat_id
                  , vis_vdate
                  , vis_act
                  , vac_vacc);
    -- COMMIT; -- Move this to your client application - COMMIT'ing in PL/SQL procedures is usually bad transactional programming practice
    EXCEPTION
       -- No need for rollback statements here - it is automatic when raising errors...
       WHEN NO_DATA_FOUND THEN
          raise_application_error (-20000
                                 , 'Patient not found with ID number suggested');
       WHEN action_over THEN
          raise_application_error (-20001
                                 , 'There are more than two vaccinations for this patient');
       WHEN patient_age_85_vac_limit THEN
          raise_application_error (-20002
                                 , 'The patient is older than 85 and received more than one vaccination');
       WHEN vdate_before_jan THEN
          raise_application_error (-20005
                                 , 'Visit date is before 1st January 2008');
    END;
    /Notice that I lock the row via an "SELECT ... FOR UPDATE" - this is very important because you do NOT want two users inserting vaccination data for the same patient at the same time. Due to Oracle's read-concurrency feature (usually very handy) - you can really get burned if you do not serialize access to data. A primary key on vaccinations would take care of this too - but it is safer in my opinion to protect your PL/SQL as well. Read Tom Kyte's book "Effective Oracle by Design" - he goes over this issue in detail with an example room reservation system.
    Good luck!
    Message was edited by:
    PDaddy

  • Please help: Mouse cursor on MBP repeatedly freezing for a few seconds

    Hi all
    I bought a MBP last week, and today I started experiencing problems with the mouse cursor. No matter whether I'm using the trackpad or an external mouse (I've tried using both a wired Mighty Mouse and a wireless Logitech), when I'm moving the cursor it keeps freezing for a few seconds (perhaps less than a second), and then I "regain" control of it, only for it to freeze again after a short while.
    The only thing that I can think of that might have something to do with this is that I replaced the 2GB of Apple RAM with 4GB of OWC RAM a couple of days ago. Can this be the reason?
    Please help me, as this problem renders the computer impossible to use:(
    Thanks in advance
    Daniel
    PS: I'm running Mac OS 10.5.1 and I've got the Keyboard Freeze Update Installed.

    Hi.
    I have a similar problem, however I realized it is somehow related to weather the airport is on. If I turn it off, there are no freezes. It is weird, and I'm going to go with it to Apple.

  • Need help on cursors

    Hi,
    I am having issue with my cursor.
    My cursor declartion looks like below:
    Declare
    cursor c1 is
    select job_id,delayed_time
    from mail_test;
    Begin
    open c1;
    Loop
    Fetch c1 into m_job_id, m_delayed_time;
    IF c1%FOUND THEN
    --Exit when c1%NOTFOUND;
    dbms_output.put_line('hai');
    dbms_output.put_line(' Job '||m_job_id||' is delayed by '||m_delayed_time||' minutes, ');
    EXIT;
    END IF;
    END LOOP;
    close c1;
    End;
    In mail_test table only one row is there for job 1151, but the above code snippet is displaying 3 rows. Any problem with my looping because I want to display only one row.
    O/p
    hai
    Job 1151 is delayed by 184 minutes,
    hai
    Job 1151 is delayed by 184 minutes,
    hai
    Job 1151 is delayed by 184 minutes,
    Desired o/p:
    hai
    Job 1151 is delayed by 184 minutes,
    Please help me on this. Thanks

    I dont want to use any predicate for job_id bcoz I want to select all the records from that table.Strange, that sounds contradictionary: do you want to select all records or just one?
    Anyway:
    Your other options are changing the query to either:
    select distinct job_id
                   ,      delayed_time
                   from   mail_testor (dirty one)
    select job_id
                   ,      delayed_time
                   from   mail_test
                   where  rownum=1Or, if you just want the output once, but loop through all records, you can do something like:
    declare
      prev_id number;
    begin
      for rec in ( select job_id
                   ,      delayed_time
                   from   mail_test
      loop
        if prev_id != rec.job_id
        then
          dbms_output.put_line('hai');
          dbms_output.put_line(' Job '||rec.job_id||' is delayed by '||rec.delayed_time||' minutes ');
        end if;
        prev_id := rec.job_id;
      end loop;
    end; 

  • Help with cursor please. . And Syncing Video to Audio.

    Hello, and thanks for reading this. I'm starting with a small project to start learning Premier.
    I've taken about 25 second clips from some songs and mixed them into a 15 minute mix, I would like to incorperate live tour footage of him preforming the song in sync with the songs so that his mouth is moving at the same time and Hand and body movements and such. .
    I'm having a hard time doing this because unlike Adobe Audition when you select a part of the timeline and hit space to play, and then hit space again to pause it and can have the cursor jump back to where it was when you hit play the first time, in Premier when you hit pause it stops where you pause it, and i have to move the timeline, which is very hard to do when I'm zoomed in so far because I need to be presise.
    Is there a better way to do this, or any tips you can provide to help me?
    So far I've added markers to the beginning and end of each song, but it still needs about 3 secs of fine tuning which is proving to be hard when I have to keep zooming out and moving back.
    Thanks so much..

    These are both great help to me, While I would love to continue hearing more tips I do have a question to add which you may know the answer to.
    When using the trim tool   to make a video shorter or longer, because when setting the in and out points i can't make them exact until it's on the timeline, can you shorten or lenghthen it per frame, like when using the alt key to move the video, instead of dragging with the mouse?
    Thanks so much (:

  • Need help in Cursor exception

    Hi,
    I have a small code with implicit cursor to fetch rows from table unreadable_cards and then for each value fetched I lookup another table card_acnt for some values and update data in unreadable cards table. The code is as below
    declare
    v1 number;
    begin
    for v1 in (select engravedid from unreadable_cards where case_resolved=1)
    loop
    update unreadable_cards set serial_number = (select serial_number from card_account
    where ticketid = v1.engravedid)
    where engravedid = v1.engravedid;
    update unreadable_cards set case_resolved=2
    where case_resolved=1
    and serial_number is not null;
    end loop;
    exception
    when no_data_found then
    update unreadable_cards set case_resolved=22
    where ticketid = v1.engravedid;
    when too_many_rows then
    update unreadable_cards set case_resolved=23
    where ticketid = v1.engravedid;
    when others then
    update unreadable_cards set case_resolved=24
    where ticketid = v1.engravedid;
    end;
    Here I have problem writing values to the table as this error pops up for every reference to V1 in exception
    PLS-00487: Invalid reference to variable 'V1'
    I need to be able to raise all three exceptions within the loop so that v1 can be referenced and loop does not exit on encountering the exception and completes for every row fetched by cursor, so that I can track the status of each record on the basis of case_resolved value.
    Any help would be highly appreciated
    Thanks
    Saurabh

    Let me get that out of me.. I don't like your code
    First thing you need to know is, you are not going to hit NO_DATA_FOUND exception in a UPDATE statement. If a update did not modify any row it will not raise NO_DATA_FOUND exception. Check this out
    SQL> begin
      2    update emp set sal = sal+ 10 where 1=2;
      3  end;
      4  /
    PL/SQL procedure successfully completed.
    No exception there. So that is one thing you need to look at.
    Second thing I don't like the way you have used WHEN OTHERS exception. What are the exception you are looking at? You should not be having a when others without RAISE. It a bug in the code. You need to fix that.
    Assuming your logic behind assigning CASE_RESOLVED is like this.
    CASE_RESOLVED = 2   means you have found an exact match for your UNREADABLE_CARDS.ENGRAVEDID in CARD_ACCOUNT.TICKETID
    CASE_RESOLVED = 22 means you don't have a match for your UNREADABLE_CARDS.ENGRAVEDID in CARD_ACCOUNT.TICKETID
    CASE_RESOLVED = 23 means you have multiple match for your UNREADABLE_CARDS.ENGRAVEDID in CARD_ACCOUNT.TICKETID
    CASE_RESOLVED = 24 This does not make any sense. You need to drop this part.
    You can do this, You don't need all that PL/SQL. Just a simple SQL like this will do.
    merge into unreadable_cards x
    using (
            select a.engravedid
                 , max(b.serial_number) serial_number
                 , case when count(b.serial_number) = 1 then 2
                        when count(b.serial_number) = 0 then 22
                        when count(b.serial_number) > 1 then 23
                   end case_resolved
              from unreadable_cards a
              left
              join card_account b
                on a.engravedid = b.eticketid
             where a.case_resolved = 1
             group
                by a.engravedid
          ) y
       on (
            x.engravedid = y.engravedid
    when matched then
    update set x.serial_number = nvl(y.serial_number, x.serial_number)
              , x.case_resolved = y.case_resolved;
    Above is a untested code. But should work. If any minor error fix it and you should be good to go.

  • Help regarding cursor

    Dear Experts,
    I had requirement whenever user click on user input field. It should pop-up mesage.
    Like: in IW51 t-code,when user clicks on PO number,it should throw an pop-up message.
    I need help from you regarding cursor click action. whether it is possible to develop the logic in customer-exit or not?
    Please suggest me your solutions to solve the issue.
    Thanks in advance,
    Bharat.

    Why duplicate thread ??

  • Need help with cursor def

    Hi I have seen some where in the code
    .what I could not understand is
    1.what does the e with clause in this code will do? where it is used frequently and what is the advantage?
    2.the temp_holding is a table with only one column.So is it like we can use with caluse in the cursor with only one columned tables?
    3.why is the AS keyword used in this?
    4.If I want to write a select staement for a cursor like this and see what is the data contained in the cursor ,how to write it ?
    thanks in adavnce for your help..
    OPEN lv_refcur FOR
    WITH TEMP_HOLDINGS AS
    SELECT A1.VENDOR_INSTRUMENT_ID,A1.DATA_SOURCE_CD FROM FI_IDX_BENCHMARK_HOLDINGS A1, FI_IDX_BENCHMARK B1, FI_IDX_SOURCE C1
    WHERE
    A1.PRICING_DT = pv_in_dt AND A1.DATA_SOURCE_CD = pv_in_data_src_cd AND A1.INDEX_CD = B1.INDEX_CD
    AND B1.INDEX_CD = C1.INDEX_CD AND C1.DATA_SOURCE_CD = A1.DATA_SOURCE_CD AND B1.IS_PA_REQUIRED = 'Y'
    UNION
    SELECT A2.VENDOR_INSTRUMENT_ID,A2.DATA_SOURCE_CD FROM FI_IDX_FORWARD_HOLDINGS A2, FI_IDX_BENCHMARK B2, FI_IDX_SOURCE C2
    WHERE
    A2.PRICING_DT = pv_in_dt AND A2.DATA_SOURCE_CD = pv_in_data_src_cd AND A2.INDEX_CD = B2.INDEX_CD
    AND B2.INDEX_CD = C2.INDEX_CD AND C2.DATA_SOURCE_CD = A2.DATA_SOURCE_CD AND B2.IS_PA_REQUIRED = 'Y'
    -- MDR START MC IGAR Disclosure change
    UNION
    SELECT
    A1.VENDOR_INSTRUMENT_ID,
    A1.DATA_SOURCE_CD
    FROM
    FI_IDX_BENCHMARK_HOLDINGS A1,
    FI_IDX_BENCHMARK B1,
    FI_IDX_SOURCE C1,
    fi_group_member GM
    WHERE
    A1.PRICING_DT = pv_in_dt
    AND GM.group_cd = 'BCGLBIDXPA'
    AND GM.purpose_cd = 'GLOBALIDX'
    AND A1.DATA_SOURCE_CD = GM.character_val
    AND A1.INDEX_CD = B1.INDEX_CD
    AND B1.INDEX_CD = C1.INDEX_CD
    AND C1.DATA_SOURCE_CD = pv_in_data_src_cd
    AND B1.IS_PA_REQUIRED = 'N'
    UNION
    SELECT
    A2.VENDOR_INSTRUMENT_ID,
    A2.DATA_SOURCE_CD
    FROM
    FI_IDX_FORWARD_HOLDINGS A2,
    FI_IDX_BENCHMARK B2,
    FI_IDX_SOURCE C2,
    fi_group_member GM
    WHERE
    A2.PRICING_DT = pv_in_dt
    AND GM.group_cd = 'BCGLBIDXPA'
    AND GM.purpose_cd = 'GLOBALIDX'
    AND A2.DATA_SOURCE_CD = GM.character_val
    AND A2.INDEX_CD = B2.INDEX_CD
    AND B2.INDEX_CD = C2.INDEX_CD
    AND C2.DATA_SOURCE_CD = pv_in_data_src_cd
    AND B2.IS_PA_REQUIRED = 'N'
    -- MDR END
    SELECT
    INSTRUMENT_ID,
    FUND_OR_INDEX_CD,
    PRICING_DT,
    FI_INSTRUMENT_ID,
    ISSUE_DESCRIPTION,
    TICKER,
    ISSUE_DT,
    STATED_MATURITY_DT,
    COUPON,
    STATE_CD,
    COUNTRY_CD,
    CURRENCY_CD,
    CALLABLE_FLAG,
    PUTABLE_FLAG,
    INSURED_FLAG,
    AMT_CD,
    REVENUE_SOURCE_CD,
    ISSUER_ID,
    NON_2A7_DIVER_ISSUER_ID,
    BLOOMBERG_MBS_TYPE,
    MBS_AGENCY_CD,
    ORIGINAL_TERM,
    DS_CLASS1_CD,
    DS_CLASS2_CD,
    DS_CLASS3_CD,
    MAX(LB_CLASS1_CD) LB_CLASS1_CD,
    MAX(LB_CLASS2_CD) LB_CLASS2_CD,
    MAX(LB_CLASS3_CD) LB_CLASS3_CD,
    MAX(LB_CLASS4_CD) LB_CLASS4_CD,
    GENERIC_INSTRUMENT_ID,
    MAX(SC_CLASS1_CD) SC_CLASS1_CD,
    MAX(SC_CLASS2_CD) SC_CLASS2_CD,
    MAX(SC_CLASS3_CD) SC_CLASS3_CD,
    MAX(SC_CLASS4_CD) SC_CLASS4_CD
    FROM (
    SELECT
    DISTINCT
    PV_FND_IDX_CD AS FUND_OR_INDEX_CD,
    IAI.FI_INSTRUMENT_ID AS FI_INSTRUMENT_ID,
    -- MC IGAR Disclosure
    decode( pv_in_data_src_cd, 'LBG', decode (I.INSTRUMENT_DOMAIN_CD, 'MBS', I.cusip, IAI.ALTERNATE_ID), IAI.ALTERNATE_ID) AS INSTRUMENT_ID,
    -- MC IGAR Disclosure
    pv_in_dt AS PRICING_DT,
    I.ISSUE_DESC AS ISSUE_DESCRIPTION,
    I.BLOOMBERG_TICKER AS TICKER,
    DECODE(pv_in_data_src_cd,'LBG',I.ISSUE_DT,NULL) AS ISSUE_DT,
    I.STATED_MATURITY_DT AS STATED_MATURITY_DT,
    I.COUPON AS COUPON,
    I.STATE_CD AS STATE_CD,
    I.COUNTRY_CD AS COUNTRY_CD,
    I.CURRENCY_CD AS CURRENCY_CD,
    I.CALLABLE_IND AS CALLABLE_FLAG,
    I.PUTABLE_IND AS PUTABLE_FLAG,
    DECODE(pv_in_data_src_cd,'LBG',I.INSURED_IND,NULL) AS INSURED_FLAG,
    I.AMT_CD AS AMT_CD,
    I.REVENUE_SOURCE_CD AS REVENUE_SOURCE_CD,
    I.MASTER_ISSUER_ID AS ISSUER_ID,
    I.NON_2A7_DIVER_ISSUER_ID AS NON_2A7_DIVER_ISSUER_ID,
    MBS.BLOOMBERG_MBS_TYPE AS BLOOMBERG_MBS_TYPE,
    MBS.MBS_AGENCY_CD AS MBS_AGENCY_CD,
    MBS.ORIGINAL_TERM AS ORIGINAL_TERM,
    NULL AS DS_CLASS1_CD,
    NULL AS DS_CLASS2_CD,
    NULL AS DS_CLASS3_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'LBCC', S.CLASSIFICATION_LEVEL1_CD)
    AS LB_CLASS1_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'LBCC', S.CLASSIFICATION_LEVEL2_CD)
    AS LB_CLASS2_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'LBCC', S.CLASSIFICATION_LEVEL3_CD)
    AS LB_CLASS3_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'LBCC', S.CLASSIFICATION_LEVEL4_CD)
    AS LB_CLASS4_CD,
    NULL AS GENERIC_INSTRUMENT_ID,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'SCIS', S.CLASSIFICATION_LEVEL1_CD)
    AS SC_CLASS1_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'SCIS', S.CLASSIFICATION_LEVEL2_CD)
    AS SC_CLASS2_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'SCIS', S.CLASSIFICATION_LEVEL3_CD)
    AS SC_CLASS3_CD,
    DECODE (S.CLASSIFICATION_SCHEME_CD, 'SCIS', S.CLASSIFICATION_LEVEL4_CD)
    AS SC_CLASS4_CD
    FROM
    INSTRUMENT I,
    INSTRUMENT_SECTOR S,
    TEMP_HOLDINGS H,
    INSTRUMENT_ALTERNATE_ID IAI,
    INSTRUMENT_MBS MBS,
    FI_IDX_INSTRUMENT FII
    WHERE
    H.DATA_SOURCE_CD = FII.DATA_SOURCE_CD
    AND H.VENDOR_INSTRUMENT_ID = FII.VENDOR_INSTRUMENT_ID
    AND FII.FMR_CUSIP = IAI.ALTERNATE_ID
    AND IAI.FI_INSTRUMENT_ID = I.FI_INSTRUMENT_ID
    AND IAI.FI_INSTRUMENT_ID = S.FI_INSTRUMENT_ID(+)
    AND IAI.FI_INSTRUMENT_ID = MBS.FI_INSTRUMENT_ID(+)
    AND IAI.ALTERNATE_ID_TYPE_CODE = 'FMR_CUSIP'
    GROUP BY INSTRUMENT_ID, FUND_OR_INDEX_CD, PRICING_DT, FI_INSTRUMENT_ID,
    ISSUE_DESCRIPTION, TICKER, ISSUE_DT, STATED_MATURITY_DT, COUPON, STATE_CD,
    COUNTRY_CD, CURRENCY_CD, CALLABLE_FLAG, PUTABLE_FLAG, INSURED_FLAG, AMT_CD,
    REVENUE_SOURCE_CD, ISSUER_ID, NON_2A7_DIVER_ISSUER_ID, BLOOMBERG_MBS_TYPE,
    MBS_AGENCY_CD, ORIGINAL_TERM, DS_CLASS1_CD, DS_CLASS2_CD, DS_CLASS3_CD,
    GENERIC_INSTRUMENT_ID;
    Edited by: 953115 on Dec 5, 2012 2:04 AM

    953115 wrote:
    1.what does the e with clause in this code will do? where it is used frequently and what is the advantage?The WITH clause is called subquery factoring, not easy to find in the manual if you don't know that
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2161315
    http://docs.oracle.com/cd/E11882_01/server.112/e26088/statements_10002.htm#i2077142
    >
    subquery_factoring_clause
    The WITH query_name clause lets you assign a name to a subquery block. You can then reference the subquery block multiple places in the query by specifying query_name. Oracle Database optimizes the query by treating the query name as either an inline view or as a temporary table.
    >
    Simply, it is like creating a view local to the query that can be used one or more times in the rest of the query. It has added benefits such as the potential to materialize the results, explicitly push predicates into the subquery, and perform hierarchical queries using the recursive feature.
    >
    2.the temp_holding is a table with only one column.So is it like we can use with caluse in the cursor with only one columned tables?No you can put any query in the WITH clause
    >
    3.why is the AS keyword used in this?Developer preference? It is optional when specifying a column alias, it seems many of the aliases in your query are unnecessary since they just duplicate the existing column name.
    4.If I want to write a select staement for a cursor like this and see what is the data contained in the cursor ,how to write it ?You can view the results from the cursor the same way as any select query, e.g.
    SQL> var c refcursor
    SQL> begin
      2    open :c for
      3      with test_data as
      4      (
      5      select 1 n, 'a' s from dual union all
      6      select 2 n, 'b' s from dual union all
      7      select 5 n, 'x' s from dual
      8      )
      9      select n, s, case when n > 2 then 'High' else 'Low' end y
    10      from test_data;
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL> print c
             N S Y
             1 a Low
             2 b Low
             5 x High

Maybe you are looking for

  • Sales,Production and Stock in a single query

    Hi gurus, My scenario is this: I want to create a sales report i.e. productwise sales report with the key figures,sales quantity,production quantity and stock quantity.On a daily basis. can anyone guide me which are the cube and datasouce i need to u

  • Purpose of Data Template

    What is the purpose of Data Templates in BI Publisher? I understand their format, creating one, and uploading it into BI Publisher Enterprise, our current environment, but I am trying to see what value and power they provide. Is it the lexical refere

  • IPod won't sync all music to iTunes

    I recently got a new Macbook Pro and needed to transfer over all of my music on iTunes from my old laptop. My iPod Touch has enough space to hold my entire iTunes library, so I synced it with the iTunes library on my old laptop, got everything onto i

  • Cannot allocate memory error

    Hello, I am using: Oracle: Berkeley DB XML 2.5.16: (December 22, 2009) Berkeley DB 4.8.26: (December 18, 2009) When attempting to open a container in an environment where the application process has been running for a while I get the following error:

  • Why do I have to keep entering my itunes password on my ipad?

    Can anyone offer any suggestions on how to have my iTunes password stored so I don't have to keep entering it after I enter my passcode to begin doing anything?  To clarify, I have a passcode set up to begin after 15 minutes of inactivity.  Once that