Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

pl/sql help required on insertion / updation of empid

$
0
0

 My requirement is to insert data into emptable  and fields - empid,empfname,emplname,empfilestatus,createdate. Based on the below criteria I need to insert data  into emptable. For this purpose, am using empfilestatustable & empsrctable. Here is ...I need to use curosors and loop in stored procedure to do this activity...I need help please...I have built multiple sql select statements with union to insert but it has been told to built using cursors & loop...

insert into emptable

criteria - if empid not exist in emptable then insert and set empfilestatus=2
if empid exist in emptable then do not insert and update records (in case of change in fname or lname, shouldnt update empfilestatus)
if empfilestatus is (5,6,7) then it should insert any record in emptable even though empid existing in emptable.

if empfilestatus is (4) then it should not insert any record in emptable with same empid in emptable.

if record createdate>40  days  then it should insert empid in emptable even though it exists.

 empfilestatustable

empfilestatusempfilestatusname
1pending
2received
3inprogress
4cancel
5complete
6abonded
7superseded

empsrc table

empidempfnameemplnamedeptno
1johnkerrycomp
2andewflintpurch
3dineshpanpurch
4rajjarpurch
5karyvolsepurch
6dannydizecomp
7sachingeetedu
8soniadsouzaedu
9rajeshkawacomp






Viewing all articles
Browse latest Browse all 23857

Trending Articles