ROWID in dynamic SQL
DBAsupport.com Forums - Powered by vBulletin
Results 1 to 4 of 4

Thread: ROWID in dynamic SQL

  1. #1
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    Unhappy ROWID in dynamic SQL

    i have my variable declared as:

    l_rowid urowid;

    and i want to execute a dynamic update using rowid as a bind variable:

    for cur in (select rowid, ....) loop

    l_rowid := cur.rowid;

    execute immediate 'update sometable set somecolumn = 1 where rowid=:row_id' using l_rowid;

    end loop;

    something's wrong though and i get oracle error (invalid rowid).

    what is the correct way of doing this?

    THX

  2. #2
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Implicit cursor ...
    Code:
    begin
    for l_cur in (select rowid from my_table)
    loop
    update my_table set col1=2 where rowid = l_cur.rowid;
    end loop;
    end;
    /
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

  3. #3
    Join Date
    Feb 2003
    Location
    Slovakia, Europe
    Posts
    72

    Unhappy i must use dynamic sql

    thx, slimdave, but i DO need to use dynamic SQL because of other predicates i'm using in that update statement which i do not know in advance.

  4. #4
    Join Date
    Aug 2002
    Location
    Colorado Springs
    Posts
    5,253
    Code:
    begin
       for l_cur in (select rowid from my_table)
       loop
          execute immediate 'update my_table set col1=2 where rowid = :my_rowid' using l_cur.rowid;
       end loop;
    end;
    /
    David Aldridge,
    "The Oracle Sponge"

    Senior Manager, Business Intelligence Development
    XM Satellite Radio
    Washington, DC

    Oracle ACE

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