472,986 Members | 3,035 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

output parameters

I have a stored proc that inserts a record into a table and sets three output parameter values. There is a contition that then inserts a record into a second table. If this insert does not occur, my calling application gets the output values, but if the conditional insert does occur, the output values are empty. Can anyone tell me why? Here is the code:

CREATE Procedure usp_IMDetails_InsertTempDtl
@Orht_Id int,
@Pdt_id int,
@Ordt_UOM varchar(10),
@Ordt_UnitsOrdered decimal(9,2),
@Ordt_Cost decimal(9,2),
@Ordt_Price decimal(9,2),
@Ordt_DiscountPct decimal(9,2),
@Ordt_DiscountAmt decimal(9,2),
@Ordt_ExtendedAmt decimal(9,2),
@Ordt_AddDescText varchar(50),
@CreatedBy varchar(50),
@Ordt_Id int output,
@Pdt_ProductSKU varchar(25) output,
@Pdt_ProdDesc varchar(60) output
AS

BEGIN

BEGIN TRANSACTION
INSERT INTO ordt_OrderDtl (
Orht_Id,
Pdt_Id,
Ordt_UOM,
Ordt_UnitsOrdered,
Ordt_Cost,
Ordt_Price,
Ordt_DiscountPct,
Ordt_DiscountAmt,
Ordt_ExtendedAmt,
Ordt_CreatedBy,
Ordt_CreatedDate )
VALUES (
@Orht_Id,
@Pdt_Id,
@Ordt_UOM,
@Ordt_UnitsOrdered,
@Ordt_Cost,
@Ordt_Price,
@Ordt_DiscountPct,
@Ordt_DiscountAmt,
@Ordt_ExtendedAmt,
@CreatedBy,
GETDATE() )

IF @@ERROR <> 0
BEGIN
ROLLBACK TRANSACTION
RETURN -1
END

Set @Ordt_Id = @@Identity
Select @Pdt_ProductSKU = pdt_productsku, @Pdt_ProdDesc = pdt_proddesc
From pdt_product
Where pdt_Id = @Pdt_Id

IF LEN(@Ordt_AddDescText) > 0
BEGIN

INSERT INTO nts_notes (
NTS_FileAssn,
NTS_ParTblId,
NTS_Type,
NTS_Text,
NTS_Destination,
NTS_CreatedBy,
NTS_CreatedDate)
VALUES (
'Ordt',
@Ordt_Id,
1,
@Ordt_AddDescText,
0,
@CreatedBy,
GETDATE())

IF @@ERROR <> 0
BEGIN
ROLLBACK TRANSACTION
RETURN -2
END
END

COMMIT TRANSACTION
RETURN 1

END
GO
Jun 10 '06 #1
0 8730

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

Similar topics

1
by: Bari Allen | last post by:
I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First varchar(80) OUTPUT ,...
5
by: vivienne.netherwood | last post by:
I am developing an Access Project front end with a SQL server database. I have written a stored procedure that returns a record set and also a value via an output parameter. The procedure is as...
4
by: Janaka | last post by:
Hi this is kind of an ASP.NET/ADO.NET question. I've got a stored procedure on SQL Server that returns a results set. It also sets 3 output parameters in a seperate Select statement. When...
2
by: Bari Allen | last post by:
ASP Classic question: I have a Stored procedure in SQL, that works, when tested in SQL, with one input & several output parameters, as follows: CREATE PROCEDURE myProcedure @MyID int , @First...
3
by: juststarter | last post by:
Hello all, I am executing a stored procedure (on an SQL Server) using ODBC but i can't get the output parameter's value on the client. The stored proc has 3 parameters ,2 of them are input and 1...
1
by: Joe Van Meer | last post by:
Hi all, I have an app that currently runs through 3 seperate stored procedures each returning a count of records. What I would like to do is combine these calls into one call, however I am...
1
by: Garth Wells | last post by:
Using an example in the Jan 2006 release of the Enterprise Library, I came up with the code shown below to create a DAL method for returning several columns of a single row. I place the output...
6
by: c676228 | last post by:
Hi everyone, I wrote a store procedure that fetch one row data in the database based on the parameter value I entered. After I created the store procedure, the store procedure code looks like...
1
by: John Bailo | last post by:
This is a my solution to getting an Output parameter from a SqlDataSource. I have seen a few scant articles but none of them take it all the way to a solution. Hopefully this will help some...
2
by: gabosom | last post by:
Hi! I've been breaking my head trying to get the output variables from my Stored Procedure. This is my SP code CREATE PROCEDURE GetKitchenOrderDetail( @idService int, --outPut Variables ...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

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.