Description
Properties
| Name | Value |
|---|---|
| ANSI Nulls ON | True |
| Quoted Identifier ON | True |
| Encrypted | False |
| Execute As | |
| Assembly |
Parameters
| Name | Data Type | Length | Description |
|---|---|---|---|
| @id_data_out_hdr | bigint | 8 | |
| @id_terkait | bigint | 8 | |
| @doc_out_to_id | bigint | 8 | |
| @user | varchar | 70 |
SQL Script
SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO
CREATE PROCEDURE dbo.spi_outgoing_approved
@id_data_out_hdr bigint, @id_terkait bigint, @doc_out_to_id bigint, @user varchar(70)
AS
BEGIN
if (select COUNT(*) from dbo.tbl_data_out_hdr_h_status where id_data_out_hdr = @id_data_out_hdr and [status] = 'APPROVED') <> 0
begin
select '01' as status, ' DATA HDR NOT FOUND OR DATA ALREADY APPROVED' as description
return
end
if (select COUNT(*) from tbl_data_out_hdr where id_data_out_hdr = @id_data_out_hdr) = 0
begin
select '01' as status, ' DATA NOT FOUND' as description
return
end
if (select COUNT(*) from tbl_data_out_dtl where id_data_out_hdr = @id_data_out_hdr) = 0
begin
select '01' as status, ' DATA NOT FOUND' as description
return
end
-- insert tbl_data_out_hdr_h_status
insert into tbl_data_out_hdr_h_status(
id_data_out_hdr
,status_date
,status
,create_by
,create_date
,update_by
,update_date
) values (@id_data_out_hdr, GETDATE(), 'APPROVED', @user, GETDATE(), @user, GETDATE() )
declare @id_data_out_hdr_h_status int
set @id_data_out_hdr_h_status = @@IDENTITY
-- update header dengan status dari status h header
update tbl_data_out_hdr set id_data_out_hdr_h_status = @id_data_out_hdr_h_status, approve_date=GETDATE() where id_data_out_hdr = @id_data_out_hdr
if @doc_out_to_id = 1
begin
update tbl_vgi_hdr set status = 'DATA APPROVED' where id_vgi_hdr = @id_terkait
end
select '00' as status, ' DATA APPROVED' as description
END
GO
GO
CREATE PROCEDURE dbo.spi_outgoing_approved
@id_data_out_hdr bigint, @id_terkait bigint, @doc_out_to_id bigint, @user varchar(70)
AS
BEGIN
if (select COUNT(*) from dbo.tbl_data_out_hdr_h_status where id_data_out_hdr = @id_data_out_hdr and [status] = 'APPROVED') <> 0
begin
select '01' as status, ' DATA HDR NOT FOUND OR DATA ALREADY APPROVED' as description
return
end
if (select COUNT(*) from tbl_data_out_hdr where id_data_out_hdr = @id_data_out_hdr) = 0
begin
select '01' as status, ' DATA NOT FOUND' as description
return
end
if (select COUNT(*) from tbl_data_out_dtl where id_data_out_hdr = @id_data_out_hdr) = 0
begin
select '01' as status, ' DATA NOT FOUND' as description
return
end
-- insert tbl_data_out_hdr_h_status
insert into tbl_data_out_hdr_h_status(
id_data_out_hdr
,status_date
,status
,create_by
,create_date
,update_by
,update_date
) values (@id_data_out_hdr, GETDATE(), 'APPROVED', @user, GETDATE(), @user, GETDATE() )
declare @id_data_out_hdr_h_status int
set @id_data_out_hdr_h_status = @@IDENTITY
-- update header dengan status dari status h header
update tbl_data_out_hdr set id_data_out_hdr_h_status = @id_data_out_hdr_h_status, approve_date=GETDATE() where id_data_out_hdr = @id_data_out_hdr
if @doc_out_to_id = 1
begin
update tbl_vgi_hdr set status = 'DATA APPROVED' where id_vgi_hdr = @id_terkait
end
select '00' as status, ' DATA APPROVED' as description
END
GO