Home » Developer & Programmer » Forms » what is wrong with this code
what is wrong with this code [message #198121] |
Sun, 15 October 2006 05:05 |
qewani
Messages: 51 Registered: December 2005 Location: uaq
|
Member |
|
|
hi
this code does not do the insert step and the update step?? why does it not do that? what is wrong in my code please help me??
DECLARE
V_NUMBER NUMBER;
M_ATHG_CODE VARCHAR2(40);
CURSOR C2 IS
SELECT AUSR_ATHG_CODE
FROM PM_AUTH_USER
WHERE AUSR_USER_ID = :GLOBAL.M_USER_ID;
V_NUMBER NUMBER;
alert_button NUMBER;
DUMMY2 VARCHAR2(6);
DUMMY VARCHAR2(6);
CURSOR C1 IS
SELECT EMPD_DOCU_CODE, EMPD_CODE FROM PM_EMP_DOCUMENT
where EMPD_DOCU_CODE = :PT_EMP_DOCUMENT_DETAIL.EDD_DOCU_CODE and EMPD_CODE = :PT_EMP_DOCUMENT_head.EDH_EMP_CODE ;
BEGIN
IF :EDH_APPR_UID IS NOT NULL THEN
message('THIS IS ALREADY APPROVED');
RAISE FORM_TRIGGER_FAILURE;
END IF;
--SELECT EMPD_DOCU_CODE, EMPD_CODE INTO DUMMY, DUMMY2 FROM PM_EMP_DOCUMENT
--where EMPD_DOCU_CODE = :PT_EMP_DOCUMENT_DETAIL.EDD_DOCU_CODE and EMPD_CODE = :PT_EMP_DOCUMENT_head.EDH_EMP_CODE ;
--IF :PT_EMP_DOCUMENT_DETAIL.EDD_DOCU_CODE = dummy AND :PT_EMP_DOCUMENT_head.EDH_EMP_CODE = DUMMY2 THEN
--select empd_docu_code INTO DUMMY FROM PM_EMP_DOCUMENT
IF C1%ISOPEN THEN
CLOSE C1;
END IF;
OPEN C1 ;
FETCH C1 INTO DUMMY, DUMMY2;
message ('hi 1');
--null;
--else
IF C1%FOUND THEN
UPDATE PM_EMP_DOCUMENT SET
EMPD_COMP_CODE = :EDH_COMP_CODE,EMPD_CODE =:EDH_EMP_CODE,
EMPD_DOCU_CODE = :EDD_DOCU_CODE,EMPD_NUMBER =:EDD_NUMBER,
EMPD_ISS_PLACE = :EDD_ISS_PLACE,EMPD_ISS_DT = :EDD_ISS_DT,EMPD_EXP_DT =:EDD_EXP_DT,
EMPD_ISS_DT_HIJR =:EDD_ISS_DT_HIJR,EMPD_EXP_DT_HIJR =:EDD_EXP_DT_HIJR,
EMPD_INIT_DAYS =:EDD_INIT_DAYS,EMPD_FRZ_FLAG =:EDD_FRZ_FLAG,
EMPD_CR_UID =:EDD_CR_UID,EMPD_CR_DT = :EDD_CR_DT,
EMPD_UPD_UID =:EDD_UPD_UID,EMPD_UPD_DT =:EDD_UPD_DT,
EMPD_JS_DATE =:EDD_JS_DATE,
EMPD_JS_REMARKS =:EDD_JS_REMARKS
;
ELSIF C1%NOTFOUND THEN
message ('SQLNOTFOUND NOW INSERTING');
INSERT INTO PM_EMP_DOCUMENT(EMPD_COMP_CODE,EMPD_CODE,
EMPD_DOCU_CODE,EMPD_NUMBER,EMPD_ISS_PLACE,EMPD_ISS_DT,EMPD_EXP_DT,
EMPD_ISS_DT_HIJR,EMPD_EXP_DT_HIJR,EMPD_INIT_DAYS,EMPD_FRZ_FLAG,EMPD_CR_UID,EMPD_CR_DT,EMPD_UPD_UID,EMPD_UPD_DT,EMPD_JS_DATE,
EMPD_JS_REMARKS) VALUES (:EDH_COMP_CODE,
:EDH_EMP_CODE,
:EDD_DOCU_CODE,
:EDD_NUMBER,
:EDD_ISS_PLACE,
:EDD_ISS_DT,
:EDD_EXP_DT,
:EDD_ISS_DT_HIJR,
:EDD_EXP_DT_HIJR,
:EDD_INIT_DAYS,
:EDD_FRZ_FLAG,
:EDD_CR_UID,
:EDD_CR_DT,
:EDD_UPD_UID,
:EDD_UPD_DT,
:EDD_JS_DATE,
:EDD_JS_REMARKS);
commit;
message ('hi 2');
--else null;
END IF;
message ('LAST');
CLOSE C1;
OPEN C2;
FETCH C2 INTO M_ATHG_CODE;
IF M_ATHG_CODE IS NULL OR C2%NOTFOUND THEN
IF GET_ITEM_PROPERTY('PT_EMP_DOCUMENT_HEAD.APPROVE', ENABLED) = 'TRUE' THEN
SET_ITEM_PROPERTY('PT_EMP_DOCUMENT_HEAD.APPROVE', ENABLED , PROPERTY_FALSE);
END IF;
ELSE
IF GET_ITEM_PROPERTY('PT_EMP_DOCUMENT_HEAD.APPROVE', ENABLED) = 'FALSE' THEN
SET_ITEM_PROPERTY('PT_EMP_DOCUMENT_HEAD.APPROVE', ENABLED , PROPERTY_TRUE);
END IF;
END IF;
END;
|
|
|
|
|
|
|
Re: what is wrong with this code [message #198266 is a reply to message #198152] |
Mon, 16 October 2006 06:18 |
yogen
Messages: 39 Registered: October 2006 Location: UK
|
Member |
|
|
Hi,
First of all if your cursor is selecting only one record why you need cursors..directly you can use select..into ...clause then check the values and update/insert accordingly.
If the cursor is selecting more then one record you need to use loop and then do whatever operation you want to do.
try this it must work after that.
|
|
|
Goto Forum:
Current Time: Tue Dec 03 05:26:40 CST 2024
|