Home » Developer & Programmer » Forms » Flag Set
Flag Set [message #269685] Mon, 24 September 2007 01:52 Go to next message
nayana
Messages: 33
Registered: August 2007
Location: Bangalore
Member
Hi,

Created one table and it contains following columns:
empno, name , mailid,DOJ,location etc.

and also created one form to enter these columns data. Form contains add/delete/update buttons.

When i select delete button it will delete entire row from the table. But I want data in case any employee rejoined. I heard that its possible using flag set, but i don't know the commands for that. Please advice.

Thanks in advance.

Regards,
Nayana
Re: Flag Set [message #269687 is a reply to message #269685] Mon, 24 September 2007 02:01 Go to previous messageGo to next message
Arju
Messages: 1554
Registered: June 2007
Location: Dhaka,Bangladesh. Mobile:...
Senior Member

Flag Set is nothing but up to you.
Re: Flag Set [message #269695 is a reply to message #269687] Mon, 24 September 2007 02:24 Go to previous messageGo to next message
nayana
Messages: 33
Registered: August 2007
Location: Bangalore
Member
Hi,

Could please explain me with examples.

Thanks,
Nayana
Re: Flag Set [message #269698 is a reply to message #269695] Mon, 24 September 2007 02:38 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Add a field to the table called 'deleted_fl'. Then write an 'on-delete' trigger which will intercept the 'delete' command and update the row so that the flag is set to 'Y' (or something).

Chaneg the 'default_where' so that it contains something like "nvl(deleted_fl,'N') <> 'Y'". This way your 'deleted' entries will not be displayed.

David
Re: Flag Set [message #269739 is a reply to message #269698] Mon, 24 September 2007 06:37 Go to previous messageGo to next message
nayana
Messages: 33
Registered: August 2007
Location: Bangalore
Member
Hi,

Thanks a Lot!

Used following code.

create or replace trigger "EMP_DAYS_T1"
AFTER
delete on "EMP_DAYS"
begin
update emp_days set deleted_fl='Y' where empno=206;
end;



But this trigger is only for one employee (i.e 206).So I used :

create or replace trigger "EMP_DAYS_T1"
AFTER
delete on "EMP_DAYS"
begin
update emp_days set deleted_fl='Y' where empno=:new.empno;
end;


But the above code gives Error:
ORA-04082: NEW or OLD references not allowed in table level triggers 



Could you please let me know why?

Regards,
Nayana
Re: Flag Set [message #269751 is a reply to message #269739] Mon, 24 September 2007 07:20 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
You should try this in a row level trigger.

By
Vamsi
Re: Flag Set [message #269759 is a reply to message #269751] Mon, 24 September 2007 07:44 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
... and suffer from the mutating table error.

David told you to use the ON-DELETE trigger - it is a form trigger, not database trigger!
Re: Flag Set [message #269760 is a reply to message #269751] Mon, 24 September 2007 07:51 Go to previous messageGo to next message
nayana
Messages: 33
Registered: August 2007
Location: Bangalore
Member
Hi,

Thanks a Lot Vamsi.

Its working!!!

Regards,
Nayana
icon11.gif  Re: Flag Set [message #269761 is a reply to message #269759] Mon, 24 September 2007 07:53 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Oops!! today is a bad day for me.
Many overlooks. Mad Didn't notice the table name is same as the table, on which the DML has written.

By
Vamsi
Re: Flag Set [message #269762 is a reply to message #269760] Mon, 24 September 2007 07:55 Go to previous messageGo to next message
vamsi kasina
Messages: 2107
Registered: October 2003
Location: Riyadh, Saudi Arabia
Senior Member
Quote:
Its working!!!
Really?
Did you compile the trigger? (or) Isn't it giving run time errors?

By
Vamsi
Re: Flag Set [message #269765 is a reply to message #269762] Mon, 24 September 2007 08:01 Go to previous messageGo to next message
nayana
Messages: 33
Registered: August 2007
Location: Bangalore
Member
Hi Vamsi,


Oh!!

 successfully compiled 
.

But when I tried to delete the record no flag set.



Razz
Nayana
Re: Flag Set [message #269828 is a reply to message #269765] Mon, 24 September 2007 15:15 Go to previous messageGo to next message
Littlefoot
Messages: 20901
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
So, what did you, actually, do? Which trigger did you create? How does it look like?

If it was a database trigger, form will compile successfully as it didn't do anything with the trigger (yet). It would fail during runtime.

If it was a form trigger, what did you put in it so that it doesn't work? How do you know it doesn't work? Did you COMMIT changes you've made in order to make those changes permanent (including setting the flag)?
Re: Flag Set [message #269849 is a reply to message #269828] Mon, 24 September 2007 19:32 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
As part of the 'delete' processing cycle the form will have done a 'commit'. So you need to make sure that the database trigger has been removed and that your form logic is flowing as you have anticipated.

David
Re: Flag Set [message #270449 is a reply to message #269849] Wed, 26 September 2007 22:35 Go to previous message
nayana
Messages: 33
Registered: August 2007
Location: Bangalore
Member

Thanks a Lot!

Razz
Nayana
Previous Topic: problem with a running form
Next Topic: how to change text, on top of the forms
Goto Forum:
  


Current Time: Sat Dec 10 14:48:28 CST 2016

Total time taken to generate the page: 0.04942 seconds