Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to select notice of a trigger

Author  Topic 

upani
Starting Member

12 Posts

Posted - 2010-04-29 : 23:46:06

Hi,
I write a java programming that when exception occurs, it will call the responsible trigger'notices
Ex:
create trigger on tableA for insert
if(abcd...)
begin
print('aaaaa')
rollback transaction
end
if(xyz....)
begin
print('bbbbbb')
rollback transaction
else
print('ccccccccc')
rollback transaction

So how can i select notice 'aaaaa','bbbbb', or 'ccccc' of that trigger when incorrect insertion occurs?
And i have another question is how to create trigger that check the data i want to insert is which type? Char or datetime....?
Please show me,
Thanks!



visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-30 : 01:43:33
you mean you need help on logic which raises error messages?

for datatype check, you need make column as varchar and then do check using functions like ISDATE(),ISNUMERIC() etc and raise appropriate errors

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

upani
Starting Member

12 Posts

Posted - 2010-04-30 : 02:27:35
Yes! Can you help me?
Thank you!
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-04-30 : 02:39:42
what according to you is incorrect insertion?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -