Insert using a cursor record?
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 8 of 8

Thread: Insert using a cursor record?

Hybrid View

  1. #1
    Join Date
    Nov 2001
    Location
    New Brunswick, NJ
    Posts
    67
    Is it possible to insert into a table
    using the record loaded from a cursor?


    declare
    cursor c_cursor is
    select a,b,c from table;
    begin
    for c_rec in c_cursor
    loop

    insert into new_table (using record???)

    end loop;
    end;

    Thanks,

    Paul

  2. #2
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,136
    Yes.

  3. #3
    Join Date
    Nov 2001
    Location
    New Brunswick, NJ
    Posts
    67
    okay...

    How do I code it?

    Thanks.

  4. #4
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    declare
    cursor c_cursor is
    select a,b,c from table;
    begin
    for c_rec in c_cursor
    loop
    insert into new_table (a_new, b_new, c_new)
    values (c_rec.a,c_rec.v,c_rec.c);
    end loop;
    end;
    /

  5. #5
    Join Date
    Nov 2001
    Location
    New Brunswick, NJ
    Posts
    67
    what I was really after was to not to have to specify each of the value fields.

    something like

    insert into new_table record;

    and have record represent all of the indivual fields.

    It's just a pain because some of my cursors contain dozens of fields and it takes awhile to specify each and every field after the values clause.

    Thanks for the help.

    Paul

  6. #6
    Join Date
    May 2000
    Location
    ATLANTA, GA, USA
    Posts
    3,136
    No Pain, No Gain.

  7. #7
    Join Date
    Sep 2001
    Location
    NJ, USA
    Posts
    1,287
    Originally posted by mrpaulwass
    what
    something like
    insert into new_table record;
    U can't do it.
    in INSERT statment u must wrile VALUES and specify LIST of values.
    regardless of u use scalar variables or object types or variable arrays..

  8. #8
    Join Date
    Nov 2001
    Location
    New Brunswick, NJ
    Posts
    67
    Thanks...

    Lazy programmer, always looking for a shortcut. That's me.

    P

Posting Permissions

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



Click Here to Expand Forum to Full Width