I have written the following Stored Procedure and need input as to what could be wrong with my coding or is there a possibility that not getting the correct results is not in the procedure at all? -
ALTER PROCEDURE spIssueScannedTickets
-
@iEventID int,
-
@MemberNum nvarchar(12),
-
@BatchSize int,
-
@FirstNumber nvarchar(12),
-
@LastNumber nvarchar(12),
-
@SlotsBalance int,
-
@TableBalance int,
-
@BonusBalance int,
-
@UserID int
-
AS
-
DECLARE @Result int
-
SET @Result = 0
-
BEGIN TRANSACTION
-
if (@SlotsBalance>0)
-
INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID)
-
VALUES (GETDATE(),@iEventID,@MemberNum, 'Slots', @SlotsBalance, 0, @UserID)
-
SELECT @Result = @@error IF @Result <> 0 BEGIN ROLLBACK TRANSACTION RETURN @Result END
-
-
if (@TableBalance>0)
-
INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID)
-
VALUES (GETDATE(),@iEventID,@MemberNum, 'Tables', @TableBalance, 0, @UserID)
-
SELECT @Result = @@error IF @Result <> 0 BEGIN ROLLBACK TRANSACTION RETURN @Result END
-
-
if (@BonusBalance>0)
-
INSERT INTO TicketsIssued (Date, EventID, MemberNumber, EarnType, NumTicketsIssued, Turnover, UserID)
-
VALUES (GETDATE(),@iEventID,@MemberNum, 'Bonus', @BonusBalance, 0, @UserID)
-
SELECT @Result = @@error IF @Result <> 0 BEGIN ROLLBACK TRANSACTION RETURN @Result END
-
-
INSERT INTO BundlesIssued (MemberNumber, EventID, BundleSize, FirstNumber, LastNumber, DateIssued, UserID, Invalid)
-
VALUES (@MemberNum, @iEventID, @BatchSize, @FirstNumber, @LastNumber, GETDATE(), @UserID , 0x00)
-
SELECT @Result = @@error IF @Result <> 0 BEGIN ROLLBACK TRANSACTION RETURN @Result END
-
-
COMMIT TRANSACTION
-
SELECT @Result = @@error IF @Result <> 0 RETURN @Result
-
SET @Result = @BatchSize RETURN @Result
-
GO
-
As far as I am aware what I have written should give an "all or nothing situation". In other words either all tables are updated or none are.
Comments please.
1 1191 ck9663 2,878
Recognized Expert Specialist
Looks like it's rolling back.
Try executing it as a series of t-sql first. Define the parameters as variables and hard code the values.
Try putting a PRINT 1 or SELECT 1 (then SELECT 2..then 3...then 4) on all rollback. You'll see where it's falling. Like DEBUG mode
-- CK
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Ralph Cramden |
last post by:
I'm writing a VB6 app which calls several stored procedures on my SQL
Server DB.
The first stored procedure must complete its inserts before the second
stored procedure can query the modified table for its results. My
problem is that
the second stored procedure occasionally returns a different result
set, acting as if the first stored procedure didn't complete (or
didn't run).
|
by: dawatson833 |
last post by:
I have several stored procedures with parameters that are defined with
user defined data types. The time it takes to run the procedures can
take 10 - 50 seconds depending on the procedure.
If I change the parameter data types to the actual data type such as
varchar(10), etc., the stored procedure takes less that a second to
return records. The user defined types are mostly varchar, but some
others such as int. They are all input type...
|
by: marc |
last post by:
I've been developing a stored procedure that uses a user defined
function in the query portion of the procedure. However, since the end
product needs to allow for dynamic table names, the UDF will not work.
I've been trying to get this to work with converting the UDF to a
procedure, but I'm having no luck.
Here is the background on what I'm trying to accomplish. I need to
perform a sub-identity on a table, I have the normal identity set,...
|
by: microsoft.private.windows.netserver.setup |
last post by:
I have a very strange thing occurring in the program. I have a dataset
retrieved from a stored procedure that just select * from a table. I then
try to use the SQlCommandBuilder on the dataset, and fails. I try the same
select statement directly and not using a stored procedure and use
SQLCommandBuilder, the program works. This is a ASP.net page, and I am
stumped. I would like to use the stored procedure rather than controlling
it in...
|
by: Jack Black |
last post by:
Help!! I'm trying to call a custom stored procedure from a VB.Net
code-behind page in an ASP.Net application, and I keep getting an
error with no real helpful info...
Basically, I'm accepting a username and password from a front-end, and
performing a simple INSERT into a SQL Server table via a custom stored
procedure in the database. All privileges are fine, and the stored
procedure works fine (inserts records perfectly; tested with...
| |
by: Problematic coder |
last post by:
The intention is to call a stored proceedure which sets flags in the
database, this requires no parameters and the page does not need an
output from the stored proceedure, though is this is necessary I could
change that.
Here is the code I am using:
Dim objcom2 = New Data.OracleClient.OracleCommand
With objcom2
.Connection = objcnn
|
by: Dennis |
last post by:
Hi
I'm trying to alter my stored procedure to take a parameter for the
Database Name, but as usual the syntax is killing me.
Thanks for any help
Dennis
'----------------------------------------------------------------------------------------------------------
Before - This Works without a paramater
'----------------------------------------------------------------------------------------------------------
|
by: bbawa1 |
last post by:
I have the following stroed procedue. But whebnnI execute it it gives
me following errors.
Could you please tell me what is wrong
Msg 156, Level 15, State 1, Procedure usp_DateDiff, Line 43
Incorrect syntax near the keyword 'SELECT'.
Msg 156, Level 15, State 1, Procedure usp_DateDiff, Line 47
Incorrect syntax near the keyword 'select'.
Msg 156, Level 15, State 1, Procedure usp_DateDiff, Line 52
Incorrect syntax near the keyword...
|
by: sweatha |
last post by:
Hi
I have to convert the following query into stored procedure
"select DoctorMaster.FirstName+''+DoctorMaster.MiddleName+''+DoctorMaster.LastName as DoctorsName,DoctorMaster.DRID,DoctorMaster.Gender,DrClinicDetails.Address,DoctorMaster.Telephone+','+DoctorMaster.Mobile as Phone,PrimaryTitle.PrimaryTitle from DoctorMaster,DrClinicDetails,PrimaryTitle,Specialty where DoctorMaster.FirstName like '" + obj.ToString() + "%' or...
|
by: priyamtheone |
last post by:
I'm trying to create a stored procedure in MSSQL Server 2005 that'll perform the following jobs:
1) Create a login.
2) Create an user in TestDB database for the login created in step 1.
3) Assign the role 'db_generaluser' to the user created in step 2.
The login name and password for the login to be created will be supplied from externally through input parameters. If this procedure executes successfully it returns 0 else 1 to the caller...
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |