>select * from student where scode=zscode and lcode=zlcode and sec=zsec and admtd=1 >into cursor curToProcess nofilter >select * from curToProcess left join ExamTran ex on ... where ex.code is NULL into cursor curToInsert nofilter > >insert into ExamTran (code) select code from curToInsert >update examtran >set (all your changes) >from curToProcess inner join ExamTran on curToProcess.code = ExamTran.code >>
try insert .... (with changes) catch update with changes endtry