March 27, 2009 at 11:27 pm
hi frends
i m doing proj on air traffic control
i hav a table like
plane_position(Flight_no varchar, DateTime datetime, Longitude float, Latitude float, Altitude float)
condition is i wanna create a trigger which will chek following conditions while insertimg a new record
1. There are at the two records present at a time corresponding to any Flight_no
2. While adding a record for some flight_no, the oldest of the two records already present is deleted according to value of datetime field
3. if less then 2 records for that flight_no are present then then add directly
plz help me frends, its urgent
March 30, 2009 at 6:34 am
First I need to confirm that you are using SQL Server 2005 Compact Edition as that is the forum you have posted in.
I would not recommend doing this in a trigger. I would recommend creating a stored procedure that does all the steps that you need accomplished. In my opinion this will server your purposes better than a trigger. It also can be more secure. If you cannot use a stored procedure, I'd do my verification in the business layer of the application.
If you insist on doing this in a trigger check out this article[/url] for getting started. Based on the information you have provided, I would recommend using an INSTEAD OF trigger in this case.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 1, 2009 at 12:53 am
thaks for suggestion.
i hav created that trigger 2 days before
any ways thanks for showing interest
ALSO PLZ TELL ME THAT WHY A PROCEDURE USAGE IS SECURE THAN THE TRIGGER
PLZ REPLY FOR THIS AND THANK U ONCE AGAIN
April 1, 2009 at 12:40 pm
Stored procedures are not available for SQL Server CE.
But you already knew that.
April 1, 2009 at 12:53 pm
Using stored procedures means you do not have to grant access to the tables and, IMO, this is better for security than allowing direct able access.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
April 1, 2009 at 11:49 pm
Thanks
April 2, 2009 at 12:18 am
Stored procedures are also easier to debug than a trigger and can handle multiple table modifications better with the help of transactions.
As long as your trigger does not get too complicated you should be fine. As pointed out earlier use Instead of triggers. You will have to insert into the table from your trigger if the check conditions are satisfied.
"Keep Trying"
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply