Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CREATE PROCEDURE dbo.addCustomer
- -- Add the parameters for the stored procedure here
- @flag bit output, --return 1 for success and 0 for fail
- @Customer_ID varchar(50),
- @sales_region varchar(50),
- @Items_Recieved varchar(max),
- @Hual_ID varchar(50)
- AS
- BEGIN
- BEGIN TRANSACTION
- BEGIN TRY
- INSERT into dbo.Customer(Customer_ID,Sales_region, Items_Recieved, Hual_ID)
- values(@Customer_ID,@sales_region, @Items_Recieved, @Hual_ID
- set @flag=1;
- IF @@TRANCOUNT>0
- BEGIN commit TRANSACTION;
- END
- END TRY
- BEGIN CATCH
- IF @@TRANCOUNT>0
- BEGIN rollback TRANSACTION;
- END
- set @flag=0;
- END CATCH
- END
- GO
- CREATE PROCEDURE dbo.addCustomer
- -- Add the parameters for the stored procedure here
- @flag bit output, --return 1 for success and 0 for fail
- @Customer_ID varchar(50),
- @sales_region varchar(50),
- @Items_Recieved varchar(max),
- @Hual_ID varchar(50)
- AS
- BEGIN
- SET NOCOUNT ON;
- BEGIN TRY
- BEGIN TRANSACTION
- INSERT INTO dbo.Customer(Customer_ID,Sales_region, Items_Recieved, Hual_ID)
- VALUES(@Customer_ID,@sales_region, @Items_Recieved, @Hual_ID)
- COMMIT TRANSACTION;
- SET @flag=1;
- END TRY
- BEGIN CATCH
- IF (@@TRANCOUNT > 0)
- BEGIN
- ROLLBACK TRANSACTION;
- END
- SET @flag=0;
- -- Utilise your other Error Functions to get detailed
- -- Information about the Error, function like
- -- ERROR_LINE(), ERROR_MESSAGE(), ERROR_NUMBER()....
- END CATCH
- END
- GO
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement