TdC
Trem's hunky sex love muffin
- Joined
- Dec 20, 2003
- Messages
- 30,925
mkay, I'm working on a trigger for le school stuffs and I am literally going insane:
Ok I am freaking out a bit, because when I run an INSERT on the table this trigger lives in, then I get 4 1's printed and then the error handling. That means that the final IF() evaluated to zero, which is simply not true given the code above saying otherwise. I also tried with SELECT that goes with the IF() surrounded by ISNULL(<the select>,0) and that ofc is just desperation given that count will always return a number.
So...anyone know what the heck is going on?
Code:
SELECT COUNT(*) FROM inserted <--- is OK value = 1
SELECT COUNT(*) FROM inserted <--- is OK value = 1
INNER JOIN Vlucht v
ON inserted.vluchtnummer = v.vluchtnummer
SELECT COUNT(*) FROM inserted <--- is OK value = 1
INNER JOIN Vlucht v
ON inserted.vluchtnummer = v.vluchtnummer
INNER JOIN IncheckenVoorBestemming ivb
ON v.luchthavencode = ivb.luchthavencode
SELECT COUNT(*) FROM inserted <--- is OK value = 1
INNER JOIN Vlucht v
ON inserted.vluchtnummer = v.vluchtnummer
INNER JOIN IncheckenVoorBestemming ivb
ON v.luchthavencode = ivb.luchthavencode
INNER JOIN IncheckenBijMaatschappij ibm
ON inserted.balienummer = ibm.balienummer
IF (SELECT COUNT(*) FROM inserted <--- is NOT OK value = 0
INNER JOIN Vlucht v
ON inserted.vluchtnummer = v.vluchtnummer
INNER JOIN IncheckenVoorBestemming ivb
ON v.luchthavencode = ivb.luchthavencode
INNER JOIN IncheckenBijMaatschappij ibm
ON inserted.balienummer = ibm.balienummer) = 0
<some error stuff here>
Ok I am freaking out a bit, because when I run an INSERT on the table this trigger lives in, then I get 4 1's printed and then the error handling. That means that the final IF() evaluated to zero, which is simply not true given the code above saying otherwise. I also tried with SELECT that goes with the IF() surrounded by ISNULL(<the select>,0) and that ofc is just desperation given that count will always return a number.
So...anyone know what the heck is going on?