Hello everyone,
My name is Akashkumar, i need to know what is the meaning or use of "select -1" and why do we need this line or query?
this is where i have found it.
USE [TISDB]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER procedure [dbo].[usp_SubContractor_insert]
(
@SCCode int,
@SCCodeNumber varchar(50),
@SCName varchar(50),
@Sc_StartingDate varchar(11),
@Sc_EndingDate varchar(11),
@Sc_Address varchar(500),
@Sc_WorkName varchar(200),
@Sc_WorkOrderNo varchar(200),
@Sc_Stno varchar(50),
@Sc_vatno varchar(50),
@Sc_Estimatetime varchar(50),
@Sc_EstimateAmount varchar(50),
@Pancardno varchar(50),
@mono numeric(18,0),
@userid varchar(10),
@Tendercode int,
@LocationID varchar(10),
@Sync_Status bit,
@Layer varchar(10)
)
As
if @SCCode=0
begin
if not exists (select * from SubCont_Master where SCCode=@SCCode And SCCodeNumber=@SCCodeNumber And SCName=@SCName)
begin
select @SCCode=isnull(max(SCCode),0)+1 from [SubCont_Master]
INSERT INTO [SubCont_Master] ([SCCode],[SCCodeNumber],[SCName],[Sc_StartingDate], [Sc_EndingDate],[Sc_Address], [Sc_WorkName], [Sc_WorkOrderNo], [Sc_STno], [Sc_VatNo], [Sc_Estimatetime], [Sc_EstimateAmount],[pancardno],[mono] ,[UserId],[Tendercode],[LocationID] ,[Sync_Status],[Layer],[Dt]) VALUES (@SCCode,@SCCodeNumber, @SCName,@Sc_StartingDate, @Sc_EndingDate,@Sc_Address, @Sc_WorkName, @Sc_WorkOrderNo, @Sc_STno, @Sc_VatNo, @Sc_Estimatetime, @Sc_EstimateAmount,@pancardno,@mono,@UserId,@Tendercode, @LocationID,@Sync_Status,@Layer,GETDATE())
select @SCCode
end
else
begin
select -1
end
end
else
begin
if not exists (select * from SubCont_Master where SCName =@SCName And SCCodeNumber=@SCCodeNumber And Tendercode = @Tendercode and SCcode<>@SCCode)
begin
Update SubCont_Master Set [SCCodeNumber]=@SCCodeNumber,
[SCName] = @SCName,
[Sc_StartingDate] = @Sc_StartingDate,
[Sc_EndingDate]=@Sc_EndingDate,
[Sc_Address] =@Sc_Address,
[Sc_WorkName]=@Sc_WorkName,
[Sc_WorkOrderNo]=@Sc_WorkOrderNo,
[Sc_Stno]=@Sc_Stno,
[Sc_vatno]=@Sc_vatno,
[Sc_Estimatetime]=@Sc_Estimatetime,
[Sc_EstimateAmount]=@Sc_EstimateAmount,
[pancardno]=@pancardno,
[mono]=@mono,
[UserId]=@UserId,
[Tendercode]=@Tendercode,
[LocationID] =@LocationID,
[Sync_Status] =@Sync_Status,
[Layer] =@Layer,
[Dt]=GetDate() where SCCode=@SCCode
select @SCCode
end
else
begin
select -1
end
end
Thank you.