Quantcast
Viewing all articles
Browse latest Browse all 9369

Get allocated serial number only

I have a UDF serialno that is comma delimeted, and a Stored Procedure that will  save selected serial. But when It still saves not selected serial.

Image may be NSFW.
Clik here to view.
serial.png
Image may be NSFW.
Clik here to view.
so.png

This is my Stored Procedure.

declare @rowcount int

declare @rowcount1 int

declare @mycount as int

declare @mystring nvarchar(255)

declare @myitem  nvarchar(10)

declare @myserial nvarchar(100)

declare @mybaseentry as nvarchar(10)

declare @mylinenum as int

declare @gdocentry as nvarchar(255)

declare @gitemcode as nvarchar(255)

declare @glinenum as int

 

 

IF @object_type='17' AND (@transaction_type='A' or @transaction_type='U')

BEGIN

 

 

--for U_serial==============================================================================================================================================

  set @rowcount=(select count(*) from syscolumns a,sysobjects b where a.name='u_serialno' and b.name='rdr1' and a.id=b.id)

  if @rowcount>0 and (@transaction_type='A' or @transaction_type='U')

  begin

  set @gdocentry=''

  set @gitemcode=''

  set @glinenum=''

  --update RDR1 set U_serialno='' where docentry=@gdocentry and itemcode=@gitemcode and linenum=@glinenum

  declare serial_no cursor for SELECT A.DOCENTRY, A.ITEMCODE, A.LINENUM FROM RDR1 A, OITM B WHERE A.DOCENTRY=@list_of_cols_val_tab_del AND A.ITEMCODE=B.ITEMCODE AND B.MANSERNUM='Y'

  open serial_no

  fetch next from serial_no into @gdocentry,@gitemcode,@glinenum

  while @@fetch_status=0 begin

  set @myserial=''

  select @myserial=@myserial + cast(intrserial as varchar(255)) + ', ' from sri1 a, osri b where a.itemcode=b.itemcode and a.itemcode=@gitemcode and a.baseentry=@gdocentry and a.baselinnum=@glinenum and a.sysserial=b.sysserial  Group by cast(intrserial as varchar(255))

  set @myserial=case when @myserial='' then '' else left(@myserial,len(@myserial)-1) end

  update rdr1 set u_serialno=@myserial where docentry=@gdocentry and itemcode=@gitemcode and linenum=@glinenum

  fetch next from serial_no into @gdocentry,@gitemcode,@glinenum

  end

 

  Close serial_no

  deallocate serial_no

 

  end

END


Viewing all articles
Browse latest Browse all 9369

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>