Pl sql updating current record in cursor
declare v_column my_table.column%type; l_count pls_integer; cursor my_cursor is select count(*) from my_table where ...; begin open my_cursor; fetch my_cursor into l_count; close my_cursor; if l_count = 1 then select whse_code into v_column from my_table where ...; else v_column := null; end if; end; declare v_column my_table.column%type; cursor my_cursor is select column from my_table where ...; begin open my_cursor; fetch my_cursor into v_column; -- Optional IF ..THEN based on FOUND or NOTFOUND -- Not really needed if v_column is not set if my_cursor%notfound then v_column := null; end if; close my_cursor; end; thanks for your reply.Inside a cursor loop, WHERE CURRENT OF allows the current row to be directly updated.When the session opens a cursor with the FOR UPDATE clause, all rows in the return set will hold row-level exclusive locks.
Consider the following table: Here is how you use the Update Cursor.
There can be a situation where you have to use a cursor, even though the experts say not to use cursors or to avoid them as much as possible.
But if you look closely, most of the time we use cursors to iterate through a row collection and update the same table.
Keep in mind that the column index here is 1-based, the first column will be at index 1, the second at index 2, and so on. "; Prepared Statement statement = conn.prepare Statement(sql); String(1, "bill"); int rows Deleted = statement.execute Update(); if (rows Deleted first of all i want to Thank you i was not much more familar with Oracle and now i'm doing my projects using oracle and your samples may help me to did my projects as a guide line so starting from now I will did my project .
If you are not sure or don’t know exactly the index of column, so passing a column name would be useful: String sql = "UPDATE Users SET password=?