March 26, 2008 at 12:14 am
Hi guys,
I have a table with following columns and records.
Empid Empname Phone Flag
14 Rajan 2143 1
16 Balan 4321 1
22 Nalini 3456 0
23 Ganesh 9543 0
My requirement is when i delete a record based on empid that record's flag should be set to 1 if it is 0.Actually it should not delete. It should update the flag value. If the flag is already 1 for that particular empid then it should remain as it is. After deletion when i issue "select * from table name", the deleted record (update record) should not be displayed. Only the records with the flag value 0 alone should be displayed in the select statement.
Pls provide me the full stored procedure code
Thanx
March 26, 2008 at 12:52 am
Hi,
My suggestion would be to use an INSTEAD OF DELETE trigger. Write it in such a way, that it updates the record instead of deleting the record. And when it comes to retireving the data just you a simple SELECT statement with the WHERE clause to get only the required records.
Regards
March 26, 2008 at 3:56 am
Just update the darn flag to 1 regardless.
If it's a 0 then it becomes 1.
If it's a 1 then it's still a 1.
No need to be fancy with triggers and stuff, it only complicates it.
/Kenneth
March 26, 2008 at 4:06 am
Also asked and answered here
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=99666
N 56°04'39.16"
E 12°55'05.25"
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply