Two Cursors in a procedure

I am working on procedure, Please give ideas where i can develop this logic more meaning and easy
the logic is as follows
Table1 is having same Id's ABC having same seq number 100 as per legacy data (This is wrong entry in legacy data)
ID     --    Seqnum
ABC --     100
ABC --     100
I created a table2 where it will have max seqnum from legacy for this ID's for example ABC
ID  -- Max seqnum
ABC --500
In my procedure I will have two cursors
First cursor will be have Table1 detail
Second Cursor will have Table2 Details
In above ex the table will have the first record should be unchanged i.e.,
ABC --     100 --100
but second record will change to
ABC --     100 -- 501(This next value of the max seq number from table 2/Cursor 2)
I have to create third column which will hold the next seqnumber for that ID ABC
I should load both records changing the seqnumber so I will not have any duplicate records for same ID.
So final records will look like
ID            Seq#       Final_Seq#
ABC --     100 --     100
ABC --     100 --      501
Thanks in advance.

Adjusted accordingly to the message above
with
data_tab as
(select 'ABC' id,100 seq from dual union all
select 'ABC',100 from dual union all
select 'ABC',100 from dual union all
select 'BCD',110 from dual union all
select 'CDE',120 from dual union all
select 'CDE',120 from dual union all
select 'DEF',130 from dual union all
select 'EFG',140 from dual union all
select 'EFG',140 from dual union all
select 'EFG',140 from dual union all
select 'EFG',240 from dual union all
select 'EFG',240 from dual union all
select 'FGH',150 from dual
max_nums as
(select 'ABC' id,200 max_num from dual union all
select 'BCD',300 from dual union all
select 'CDE',400 from dual union all
select 'DEF',500 from dual union all
-- select 'EFG',600 from dual union all
select 'FGH',700 from dual
select d.id,d.seq,row_number() over (partition by d.id,d.seq order by null) rn,m.max_num,
       case when row_number() over (partition by d.id,d.seq order by null) = 1
            then d.seq
            else nvl(m.max_num,d.seq) + row_number() over (partition by d.id,d.seq order by null) - 1
       end new_seq
  from data_tab d,
       max_nums m
where d.id = m.id(+)
ID
SEQ
RN
MAX_NUM
NEW_SEQ
ABC
100
1
200
100
ABC
100
2
200
201
ABC
100
3
200
202
BCD
110
1
300
110
CDE
120
1
400
120
CDE
120
2
400
401
DEF
130
1
500
130
EFG
140
1
140
EFG
140
2
141
EFG
140
3
142
EFG
240
1
240
EFG
240
2
241
FGH
150
1
700
150

Similar Messages

  • Two cursors in one procedure

    Hi All,
    Two cursors in the same procedure will slows down the execution ?. Please can any one suggest one this.

    I aggree with Sundar, you might be able to update this without using a cursor. My general understanding is to avoid using cursor as much as possible for performance reasons, if you are doing a lot of inserts/updates etc. If you are doing lot of updates and you must have to iterate through a loop due to some reason then try to use bulk processing (use bulk inserts, updates, one sql query to access data from database to avoid conext switching etc.).

  • Error while opening two cursors in same procedure...

    Hi :
    I have written following Procedure:
    Declare
    procedure pro_canefortnight_master Is
    kr_caneperiodid integer;
    last_caneperiod_id number(10,0);
    kr_forthnightid integer;
    last_forthnight_id number(10,0);
    ref_caneperiodid integer;
    ref_seasonyrid integer;
    ctr integer:= 1;
    CURSOR comp_cur IS select * from CMS_SEASON_YEAR_MASTER ;
    comp_rec comp_cur%ROWTYPE;
    BEGIN
    OPEN comp_cur;
    FETCH comp_cur INTO comp_rec;
    WHILE comp_cur%FOUND
    LOOP
    kr_caneperiodid:= comp_rec.SEASON_YR_ID;
    select max(crayom_db.cr_cane_calender.cr_cane_calender_ID) into last_caneperiod_id from crayom_db.cr_cane_calender;
    if last_caneperiod_id <> 0 then
    last_caneperiod_id:= last_caneperiod_id + 1;
    else
    last_caneperiod_id:= 1000000;
    end if;
    insert into crayom_db.CR_CANE_CALENDER(cr_cane_calender_ID,ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby,CR_CANE_CALENDER_NAME,DESCRIPTION) values(last_caneperiod_id,11,11,comp_rec.current_season,sysdate,100,sysdate,11,comp_rec.DESC_MA,comp_rec.DESC_EN);
    COMMIT;
    /*insert into crayom_db.CR_IdBackup(kr_cultivationtypeid,cr_cultivationtypeid) values(kr_cultivationtypeid, last_cultivationtype_id);*/
    insert into crayom_db.temp(kr_bpartnerid,cr_bpartnerid) values(comp_rec.season_yr_id,last_caneperiod_id);
    commit;
    FETCH comp_cur INTO comp_rec;
    End LOOP;
    close comp_cur;
    CURSOR comp_cur1 IS select * from CMS_FORTH_NIGHT_MASTER ;
    comp_rec1 comp_cur1%ROWTYPE;
    OPEN comp_cur1;
    FETCH comp_cur1 INTO comp_rec1;
    WHILE comp_cur1%FOUND
    LOOP
    kr_forthnightid:= comp_rec1.forthnight_id;
    select max(crayom_db.cr_cane_calender_period.cr_cane_calender_period_ID) into last_forthnight_id from crayom_db.cr_cane_calender_period;
    if last_forthnight_id <> 0 then
    last_forthnight_id:= last_forthnight_id + 1;
    else
    last_forthnight_id:= 1000000;
    end if;
    if ref_seasonyrid <> comp_rec1.season_yr_id then
    ref_seasonyrid:= comp_rec1.season_yr_id;
    else
    ctr:= ctr + 1;
    end if;
    SELECT cr_bpartnerid into ref_caneperiodid from crayom_db.temp where kr_bpartnerid = comp_rec1.season_yr_id;
    dbms_output.put_line(ref_caneperiodid);
    insert into crayom_db.CR_CANE_CALENDER_period(cr_cane_calender_period_ID,ad_client_id, ad_org_id, isactive, created, createdby, updated, updatedby,Enddate,name, startdate, cr_cane_calender_id) values(last_forthnight_id,11,11,comp_rec1.current_season,sysdate,100,sysdate,11,comp_rec1.end_date,'ForthNight' || ctr, comp_rec1.start_date,ref_caneperiodid);
    commit;
    FETCH comp_cur1 INTO comp_rec1;
    End LOOP;
    close comp_cur1;
    END;
    BEGIN
    pro_canefortnight_master();
    END;
    But I am getting following Error:
    Error report:
    ORA-06550: line 429, column 8:
    PLS-00103: Encountered the symbol "COMP_CUR1" when expecting one of the following:
    := . ( @ % ;
    ORA-06550: line 433, column 1:
    PLS-00103: Encountered the symbol "FETCH" when expecting one of the following:
    begin function package pragma procedure subtype type use
    <an identifier> <a double-quoted delimited-identifier> form
    current cursor
    The symbol "begi
    ORA-06550: line 472, column 1:
    PLS-00103: Encountered the symbol "BEGIN" when expecting one of the following:
    end not pragma final instantiable order overriding static
    member constructor map
    ORA-06550: line 477, column 4:
    PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following:
    end not pragma final instantiable order overriding static
    member constructor map
    06550. 00000 - "line %s, column %s:\n%s"
    *Cause: Usually a PL/SQL compilation error.
    *Action:
    Can any body help me?
    Thank You.
    Edited by: [email protected] on Oct 22, 2009 4:36 AM

    [email protected] wrote:
    CURSOR comp_cur1 IS select * from CMS_FORTH_NIGHT_MASTER ;
    comp_rec1 comp_cur1%ROWTYPE;This is probably the issue. All variable definitions, including cursors, must be in the DEFINE section of a procedure (between either DECLARE ... BEGIN or AS/IS ... BEGIN).
    In addition I wanted to note the following:
    1. When posting it is helpful to identify your Oracle version (e.g. 10.2.0.4).
    2. Any code that is posted should be placed between \ tags to improve readability.
    3. It looks like the code is doing "slow by slow" processing (a.k.a single record processing). It could probably be made much cleaner, maintainable and better performing by possibly using INSERT .. AS SELECT ... or something along those lines.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Two Cursor in Procedure

    I was trying to use two cursors in a procedure and while compiling in DBA Studio, I get the following error: "Line # = 19 Column # = 14 Error Text = PLS-00341: declaration of cursor 'RECORD_ID_CURSOR' is incomplete or malformed"
    Are you not supposed to have two cursors in a procedure? Please help. Thanks.
    Paul

    PLS-00341 declaration of cursor 'string' is incomplete or malformed
    this is the error you are getting. You can have 2 cursors but the way it's defined is incorrect. Check your spellings and the way it's defined.

  • Dynamic Cursor in a procedure

    Hi,
    I am using 10g and wanted to check if we can use a dynamic cursor in a procedure.
    Following is my code and wanted to see if that can work with every query passed as a parameter.
    example ,
    exec test1 ('select col1, col2, col3 from table1','Two columns Sql')
    exec test1 ('select col1 from table2','one columns Sql')
    exec test1 ('select col1, col2, col3, col4, col5 from table3','Five columns Sql')
    CREATE OR REPLACE procedure test1 (p_sql IN VARCHAR2, p_subject IN VARCHAR2
    is
      v_cu_string       VARCHAR2(2000);
      v_string          VARCHAR2(2000);
      v_sql             VARCHAR2(4000);
      v_head            VARCHAR2(4000);
      v_head_sql        VARCHAR2(4000);
      v_str_sql         VARCHAR2(4000);
          TYPE cv_typ IS REF CURSOR;
          cv cv_typ;
    begin
      v_sql := p_sql;
        OPEN cv FOR v_sql;
           LOOP
             FETCH cv INTO v_cu_string;
             EXIT WHEN cv%NOTFOUND;
            ------ Processing steps
          END LOOP;
          CLOSE cv;
    END;Thanks

    user527060 wrote:
    Following is my code and wanted to see if that can work with every query passed as a parameter.
    Just curious as to why this is an improvement of
    exec test1 ('select col1, col2, col3 from table1','Two columns Sql')
    select col1, col2, col3 from table1And
    exec test1 ('select col1 from table2','one columns Sql')
    select col1 from table2And
    exec test1 ('select col1, col2, col3, col4, col5 from table3','Five columns Sql')
    select col1, col2, col3, col4, col5 from table3It needs more code from you to build, more code for anyone to enter to execute, limits selects to only one table I would guess also comes with less documentation than SQL.
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/toc.htm

  • Can we define cursors from in procedure while using .procedure file?

    Hi Team,
    Can we define cursors from in procedure while using .procedure file?
    I have a catalog procedure in which am using cursors and it is working fine. But while trying to create the same procedure using .procedure , the validation is failing with "An error occurred while parsing your procedure".
    Request your suggestions.
    Regards,
    Krishna Tangudu

    Hi Krishna,
    I also tried to find the validation for procedure and failed. What was on my mind when I posted earlier was related to Window -> Properties -> SAP HANA -> Modeler -> Validation Rules but this is not the same for procedure.
    Also the validation error seems to not being raised by Studio but the server, so it's not a frontend validation anyway.
    Trying to replicate your error I create two procedures here and both worked fine with cursor.
    The behavior you found was the same I found, the .procedure goes to repository and _SYS_BIC after activation and .hdbprocedure goes to catalog only.
    As far as I understood as you are moving from catalog (manually) and it worked on catalog (.hdbprocedure), I could check the declaration of table types of header as it's the main difference.
    Despite this investigation of declaration, you can try create it on modeler direct and see what you found on .procedure created. This can speed up investigation.
    Regards, Fernando Da Rós
    BTW: I'm faced an very strange behavior that each caracter I type on .procedure or .hdbprocedure freezes studio by around 15 seconds ?!?!?!?! (studio rev73)

  • How to compare two cursors

    Hi all,
    I have two different cursors of same recors.
    create table temp_emp as select * from emp;
    cursor cr_emp IS
    select * from emp;
    cursor cr_tmp IS
    select * from temp_emp;
    how to compare these two cursors.
    Im trying to learn comparing cursors variables. I have oracle 11g, windows Vista.
    Initially, I tried to compare only ename coloum:
    create or replace procedure compare
    IS
    cursor cr_emp IS
    select * from emp;
    cursor cr_temp IS
    select * from temp_emp;
    v_cr_emp cr_emp%rowtype;
    v_cr_temp cr_temp%rowtype;
    emp_rownum integer;
    tmpy_rownum integer;
    V_CODE NUMBER;
    V_ERRM VARCHAR2(64);
    BEGIN
    select MAX(rownum) into emp_rownum from emp;
    select MAX(rownum) into tmpy_rownum from tmpy_emp;
    open cr_emp;
    open cr_temp;
    FETCH CR_EMP INTO v_cr_emp;
    FETCH CR_TEMP INTO v_cr_temp;
    for emp_rownum in cr_emp
    loop
    for tmpy_rownum in cr_tmpy
    loop
         if(v_cr_emp.ename = v_cr_temp.ename)
         then
         dbms_output.put_line('equal');
         else
         dbms_output.put_line( 'not equal');
         end if;
    end loop;
    end loop;
    EXCEPTION
    WHEN OTHERS
    THEN
    V_CODE := SQLCODE;
    V_ERRM := SUBSTR(SQLERRM,1,64);
    DBMS_OUTPUT.put_line ('ERROR CODE' || V_CODE || ':' || V_ERRM);
    close cr_emp;
    close cr_tmpy;
    END;
    SQL> start rain.sql
    Procedure created.
    SQL> exec compare
    ERROR CODE-6511:ORA-06511: PL/SQL: cursor already open
    PL/SQL procedure successfully completed.
    Edited by: user10676396 on Apr 16, 2009 7:50 PM

    Hi user10676396,
    Hope this helps you understand the Nested loop, which I assumed you are trying to do in you program.
    Note : Code not compiled and tested.
    create or replace procedure compare
    IS
    cursor cr_emp IS
    select * from emp;
    cursor cr_temp IS
    select * from temp_emp;
    v_cr_emp cr_emp%rowtype;
    v_cr_temp cr_temp%rowtype;
    emp_rownum integer;
    tmpy_rownum integer;
    V_CODE NUMBER;
    V_ERRM VARCHAR2(64);
    BEGIN
    select MAX(rownum) into emp_rownum from emp;
    select MAX(rownum) into tmpy_rownum from tmpy_emp;
    FOR REC IN cr_emp LOOP
         dbms_output.put_line('For Ename in EMP : '||REC.ename ');
    -- In FOR loops demo concept of nested loops
      FOR TREC in cr_temp LOOP
         if(REC.ename = TREC.ename)
         then -- only output when you found a record in Temp
         dbms_output.put_line('....EQUAL rec found in Temp : ' ||TREC.ename');
         else
           null ; -- Don't output if it is not equal
         end if ;
      END LOOP;
    END LOOP;
    EXCEPTION
    WHEN OTHERS
    THEN
    V_CODE := SQLCODE;
    V_ERRM := SUBSTR(SQLERRM,1,64);
    DBMS_OUTPUT.put_line ('ERROR CODE' || V_CODE || ':' || V_ERRM);
    close cr_emp;
    close cr_tmpy;
    END;
    /Sanjay

  • Returning SQL cursor from Stored Procedure

    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..

    RP wrote:
    Hi,
    I have a query regarding returning sql cursor from stored procedure to java in oracle 11g.
    I want to query some data ex: my query returns A, B, C. Also, now I want to query some other data ex: D, E, F. Now I want to return this data as an sql cursor as a single row . Example: A,B,C,D,E,F. Is it possible to return/create a cursor in stored procedure?
    assume both query returns equal number of rows.. however both are not related to each other..It sounds like what you need is a ref cursor.
    First thing to remember though is that cursors do not hold any data (see: {thread:id=886365})
    In it's simplest form you would be creating a procedure along these lines...
    SQL> create or replace procedure get_data(p_sql in varchar2, p_rc out sys_refcursor) is
      2  begin
      3    open p_rc for p_sql;
      4  end;
      5  /
    Procedure created.
    SQL> var rc refcursor;
    SQL> exec get_data('select empno, ename, deptno from emp', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc;
         EMPNO ENAME          DEPTNO
          7369 SMITH              20
          7499 ALLEN              30
          7521 WARD               30
          7566 JONES              20
          7654 MARTIN             30
          7698 BLAKE              30
          7782 CLARK              10
          7788 SCOTT              20
          7839 KING               10
          7844 TURNER             30
          7876 ADAMS              20
          7900 JAMES              30
          7902 FORD               20
          7934 MILLER             10
    14 rows selected.
    SQL> exec get_data('select deptno, dname from dept', :rc);
    PL/SQL procedure successfully completed.
    SQL> print rc
        DEPTNO DNAME
            10 ACCOUNTING
            20 RESEARCH
            30 SALES
            40 OPERATIONS
            50 IT SUPPORTWhich takes an SQL statement (as you said that both your queries were unrelated), and returns a ref cursor, and then your Java code would fetch the data using that cursor.
    Now, as for getting your rows to columns and combining two queries that do that... something along these lines...
    SQL> select * from x;
    C
    A
    B
    C
    SQL> select * from y;
    C
    D
    E
    F
    SQL> ed
    Wrote file afiedt.buf
      1  select x.col1, x.col2, x.col3
      2        ,y.col1 as col4
      3        ,y.col2 as col5
      4        ,y.col3 as col6
      5  from (
      6        select max(decode(rn,1,col1)) as col1
      7              ,max(decode(rn,2,col1)) as col2
      8              ,max(decode(rn,3,col1)) as col3
      9        from (select col1, rownum rn from (select * from x order by col1))
    10       ) x
    11  cross join
    12       (
    13        select max(decode(rn,1,col1)) as col1
    14              ,max(decode(rn,2,col1)) as col2
    15              ,max(decode(rn,3,col1)) as col3
    16        from (select col1, rownum rn from (select * from y order by col1))
    17*      ) y
    SQL> /
    C C C C C C
    A B C D E F... will do what you ask. For further information about turning rows to columns read the FAQ: {message:id=9360005}

  • Two "cursors" when in tablet mode

    X61 tablet, Windows 7, RC1, 64 bit. , pdfannotator, onenote, office
    When using the the tablet in tablet mode (screen folded down), I often will get two cursors on the screen when the pen is near or on it.  This happens in various application software, but usually begins after using the eraser, or the flyout keyboard and tablet input menu. 
    The extra cursor appears above, and to the right of the actual cursor. Actual cursor being a pen tip "dot" while the extra cursor is a random symbol, ranging from another offset dot, to a very dark right click ring, to a very dark hourglass, to an i-beam shaped bar.  It happens immediately when using grahl's pdf annotator, but has showed up in other programs as well including onenote, after using the flyout input panel in word, and a number of other programs. 
    I'm certain it has something to do with the tablet multitouch drivers, escpecially since the drivers for 7 seem to be a wacom dual-touch driver not designed specifically for the X61.  Anyone else run into this trouble and come across a solution?

    This is what Microsoft Support told me to do, and it worked, but I am stuck with a boring standard mouse cursor in Windows (no special Tablet PC cursors - for right click, etc.)
    Step 1:
    1. Open Local Group Policy Editor:Run... gpedit.msc
    2. Navigate to User Configuration - Administrative Templates - Windows Components - Tablet PC - Cursors
    3. Enable the Turn off pen feedback setting.
    Step 2:
    Go to Control Panel. Double click on Mouse. Find "Mouse Properties"
    Go to "Pointer Options". Put a check mark in the "Display Pointer trails"
    Slide the bar over to "short". Apply the changes and then restart PDF Annotator.
    I'm awaiting Microsoft's reply as to whether there is some way to keep my original cursors without having the PDF Annotator problem.

  • Cursor in stored procedure fails

    Hi,
    In our application we have a stored procedure which is called with in parameters to generate data into some table. This procedure is being called from another procedure.
    This procedure has been used to generate data into the table without any problem since oracle 9i. Last year we have upgraded to oracle 11g after that this procedure is failing intermittently to generate data. When this procedure is executed 50 times it fails atleast once to generate data. If we rerun the procedure for the failed case it generates the data without any change to program code nor any change in underlying data. It doesn't fail if we rerun. Therefore we are unable to simulate the problem.
    Procedure has got a very simple code.
    proc1 (p1 date,p2 date) is
    begin
    for c1_rec in c1 (select col1,col2
    from x,y where x.......)
    loop
    end loop;
    end;
    First we thought for some reason this procedure was not executed at all. But it is not the case. Actually it calls the procedure but the cursor inside the procedure doesn't fetch any records. Also it doesn't report any oracle error.
    Appreciate if any one can help me in this.
    Thanks & Regards,
    Raja

    vaidyanathanraja wrote:
    4. If there is a logical error, the same procedure should not generate data when it is rerun. Behaviour should be the same at all times.Incorrect. Something like NLS settings for example can make the same code, behave differently. E.g. a date string is passed and implicitly converted to a date. And this will work for most dates from different session using different NLS settings (e.g. yyyy/mm/dd versus yyyy/dd/mm). And these sessions will provide different results using the same parameters calling the same application code.
    There are a number of such run-time factors that influences code.
    5. Failed means it didn't generate the expected output. Which means that there is a problem with that SQL being executed the way it is, with the parameters used. You need to isolate the problem further.
    6. Parameter values are right.Have you proved that by using a test case that runs the very same SQL via a test proc, using the same parameter, via a job? Ran that test case interactively via sqlplus?
    You need to pop the hood and isolate the problem.
    7. I came across one blog saying different behaviour for REF CURSOR between oracle 10g and 11g and he says it is oracle bug. I don't know whether it is applicable for this case also.Bahumbug. There are many Oracle bugs. As there is in all software. However, you have not provided any evidence of a bug.
    Application code is behaving inconsistently. That is the symptom. Oracle system code is not relevant until you can prove that the inconsistency is not in the application code, but lower down the call stack.

  • How can I get extract the data between two cursors on an XY graph

    How can I get extract the data between two cursors on an XY graph

    Well, you say xy graph, so this might be a more complicated problem.
    For a waveform graph it's trivial. Simply get the two cursor indices (property: cursor index) and apply them to array subset of the data. Is that all you need?
    Here's how the above code would look like. using cursor.index instead of cursor.x elimnates the need to include scaling information.
    For an xy graph, there could be multiple segments (e.g. imagine a spiral that passes the desired x range multiple times from both sides). This would neeed significantly more code for a general solution.
    Message Edited by altenbach on 11-24-2009 07:53 AM
    LabVIEW Champion . Do more with less code and in less time .
    Attachments:
    cursorsubset.png ‏17 KB

  • "multiple cursor in a procedure" is possible?

    Hi.. everyone.
    Is it possible , "multiple cursor in one procedure"?
    For example,
    create or replace procedure xxx
    is
    vAAA varchar2(10);
    vBBB varchar2(10);
    cursor cur_1 is select .............................;
    cursor cur_2 is select .............................;
    begin
    -- the first cursor
    open cur_1;
    loop
    end loop;
    close cur_1;
    -- the second cursor
    open cur_2;
    loop
    end loop;
    close cur_2;
    end;
    If it is not possible, what is the way to use
    multiple cursor(more than 2) in ONE procedure?
    Thanks in advance.
    Have a nice day.
    Ho.

    no problem
    SQL> drop procedure xxx;
    Procedure dropped.
    SQL> CREATE OR REPLACE
      2  procedure xxx
      3  is
      4  vAAA varchar2(10);
      5  vBBB varchar2(10);
      6  cursor cur_1 is select employee_id from employees where rownum < 2;
      7  cursor cur_2 is select department_id from departments where rownum < 2;
      8
      9  begin
    10  -----------------------------------------------
    11  -- the first cursor
    12  -----------------------------------------------
    13  dbms_output.put_line('Cursor 1 Result');
    14  open cur_1;
    15  loop
    16    fetch cur_1 into vAAA;
    17    exit when cur_1%notfound;
    18    dbms_output.put_line(vAAA);
    19  end loop;
    20  close cur_1;
    21  -----------------------------------------------
    22  -- the second cursor
    23  -----------------------------------------------
    24  dbms_output.put_line('Cursor 2 Result');
    25  open cur_2;
    26  loop
    27    fetch cur_2 into vBBB;
    28    exit when cur_2%notfound;
    29    dbms_output.put_line(vBBB);
    30  end loop;
    31  close cur_2;
    32  -----------------------------------------------
    33  end;
    34  /
    Procedure created.
    SQL> execute xxx;
    Cursor 1 Result
    100
    Cursor 2 Result
    10
    PL/SQL procedure successfully completed.

  • Open Cursor in a procedure

    Hi to all,
    my problem is to open a cursor into a procedure.
    The code is the following:
    PROCEDURE p_selection_customer
    IS
         CURSOR cursor_customer IS
              SELECT
              c_u.id_customer
              FROM
              customer_unified_a c_u;
         BEGIN
              FOR record_customer IN cursor_customer LOOP
                   ROLLBACK;
              END LOOP;
    END p_selection_customer;
    The error is :
    Errore(55,3): PL/SQL: SQL Statement ignored
    Errore(58,3): PL/SQL: ORA-06552: PL/SQL: Compilation unit analysis terminated ORA-06553: PLS-320: the declaration of the type of this expression is incomplete or malformed
    This procedure is defined in the spec. Then I suppose that my problem is that I can't open a cursor into my schema. Do I verify this hypotesys in my schema? Do I have some queries? My schema don't have the dba and sys grants.
    Thank'you very match!

    Hi Alex,
    this is the complete script used to generate the table.
    Me too, I knew that the partition was transparent to the Cursor statement.
    Thank'you very match!
    CREATE TABLE "SSVILCID"."TW_E_CUSTOMER_UNIFIED_A"
       (     "ID_CUSTOMER_UNIFIED" VARCHAR2(27 BYTE) NOT NULL ENABLE,
         "START_VALIDITY_DATE" DATE NOT NULL ENABLE,
         "START_ASINC_DATE" DATE NOT NULL ENABLE,
         "END_ASINC_DATE" DATE,
         "CUSTOMER_STATUS" VARCHAR2(255 BYTE),
         "TERMINATION_DATE" DATE,
         "CUSTOMER_DOMAIN" VARCHAR2(255 BYTE),
         "CUSTOMER_CLUSTER" VARCHAR2(255 BYTE),
         "CUSTOMER_SENIORITY" DATE,
         "ACTIVATION_DATE" DATE,
         "ACQUISITION_DATE" DATE,
         "ACQUISITION_CHANNEL" VARCHAR2(255 BYTE),
         "SUB_ACQUISITION_CHANNEL" VARCHAR2(255 BYTE),
          CONSTRAINT "TW_E_CUSTOMER_UNIFIED_A_PK" PRIMARY KEY ("START_ASINC_DATE", "ID_CUSTOMER_UNIFIED", "START_VALIDITY_DATE")
      USING INDEX PCTFREE 10 INITRANS 2 MAXTRANS 255
      STORAGE(INITIAL 65536 NEXT 1048576 MINEXTENTS 1 MAXEXTENTS 2147483645
      PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1 BUFFER_POOL DEFAULT)
      TABLESPACE "SYSTEM"  ENABLE
       ) PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
      PARTITION BY RANGE ("START_ASINC_DATE")
      SUBPARTITION BY LIST ("END_ASINC_DATE")
    (PARTITION "M200909"  VALUES LESS THAN (TO_DATE(' 2009-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200909_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200909_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M200910"  VALUES LESS THAN (TO_DATE(' 2009-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200910_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200910_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M200911"  VALUES LESS THAN (TO_DATE(' 2009-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200911_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200911_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M200912"  VALUES LESS THAN (TO_DATE(' 2010-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M200912_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M200912_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M201001"  VALUES LESS THAN (TO_DATE(' 2010-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M201001_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M201001_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "M201002"  VALUES LESS THAN (TO_DATE(' 2010-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M201002_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M201002_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") ,
    PARTITION "FUTURE"  VALUES LESS THAN (MAXVALUE)
    PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
      STORAGE(
      BUFFER_POOL DEFAULT)
      TABLESPACE "DATI"
    ( SUBPARTITION "M210001_N"  VALUES (NULL)
       TABLESPACE "DATI",
      SUBPARTITION "M210001_NN"  VALUES (DEFAULT)
       TABLESPACE "DATI") )  ENABLE ROW MOVEMENT ;

  • I have a plot with two cursors - how can I control the "visible" attribute of the second cursor?

    I have a waveform graph with multiple plots and two cursors. I can use the "cursor->visible" property to control cursor #1 but I cannot seem to find a way to control the visible attribute for cursor #2. Is there a way to do this?
    Thanks,
    RGA

    There's an "Active Cursor" property that allows you select which cursor the following actions operate on. Remember that property nodes "execute" from top to bottom...
    Mike...
    Certified Professional Instructor
    Certified LabVIEW Architect
    LabVIEW Champion
    "... after all, He's not a tame lion..."
    Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps

  • Linear fit between two cursors from a signal from a NI-instruments via DAQ-Assistant

    Hi ! 
    I'm currently having som problem with my labview code. I'm trying to make regression on a specific part of my graph. The graph consist of a signal gathered from a NI cDAQ-9178. Currently I can get the live data in a graph (Raw Signal) and then  "zoom in" to the part of the graph that im intrested in by two cursors and then display the results in a new graph (Adjusted Signal). Now a want to make regresion in the new graph. How can i do this the best way ? 
    To be noted I'm a beginner of labview so my code maybe a bit off.
    Best regards Maurlind
    Solved!
    Go to Solution.
    Attachments:
    Rawsignal test.vi ‏245 KB
    rawsignal test.png ‏64 KB

    Hi maurlind,
    I got it, the function that derived the linear fit couldn't handle that large numbers on the x-axis. I edited the VI so that the large number is suctracted for the fit, i.e. the array will now begin at zero time for the fit. It will not affect your plots though, only the algorithm .
    Try it now with the files I provided. The file "pm_mod2_Rawsignal test.vi" should be used with "test3.lvm" (your data). The file "pm_mod3_Rawsignal test.vi" is the same as "pm_mod2_Rawsignal test.vi", but it is arranged to work with the simulated data. The file "test3.lvm" is your data, but the file is slightly edited to work on my system.
    Edit "pm_mod3_Rawsignal test.vi" to fit with your acquired signal as you did with the first file you got from me.
    Attachments:
    1412794.zip ‏483 KB

Maybe you are looking for

  • How much of Flash Storage Should I get?

    I am planning to buy a 13" macbook pro but i am a little confused on what size flash storage to get. I've heard some people say that 128GB is enough, some say it's not. I plan to use this computer for little bit of gaming, email, pics, video, do PC s

  • Importing MTS files in Premiere Pro CS5 Trial

    I just bought the Master Collection but I am getting the box sent to me via mail so while I am waiting I am using the trial version. Anyways I tried importing MTS files from my hard drive and I am getting the following error - "file has an unsupporte

  • Can't compile the pngencoder.swc form the sample/libpng

    Hi, I tried without success to compile the png lib port form the Alchemy's sample. Is it possible to find this file pngencoder.swc already compiled? Thanks Julien Félix

  • Convert Image between Java2 and Microsoft Visual J++6.0

    Hello experts, Where describe that transforma image in Java2 to image in Microsoft Visual J++ 6.0. Please help me,thank you. bch Oct 20,2004

  • Music playlist missing

    bought a new computer - now i cant find my music in my i tunes account - please help