Forums
This topic is locked
backup &restore data by procedure
Posted 07 Dec 2008 06:03:47
1
has voted
07 Dec 2008 06:03:47 saraa samir posted:
hii need to create a procedure to backup and restore data
for table with 3 coulmns(name ,phone ,ishere as boolean)
&
and another procedure delete
but when i delete name the coulmn ishere value changes into false
also on delete insert this deleted name to table(DataBackUP) and if this table doesnot exist create it
i am trying to solve them so can anybody help????
thank u
Replies
Replied 10 Dec 2008 19:04:35
10 Dec 2008 19:04:35 Roddy Dairion replied:
I understand the backup and restore data.
BUT whats with the delete???
Can you explain more clearly what you're trying to achieve thank you.
BUT whats with the delete???
Can you explain more clearly what you're trying to achieve thank you.
Replied 11 Dec 2008 01:34:10
11 Dec 2008 01:34:10 saraa samir replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
I understand the backup and restore data.
BUT whats with the delete???
Can you explain more clearly what you're trying to achieve thank you.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Hi Roddy
i need to create a procedure that delete .
when i delete a name from the table the coulmn (Is Here) which takes values (true / false)
changes its value to false as the name is no longer in the table
also
i need to save these deleted records in another table . this new table works as abackup
can u help ? & as for the rest forget about it
Thank u
I understand the backup and restore data.
BUT whats with the delete???
Can you explain more clearly what you're trying to achieve thank you.
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Hi Roddy
i need to create a procedure that delete .
when i delete a name from the table the coulmn (Is Here) which takes values (true / false)
changes its value to false as the name is no longer in the table
also
i need to save these deleted records in another table . this new table works as abackup
can u help ? & as for the rest forget about it
Thank u
Replied 06 Jan 2009 20:00:18
06 Jan 2009 20:00:18 brad baker replied:
This makes no sense as if you "delete" the row you cant update the is here field since it would no longer be there. If thats the case then make a trigger thats before delete.
For mysql I think its something like this: This should copy the row you are deleting to the old/current table and put it in the new table and then delete the row from the old/current table.
DROP TRIGGER trig1;
DELIMITER //
CREATE TRIGGER trig1
BEFORE DELETE ON old_table FOR EACH ROW
BEGIN
INSERT INTO new_table select from old_table WHERE current_id=OLD.current_id;
END;
//
DELIMITER ;
For mysql I think its something like this: This should copy the row you are deleting to the old/current table and put it in the new table and then delete the row from the old/current table.
DROP TRIGGER trig1;
DELIMITER //
CREATE TRIGGER trig1
BEFORE DELETE ON old_table FOR EACH ROW
BEGIN
INSERT INTO new_table select from old_table WHERE current_id=OLD.current_id;
END;
//
DELIMITER ;