473,385 Members | 1,907 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,385 software developers and data experts.

cannot exit from if else block

I am working with the following code:

[HTML]CREATE TRIGGER PurchaseOrder
ON tblPO
FOR INSERT
AS
DECLARE @Result INT
DECLARE @ODate SMALLDATETIME
DECLARE @SDate SMALLDATETIME
DECLARE @CustomerID INT
DECLARE @SuID INT
DECLARE @Fav REAL
DECLARE @STo CHAR(35)
DECLARE @SAdd CHAR(50)
DECLARE @SCit CHAR(15)
DECLARE @SProv CHAR(10)
DECLARE @SPC CHAR(10)
DECLARE @SPhone CHAR(10)
DECLARE @Acc CHAR(20)
BEGIN TRY
--BEGIN TRANSACTION PurchaseOrder
SELECT @Result = CustID FROM tblCust WHERE ((CustID=2) AND (Active>0))
--SELECT @Result
IF (@Result IS NULL)
BEGIN
PRINT 'Customer is not ACTIVE'
BREAK
END
ELSE
BEGIN
BEGIN TRANSACTION PurchaseOrder
INSERT INTO tblPO
(OrderDate, ShipDate, CustID, SupID, FavUnfav, ShipTo, ShipAddress, ShipCity, ShipProv, ShipPC, ShipPhone, AccntPO)
Values(@ODate, @SDate, @CustomerID, @SuID, @Fav, @STo, @SAdd, @SCit, @SProv, @SPC, @SPhone, @Acc)
COMMIT TRANSACTION PurchaseOrder
END
--COMMIT TRANSACTION PurchaseOrder
END TRY[/HTML]

When I run the following:
[HTML]insert into tblPO VALUES ('2007-02-04', '2007-02-06', 2, 1, 0.1, 'Intrawest Foods Ltd.', '13811 Wireless Way', 'Burnaby', 'BC', 'V6X 1W3', 6044512700, 'PO20070002')[/HTML]

The PRINT statement executes, but so does the insert as well. I'm trying to stop the insert from occuring if the value returned is NULL (which it is with the data I'm trying to insert)
Mar 3 '07 #1
0 1455

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

Similar topics

10
by: JKop | last post by:
An excerpt from the Standard: 4 Calling the function void exit(int); declared in <cstdlib> (18.3) terminates the program without leaving the current block and hence without destroying any...
22
by: Smutny30 | last post by:
Hello, I am preparing a database that will store 10 n * GBs - 100 n * GBs of data. I calculated to have 1,2 GB of bufferpools. I run the DB2 v. 8.2.1 alone on 4 GB box. I obtain : ...
10
by: lallous | last post by:
Hello, This question was asked in comp.lang.c++ and the answers involved the use of objects whose destructors are automatically called when getting out of scope, however I was expecting...
13
by: priyasmita_guha | last post by:
Here is a program- /* PROGRAM: To find the difference between two dates */ #include<dos.h> #include<stdio.h> #include<conio.h> #include<process.h> void valid_date(int,int,int); int...
26
by: Martin Jørgensen | last post by:
Hi, I don't understand these errors I get: g++ Persort.cpp Persort.cpp: In function 'int main()': Persort.cpp:43: error: name lookup of 'j' changed for new ISO 'for' scoping Persort.cpp:37:...
1
by: Perecli Manole | last post by:
Can an Exit Sub statement in a SyncLock block cause any problems with the proper release of the locked resource or affect the Monitor's waiting queue in any way? Thanks Perry
18
by: Pedro Pinto | last post by:
Hi there once more........ Instead of showing all the code my problem is simple. I've tried to create this function: char temp(char *string){ alterString(string); return string;
4
by: arashi | last post by:
I get this msg: Warning: session_start() : Cannot send session cache limiter - headers already sent (output started at /web/www/frac/users/s/students/katalog/brukere/login.php:2) in...
5
by: Just_a_fan | last post by:
I tried to put an "on error" statement in a routine and got the message that I cannot user "on error" and a lamda or query expression in the same routine. Help does not list anything useful for...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...

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.