NJC__Documentation::DB

dbo.spi_proses_inv_bc40_del

Description

Properties

Name Value
ANSI Nulls ON

True

Quoted Identifier ON

True

Encrypted

False

Execute As
Assembly

Parameters

Name Data Type Length Description
@username varchar 100
@xmldata xml -1
@typebc varchar 50

SQL Script

SET QUOTED_IDENTIFIER, ANSI_NULLS ON
GO

CREATE PROCEDURE dbo.spi_proses_inv_bc40_del
( @username varchar(100), @xmldata xml, @typebc varchar(50))
AS
BEGIN
 SET ANSI_PADDING ON
    SET CONCAT_NULL_YIELDS_NULL ON
    
    SET ANSI_NULLS ON
 SET ANSI_WARNINGS ON
 
 declare @tbltemp table(
   
    [maker] [varchar](50) NULL,
    [order_no] [varchar](50) NULL,
    [invoice_no] [varchar](50) NULL,
    [invoice_date] [date] NULL,
    [nobl] [varchar](50) NULL,
    [tglbl] [date] NULL
   )
   
   insert into @tbltemp (
    [invoice_no],
    [invoice_date],
    [maker],
    [order_no],
    [nobl],
    [tglbl]
   )
   
   SELECT
    fileds.value('invoiceno[1]', 'varchar(50)') as invoiceno,
    (case when fileds.value('invoicedate[1]', 'date') = '1900-01-01' then NULL else fileds.value('invoicedate[1]', 'date') end)  as invoicedate,
    fileds.value('kodesupplier[1]', 'varchar(50)') as maker,
    fileds.value('orderno[1]', 'varchar(50)') as orderno,
    fileds.value('nobl[1]', 'varchar(50)') as invoiceno,
    fileds.value('tglbl[1]', 'date') as invoicedate
   from @xmlData.nodes('//data/dataxml') as xmldata(fileds)
   
   
   
   BEGIN TRY
    declare @invoice_no varchar(50),@invoice_date date,@maker varchar(50),@order_no varchar(50)
    DECLARE db_cursor CURSOR FOR 
     select invoice_no, invoice_date, maker, order_no  from @tbltemp
    OPEN db_cursor  
    FETCH NEXT FROM db_cursor INTO @invoice_no,@invoice_date,@maker,@order_no 
    WHILE @@FETCH_STATUS = 0  
    BEGIN  
     --select @order_no, @invoice_no, @maker
     delete from tbl_invoice_bc40 where 
     isnull(maker, '')=@maker 
     and isnull(invoice_no, '')=@invoice_no 
     and [status_data]='new' 
     and isnull(order_no, '')=@order_no 
     FETCH NEXT FROM db_cursor INTO @invoice_no,@invoice_date,@maker,@order_no 
    END  

    CLOSE db_cursor  
    DEALLOCATE db_cursor
    
     
   
   END TRY
   BEGIN CATCH 
    SELECT 
    '06' AS status
    ,ERROR_MESSAGE() AS description;
    
   END CATCH;
   SELECT 
    '00' AS status
    ,' SUKSES DELETED' AS description;
   

  
END
GO

Depends On

1

Used By

No items found