Results 1 to 4 of 4
  1. #1
    Join Date
    Oct 2002
    Posts
    11

    Unanswered: Updating From Cursor

    HI
    when we are updating a table from cursor is it necessary that the curstructure and destination table structure is exactly same or with diff???
    san

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: Updating From Cursor

    What do you mean by "updating a table from cursor" and "curstructure"?
    You can certainly do this:

    CREATE TABLE t1 ( a, b, c);
    CREATE TABLE t2( x, y );

    DECLARE
    CURSOR c IS SELECT a,b,c FROM t1;
    BEGIN
    FOR r IN c LOOP
    UPDATE t2 SET x = r.a WHERE y = r.b;
    END LOOP;
    END;
    /

    Is that what you meant?

  3. #3
    Join Date
    Oct 2002
    Posts
    11

    structure

    i mean

    If i have table1 structure

    slno varchar2(10),
    empno varchar2(!))


    other table is empno varchar2(10)
    slno varchar2(!));

    so when i am selcting in to cursor is that selection should be in same order of updating table or it is not a problem..


    san

  4. #4
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1

    Re: structure

    What does your update look like? You can see from my previous post that order, number and name of columns is irrelevant in the type of update I was showing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •