Home » Developer & Programmer » Forms » unable to delete the record (Oracle forms 6i)
unable to delete the record [message #541787] Thu, 02 February 2012 05:12 Go to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

Hi all..
please see the attached images for reference..

when i tried to delete the record by clicking the delete button which has the trigger code as
---
delete from emp where employee_id=:e_id;
commit;

---
it wasn't. and showed the message as
---FRM-40508: ORACLE ERROR: Unable to INSERT record.
/forum/fa/9794/0/

if i change the EMP ID item property "database item" to "NO"..then i can able to delete the record..

but, now i am unable to insert the record form the same form...
  • Attachment: Picture1.jpg
    (Size: 54.38KB, Downloaded 9316 times)
Re: unable to delete the record [message #541789 is a reply to message #541787] Thu, 02 February 2012 05:17 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Assuming the datablock is based on the emp table the correct code is
delete_Record;

And there is a button on the standard tool bar that does that.
Re: unable to delete the record [message #541794 is a reply to message #541789] Thu, 02 February 2012 05:32 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

I can do that from standard toolbar delete button....

but, i need to delete the record by clicking the delete button..

then what changes need to be done..
Re: unable to delete the record [message #541796 is a reply to message #541794] Thu, 02 February 2012 05:33 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
As you were told: pure DELETE_RECORD built-in, not DELETE statement.
Re: unable to delete the record [message #541801 is a reply to message #541796] Thu, 02 February 2012 05:53 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

how can i delete the record which i entered in the "emp id" field..

for eg: i want to delete the employee whose id is 115.

then how can i use the DELETE_RECORD builtin..
Re: unable to delete the record [message #541804 is a reply to message #541801] Thu, 02 February 2012 06:20 Go to previous messageGo to next message
cookiemonster
Messages: 13937
Registered: September 2008
Location: Rainy Manchester
Senior Member
Is the datablock based on the emp table?
Re: unable to delete the record [message #541867 is a reply to message #541804] Thu, 02 February 2012 22:13 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

Yes..the datablock is on emp table.
Re: unable to delete the record [message #541881 is a reply to message #541867] Fri, 03 February 2012 00:03 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I'd suggest you to run the form once again, as it is. Enter 115 into that item and push the "Delete" button. It will fail with FRM-40508: ORACLE ERROR: Unable to INSERT record.

Now go to Help Forms menu and click "Display error".

/forum/fa/9799/0/

Post the result back here.

It's not that you can't DELETE a record, it is that your form is trying to INSERT a record, but is unable to. "Display Error" will tell you (us) why.
Re: unable to delete the record [message #541884 is a reply to message #541881] Fri, 03 February 2012 00:29 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

Hi..

Here is the error message...
It says cann't insert null into LAST_NAME.
my questions is that why it executing the INSERT statement..rather DELETE statement..


/forum/fa/9801/0/
  • Attachment: Picture2.jpg
    (Size: 78.38KB, Downloaded 8862 times)
Re: unable to delete the record [message #541886 is a reply to message #541884] Fri, 03 February 2012 00:42 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
COMMIT you have in WHEN-BUTTON-PRESSED trigger on the "Delete" button is trying to save datablock values into a table. LAST_NAME item is empty, but the column is NOT NULL so it fails.

So, are there any values in a data block? Make sure there aren't.

Anyway: I think that what you are doing is wrong. As it is a datablock, there's no reason to delete records as you are trying to. If you want to remove certain employee's record, you should:
- enter query mode
- put 115 into the EMP_ID item
- execute query
- once the values are retrieved, DELETE_RECORD (a built-in). Not DELETE FROM ... (a statement).

If you insist on deleting any record by entering EMP_ID and using DELETE statement, write a new form. Put EMP_ID into a control block (i.e. the one that is not based on a table). Create "Delete" button and put DELETE FROM ... statement into WHEN-BUTTON-PRESSED trigger.

That would work, but the question is WHY would you want to do it that way, which is far more complicated that default Forms processing?
Re: unable to delete the record [message #541887 is a reply to message #541884] Fri, 03 February 2012 00:44 Go to previous messageGo to next message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

to resolve the above errors message:
I have filled the EMP_ID, LAST_NAME and JOB_ID it deletes the information and replaced by the entered data...

for eg;

record before delete:
emp_id firstname last_name phone job_id salary dept_id
115 steven J 55555 10 10000 2


if i try to delete the record of "115" by filling the form

emp_id=115 last_name=bresnen job_id=15

After deletion...
emp_id firstname last_name phone job_id salary dept_id
115 bresnen 15


here, the previous information was deleted and new data inserted automatically...


**************WHY THE INSERT was done***********
Re: unable to delete the record [message #541888 is a reply to message #541887] Fri, 03 February 2012 00:53 Go to previous messageGo to next message
Littlefoot
Messages: 21818
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I told you in my previous message. COMMIT did that.
DELETE FROM ... you wrote in WHEN-BUTTON-PRESSED deleted a record that existed in a table.
Values you entered manually into form items were inserted into a table upon COMMIT.

You are doing things in a wrong manner. Stop doing that and everything will be OK.

Rely on built-in Forms features as much as possible, don't reinvent the wheel.
Re: unable to delete the record [message #541891 is a reply to message #541887] Fri, 03 February 2012 01:07 Go to previous message
Srini_DEV
Messages: 20
Registered: January 2012
Location: India
Junior Member

Finnal I got the clarification on this...

thanks everyone Razz
Previous Topic: Call report from Form 10g.
Next Topic: search for NULL fields
Goto Forum:
  


Current Time: Thu Sep 12 23:27:01 CDT 2024