You are on page 1of 2

Alter procedure MSSPDCSMC02Family (@PDescription varchar(max),@PDCSMP02Fam int,@PALert varchar(100) output) as Begin set nocount on declare declare declare declare

declare declare declare declare @Rowvalues varchar(max) @Columnvalues varchar(max) @Type char(1) @DCSMC02key int @DCSMC02RelationName varchar(50) @DCSMS01Relation int @Age int @cnt int

while(CHARINDEX('',@PDescription,0)<>0) Begin set @Rowvalues=LEFT(@PDescription,(charindex('',@PDescription,0)-1)) set @PDescription=SUBSTRING(@PDescription,(charindex('',@PDescription,0)+ 1),(len(@PDescription)-LEN(@Rowvalues))) set @cnt=0 while(CHARINDEX('',@Rowvalues,0)<>0) Begin set @Columnvalues=LEFT(@Rowvalues,(charindex('',@Rowvalues,0)-1)) set @Rowvalues=SUBSTRING(@Rowvalues,(charindex('',@Rowvalues,0)+1),(len(@ Rowvalues)-len(@Columnvalues))) if(@cnt=0) set @Type=upper(@Columnvalues) if(@cnt=1) set @DCSMC02key=@Columnvalues if(@cnt=2) set @DCSMC02RelationName=@Columnvalues if(@cnt=3) set @DCSMS01Relation=@Columnvalues if(@cnt=4) set @Age=@Columnvalues set @cnt=@cnt+1 End if(@Type='I') Begin insert into DCSMC02Family (DCSMP02Fam,DCSMC02RelationName,DCSMS01Relatio n,Age,CRDateTime,LUDateTime,DCSMC02Status) values (@PDCSMP02Fam,@DCSMC02Relation Name,@DCSMS01Relation,@Age,GETDATE(),GETDATE(),'C') set @PALert=0 End if(@Type='U') Begin update DCSMC02Family set DCSMP02Fam=@PDCSMP02Fam,DCSMC02RelationName=@DC SMC02RelationName,DCSMS01Relation=@DCSMS01Relation,Age=@Age,LUDateTime=GETDATE() where DCSMC02key=@DCSMC02key set @PALert=1 End if(@Type='D') Begin declare @refdelete varchar(50)

exec ADM_SP_RefDelete DCSMC02Family,@DCSMC02key,'',@refdelete output if(@refdelete=0) Begin update DCSMC02Family set DCSMC02Status='D',LUDateTime=GETDATE() where DC SMC02key=@DCSMC02key set @PALert=2 End Else set @PALert='547' End End set nocount off End --declare @PAlert varchar(100) --exec MSSPDCSMC02Family 'D9zz440D10yy445',2,@PALert output --select @PALert --select * from DCSMC02Family

You might also like