2. l
Cursors
A cursor is a structure that allows you to go over records
sequentially, and perform operations based on the results of
the cursor SELECT statement.
Cursors are created with a DECLARE CURSOR statement and
opened with an OPEN statement. Rows are read with a FETCH
statement before the cursor is finally closed with a CLOSE
statement.
A cursor should be created inside a Stored Programs.
11. Excercise:
1. Create three tables namely and have columns as follows:
1.1 Employee (EmpID, Name, Age)
1.2 Inventory (ItemID, ItemName, UsedEmpID)
1.3 EmpInvMatchTable (EmpID, ItemID)
2. Insert some relevant values to Employee and Inventory. Make sure there are values
in the Inventory table where it has some existing Employees using the items. And also
note that there are items which have no owner (means no EmplD)
3. Write a Procedure that has two cursors like in the sample, check the existing EmpIDs
in the Inventory table and if found then insert both the IDs (Emp and Item) to the third
table.
Note: You should execute the procedure and show me the results :)