oracle - Using UPDATE cursor in PL/SQL -


as far can see, can make update in pl/sql without using cursor. example:

create or replace procedure update_my_table (id number)    ... begin    ...    update my_table set column=null my_id = id;    ... end 

i guess cursor needed if want perform fetch of updated row, right?

oracle uses cursors under hood update , selects, going bit beyond you're asking. no, don't have select rows updated in visible explicit or implicit cursor.

you don't have use cursor select row though. can select ... into:

create ...     my_row my_table%rowtype; begin     select * my_row my_table my_id = id;     -- row data     dbms_output.put_line(my_row.my_col); end; 

or can select individual columns separate variables instead of rowtype variable. have 1 row (or 1 row's worth of columns) query; if there no matches you'll no data found error, if more 1 too many rows. can select multiple rows pl/sql table , manipulate data there, still without visible cursor.

however, if want select and update row, want cursor with select ... update clause, , update ... current of ... prevent else modifying data between select , update.

a simple update you've got efficient way, whether you're updating 1 row or millions.


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -