SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[proc_delete_spaj_web]
  @pi_no_spaj varchar(12),
  @po_message varchar(300) Output
AS
BEGIN
  BEGIN TRAN
  
	DELETE FROM web_spaj WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_pemegang WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_pemegang_alamat WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_tertanggung WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_tertanggung_alamat WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_plan WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_termaslahat WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_riwayat WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_asuransi WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_kesehatan WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_statistik WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_pernyataan WHERE no_spaj=@pi_no_spaj
	DELETE FROM web_spaj_dokumen WHERE no_spaj=@pi_no_spaj
	
	COMMIT TRAN
	
	SET @po_message = 'Sukses'
	RETURN 0
END
GO
