sql - Data did not display in Stored Procedure -
i'm new here, please correct me if ask wrongly.
i did stored procedure, however, when execute it, errornumber
, spname
, errormessage
came out.
can please explain me did wrong? thanks.
this executed:
exec dbo.sppartmasterextension @domainsite = 'bris0011', @itemno='1002424251911', @itemdescription = 'new item', @itemvalue = '1', @itemum = '1', @employeeno = 'nn031097'
this stored procedure:
create procedure [dbo].[sppartmasterextension] @domainsite nvarchar(8), @itemno nvarchar(18), @itemdescription nvarchar(50), @itemvalue nvarchar(50), @itemum nvarchar(50), @employeeno nvarchar(18) begin declare @errorno integer = '', @spname nvarchar(max) = '', @errormessage nvarchar(max) = '' declare @itemumoriginal nvarchar(50) if exists (select id partmasterextension itemno = @itemno , itemdescription = @itemdescription , domainsite =@domainsite) begin update partmasterextension set itemvalue = @itemvalue, itemum = @itemum, datetimestamp = getdate(), employeeno = @employeeno itemno = @itemno , itemdescription = @itemdescription , domainsite = @domainsite end else begin begin try insert partmasterextension select @domainsite, @itemno, @itemdescription, @itemvalue, @itemum, getdate(), @employeeno end try begin catch select @errorno = error_number(), @spname = error_procedure(), @errormessage = error_message(); end catch end select @errorno errornumber, @spname spname, @errormessage errormessage; end go
if product exist, update process , then, last select. if data doesn't exist, try inserting and, if error occurs, set values variables declared, before returning it.
what expecting stored procedure?
Comments
Post a Comment