create or replace PROCEDURE PROC_TESTPROCEDURENAME
(
REF_CURSOR OUT SYS_REFCURSOR,
OP_strException OUT VARCHAR2
)
AS
V_COUNT INTEGER:=0;
cursor c is select id from TBL_USERMASTER;
tmp INTEGER;
BEGIN
open c;
LOOP EXIT when c%NOTFOUND;
FETCH c into tmp;
V_COUNT:=0;
select count(*) into V_COUNT from TBL_MAPPINGUSERDETAIL where fkUserid=tmp;
if V_COUNT=0 then
insert into TBL_MAPPINGUSERDETAIL(id,name,mobile,fkUserid,created_date)
select SEQ_TBL_MAPPINGUSERDETAIL.NEXTVAL,NAME,MOBILE_NO,SEQID,sysdate from TBL_USERMASTER where id =tmp;
end if;
commit;
END Loop;
close c;
OPEN REF_CURSOR FOR
select id,name,mobile,fkUserid from TBL_MAPPINGUSERDETAIL order by name;
OP_strException:='';
exception
when others then
OP_strException:= SUBSTR(SQLERRM, 1, 100);
-- Log Table Maintain
END;
(
REF_CURSOR OUT SYS_REFCURSOR,
OP_strException OUT VARCHAR2
)
AS
V_COUNT INTEGER:=0;
cursor c is select id from TBL_USERMASTER;
tmp INTEGER;
BEGIN
open c;
LOOP EXIT when c%NOTFOUND;
FETCH c into tmp;
V_COUNT:=0;
select count(*) into V_COUNT from TBL_MAPPINGUSERDETAIL where fkUserid=tmp;
if V_COUNT=0 then
insert into TBL_MAPPINGUSERDETAIL(id,name,mobile,fkUserid,created_date)
select SEQ_TBL_MAPPINGUSERDETAIL.NEXTVAL,NAME,MOBILE_NO,SEQID,sysdate from TBL_USERMASTER where id =tmp;
end if;
commit;
END Loop;
close c;
OPEN REF_CURSOR FOR
select id,name,mobile,fkUserid from TBL_MAPPINGUSERDETAIL order by name;
OP_strException:='';
exception
when others then
OP_strException:= SUBSTR(SQLERRM, 1, 100);
-- Log Table Maintain
END;



0 comments:
Post a Comment