-
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
-
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;
/
-
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.
-
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;
/
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|