Updating using explicit cursors Onlinesex pinay

Explicit Cursors Programmers create explicit cursors, and with these you can do operations on a set of rows, which can be processed one by one.

You use explicit cursors when you are sure that the SQL statement will return more than one row.

CREATE TABLE employees_temp AS SELECT employee_id, first_name, last_name FROM employees; DECLARE emp_id employees_temp.employee_id%TYPE; emp_first_name employees_temp.first_name%TYPE; emp_last_name employees_temp.last_name%TYPE; BEGIN INSERT INTO employees_temp VALUES(299, 'Bob', 'Henry'); UPDATE employees_temp SET first_name = 'Robert' WHERE employee_id = 299; DELETE FROM employees_temp WHERE employee_id = 299 RETURNING first_name, last_name INTO emp_first_name, emp_last_name; COMMIT; DBMS_OUTPUT.

By using the same mechanics, a SQL procedure can also define a result set and return it directly to the caller of the SQL procedure or to a client application.Cursors enable manipulation of whole result sets at once.In this scenario, a cursor enables the rows in a result set to be processed sequentially.For example, two statements might credit one bank account and debit another.It is important not to allow one operation to succeed while the other fails.Let's just recap quickly on the definitions we gave in the tutorial on implicit cursors.


Leave a Reply