473,394 Members | 1,932 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Something I'm missing with condition?

Hi all,

I have the following snippet of code in my trigger
[HTML]SELECT @Currentqty = qtyonHand FROM tblProduct WHERE ProductID = @Product
SELECT @CurrentReorder = ReorderPoint FROM tblProduct WHERE ProductID = @Product
IF (@Currentqty < @CurrentReorder)
BEGIN
--PRINT 'Update will fire'
BEGIN TRANSACTION ProductUpdate
UPDATE tblProduct
SET qtyonHand = qtyonHand + @OrderAmt
WHERE ProductID = @Product
COMMIT TRANSACTION ProductUpdate
END
ELSE
BEGIN
PRINT 'No need to order, Plenty of items are on hand.'
END
GO[/HTML]


The following is what I'm using to add 50 ites to the qtyonHand

[HTML]UPDATE tblProduct
SET qtyonHand = qtyonHand + 50
WHERE ProductID = 1[/HTML]

What ends up happening is that the trasaction is actually firing and thus even if the condition (say 100<50) is False, 50 is still added then the PRINT fires.
What am I not seeing?

Tnx
Mar 3 '07 #1
0 855

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: SB | last post by:
This while loop keeps repeating even when a correct character is entered.... cout<<endl<<"What day would you like to schedule the appointment?"<<endl; cout<<endl<<"Enter 'M' for Monday, 'T' for...
7
by: Dave | last post by:
I'm fairly new to C# and I must be misunderstanding something: I have created a standard web ASP.NET web application project and put data controls into it. Right at the top is a whole set of...
44
by: Tolga | last post by:
As far as I know, Perl is known as "there are many ways to do something" and Python is known as "there is only one way". Could you please explain this? How is this possible and is it *really* a...
2
by: Beowulf | last post by:
The problem: I'm updating a report to be "multi-language" capable. Previously, any items that had text associated with them were unconditionally pulling in the English text. The database has...
5
by: le0 | last post by:
Hello guys, Im really having a hard time doing this, I have a record set with the ItemNo field with the data type as Text. In the record that I have, I want to find the missing number in the...
3
by: danceli | last post by:
After loading the BCP files that are created during the trigger/ reporting events I've noticed that the data in the table is missing records. I've also noticed that the missing records (records in...
8
sammyboy78
by: sammyboy78 | last post by:
I'm trying to create a class "WeeklyPay" that contains the methods that class "WeeklyPayTest" will use to compute the weekly pay of an employee when the user inputs employee name, hours worked, and...
33
by: Stef Mientki | last post by:
hello, I discovered that boolean evaluation in Python is done "fast" (as soon as the condition is ok, the rest of the expression is ignored). Is this standard behavior or is there a compiler...
11
by: MC | last post by:
I have a couple of customers who are using a program that deserializes an XML file, and on some files, the program fails to see the content of the file -- treats it as zero length and reports "root...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.