Using records with cursors in oracle database language plsql

RECORD is every single item in cursor (cursordaki herbir kayıt RECORD diye tanımlanır)
There is 3 way to use records (with cursor) 

1 - creating cursor and fetching it into record

You can create cursor (vc_MyCursor) and record (vr_RecEmployees) at the beginning of anonymous block and  open it in begin-end section, then can fetch it into a record by using

FETCH vc_MyCursor INTO vr_RecEmployees;
At the cursor should be closed as 
CLOSE vc_MyCursor;

2 - using record as cursor of select statement in for loop

Simple you can create a local record in for loop as
FOR rec IN (SELECT * FROM employees e WHERE department_id = 30) LOOP
...
  END LOOP;

3 - using record based on cursor in for loop!

 Another easier way to create a local record is using created cusrsor in for loop as
 FOR rec IN vc_MyCursor LOOP
...
  END LOOP;

All codes are available in GitHub here.
If you want to check some real project with all PLSQL codes please check here
Till next time!

Comments

Popular posts from this blog

Gove confirms mandatory housebuilding targets for councils will be abolished in face of Tory rebellion – UK politics live

Kotak Mahindra Bank Recruitment 2022 Released for Graduate Candidates And Apply Online