Home » Developer & Programmer » Forms » updating using forms
| updating using forms [message #258037] |
Thu, 09 August 2007 22:16  |
alister
Messages: 101 Registered: August 2007 Location: India
|
Senior Member |
|
|
I created a form which should insert into a table if the record is not found and updated it if it is already there. But it is always inserting a new record into the table. So I made one field unique. Now it says record already inserted or Unable to insert, and does not update the fields that I have updated. Can anyone help me.
Alister
|
|
|
|
|
|
| Re: updating using forms [message #258958 is a reply to message #258039] |
Mon, 13 August 2007 22:20   |
alister
Messages: 101 Registered: August 2007 Location: India
|
Senior Member |
|
|
Dear David
I am using Forms 5.0.6 and Oracel 8.1.7.
I am enclosing the code below
key_next_item of :adjfschdr.empcode
BEGIN
DECLARE
L_NO NUMBER;
BEGIN
SELECT COUNT(EMPCODE) INTO L_NO FROM ADJFSCHDR WHERE EMPCODE=:adjfschdr.empcode;
IF L_NO=0 THEN
SELECT BILLUNIT,EMPNAME,RLYJOINDATE,PAYRATE,SCALECODE,DESIGNATION
into :adjfschdr.billunit,:adjfschdr.empname,:adjfschdr.dateofappointment,:adjfschdr.basicrate,
:adjfschdr.scalecode,:adjfschdr.designation
FROM AFPBLEMP
WHERE EMPNO=:adjfschdr.empcode
AND PAYBILLID IN (SELECT MAX(PAYBILLID) FROM AFPBLEMP
WHERE EMPNO=:adjfschdr.empcode AND PAYBILLID LIKE '200%');
BEGIN
select deptcode,birthdate,ticketno,empgroup
into :adjfschdr.department,:adjfschdr.dateofbirth,:adjfschdr.staffno,
:adjfschdr.empgroup
from prmaemp
WHERE EMPno=:adjfschdr.empcode;
EXCEPTION
WHEN NO_DATA_FOUND THEN
NULL;
END;
SELECT SHORTDESC INTO
:adjfschdr.department
from afgencod
where codetype='DT'
AND CODE=:adjfschdr.department;
ELSE
SELECT billunit, empcode, staffno, empname, department,
dateofappointment, basicrate, scalecode, designation,
dateofbirth, dateofsecondment, yearsofservice, officeorder,
corporatebody, dateofrepatriation,empgroup
INTO :adjfschdr.billunit, :adjfschdr.empcode, :adjfschdr.staffno, :adjfschdr.empname,
:adjfschdr.department,:adjfschdr.dateofappointment, :adjfschdr.basicrate,
:adjfschdr.scalecode, :adjfschdr.designation,
:adjfschdr.dateofbirth, :adjfschdr.dateofsecondment, :adjfschdr.yearsofservice,
:adjfschdr.officeorder,:adjfschdr.corporatebody, :adjfschdr.dateofrepatriation,
:adjfschdr.empgroup
FROM adjfschdr
WHERE EMPCODE=:adjfschdr.empcode;
END IF;
:adjfschdr.yearsofservice:=round(MONTHS_BETWEEN( sysdate, :adjfschdr.dateofappointment) / 12,1);
END;
END; --------
I the record is already availabe in the Adjfschdr table it will display it, otherwise it will fetch it from other tables. If it is a new record it gets updated into adjfschdr table. If it is not a new record, then only the corrected fields should get updated. But since empcode is unique it says FRM-40508 - ORACLE error Unable to insert record. On the save button I gave only commit.
Alister
[Updated on: Tue, 14 August 2007 02:16] by Moderator Report message to a moderator
|
|
|
|
|
|
|
|
|
|
| Re: updating using forms [message #259538 is a reply to message #259018] |
Wed, 15 August 2007 22:30  |
alister
Messages: 101 Registered: August 2007 Location: India
|
Senior Member |
|
|
I have tried your suggestion of creating a control block on empcode and then did the execute query. I worked. Thank you very much. I shall download some of the demos and study them
Alister
|
|
|
|
Goto Forum:
Current Time: Wed Apr 29 21:30:08 CDT 2026
|