NJC__Documentation::DB

dbo.sp_insertmodulbc23_manual

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

Name Data Type Length Description
@car varchar 26
@idx bigint 8
@nodaft varchar 100
@tgdaft date 3
@userid varchar 10

SQL Script

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
/****** Object: StoredProcedure dbo.sp_insertmodulbc23 Script Date: 12/26/2012 23:23:28 ******/
--SET ANSI_NULLS ON
--GO
--SET ANSI_WARNINGS ON
--GO
--SET QUOTED_IDENTIFIER ON
--GO
CREATE PROCEDURE dbo.sp_insertmodulbc23_manual
 @car as varchar(26), @idx as bigint, @nodaft varchar(100),@tgdaft date,  @userid varchar(10)

AS
BEGIN
   declare @countdata int
   declare @detilitemcount int

   select @countdata = COUNT(*) from tbl_bc_in_hdr where id_bc_in_hdr = @idx and status is null 
   
   IF @countdata <> 1 
   BEGIN
 select '01' as status, ' DATA Not Found or Already Exist' as hasil
 return
   END
--BEGIN TRY
-- BEGIN TRANSACTION
-- insert header
 --SET ANSI_NULLS ON
 --SET ANSI_WARNINGS ON
 
 
 declare @now datetime
 set @now = GETDATE()

 UPDATE tbl_bc_in_hdr set CAR = @car,[BC23No]=@nodaft,[BC23Tg]=@tgdaft, Status = '00', statusdok='DATA PROCESSED' where id_bc_in_hdr = @idx
 UPDATE tbl_bc_in_dtl set CAR = @car where id_bc_in_hdr = @idx
 UPDATE dbo.tbl_bc_in_dok set CAR = @car where id_bc_in_hdr = @idx
 UPDATE dbo.tbl_bc_in_con set CAR = @car where id_bc_in_hdr = @idx
 
 UPDATE dbo.tbl_bc_in_dtl_partnumber set CAR = @car where id_bc_in_hdr = @idx
 
 INSERT INTO tbl_bc_in_hdr_h_status
          (id_bc_in_hdr, statusdok, status_date
          ,[create_by]
    ,[create_date]
    ,[update_by]
    ,[update_date])
 VALUES     (@idx, (select top 1 statusdok from tbl_bc_in_hdr where id_bc_in_hdr = @idx), @now
  ,@userid
  ,@now
  ,@userid
  ,@now
 )
 
    
 select '00' as status, ' Sukses'+' NO AJU BARU: '+@car as hasil
 
--COMMIT
--END TRY
-- BEGIN CATCH
-- -- Whoops, there was an error
-- IF @@TRANCOUNT > 0
-- ROLLBACK

-- -- Raise an error with the details of the exception
-- DECLARE @ErrMsg nvarchar(4000), @ErrSeverity int
-- Set @ErrMsg = ERROR_MESSAGE()
-- set @ErrSeverity = ERROR_SEVERITY()
-- select @ErrMsg as hasil,@ErrSeverity as status
-- RAISERROR(@ErrMsg, @ErrSeverity, 1)
--END CATCH
   
END
GO

Used By

No items found