Updating 2 tables simultaneously
Hello everyone,
I wanna know that how we can modify two tables at once.
That is what I am trying to do is that there are 3 tables
Category (Id (Primary key), Name)
Message (Id (Primary key), CategoryId (Foreign key), Subject (Not Null), Owner) and Reply (Id (Primary key), MessageId (Foreign key), Subject (Null allowed), Body, Owner)
Here Message table contains only Subject field which is different from the subject field of Reply table.
Now whenever a user wants to post a message/reply in specific category then it should first be checked that it is new message or existing message in that category.
If it is new then the subject filed should go in the Message table and Id should be returned and sent back to the Reply table and stored in the MessageId field, and body field and MessageId should then be stored in Reply table.
And if it is not new message then all messages/replies should be stored in the Reply table only for that specific message for which replies are being posted.
So please can any one tell me the procedure or code snippet that how these 2 tables can be accessed simultaneously and achieve the above functionality.
Many many thanks in advance.
|