Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2002
    Location
    India
    Posts
    40

    Unanswered: Loop in cursors and update some values

    Hello

    i want to create one cursor with null values.
    like
    Cursor test is
    Select a,b,c,d,e,f,g,h,i,j,k from dual

    After this i want to pass values for a,b,c,d in that cursor
    Once it is done, again i want to pass values for
    a,b,e,f, after this once again
    i want to pass values to a,b,g,h

    Can i do that , if S please give me some code sample.

    I have one SQL in which for now we are creating one
    temp table and in each SQL we are inserting values into
    required columns in that temp table

    Finally we are taking values from temp , combining
    with other main tables.

    Now are forced to go for PL/SQL so ..let me know
    what i can do for this

    Is it possible to insert only some column values in
    cursor...

    Thanks
    Suryadevara

  2. #2
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    I don't understand what you are trying to do, really. You can't select a,b,c,... from dual because table dual doesn't possess such columns:

    SQL> select a,b,c from dual;
    select a,b,c from dual
    *
    ERROR at line 1:
    ORA-00904: invalid column name

    But let's suppose you are really selecting from another table:

    SQL> create table t1 (a int, b int, c int);

    Table created.

    Now, you can set values in the cursor record like this:

    Code:
    declare
      cursor test is
        select a,b,c from t1;
    begin
      for r in test loop
        r.b := 1;
        r.c := 2;
        update test set b = r.b, c=r.c
        where a = r.a;
      end loop;
    end;
    /
    Is that what you meant?

Posting Permissions

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