I need Sybase datatype to save string of indefinite Length.

China☆狼群 提交于 2019-12-05 15:47:52

There is text datatype. You can find More information here.

How to use it with procedure:

create procedure settxt
(
  @txt text
)
as
begin
  select @txt
end

How to run the procedure:

declare @txt  text
select @txt = 'Hello world'
execute settxt @txt

The code works for me, but maybe not for everyone.

Here is solution with temporary table:

create table #texttab
(
  txt varchar(100)
)
go
insert into #texttab
values ('Hello ')

insert into #texttab
values  (' wolrd!')
go
create procedure settxt
as
begin
  declare @txt text, 
          @txtval varchar(100)  

  select @txt=' '

  declare curTXT cursor for 
  select txt from #texttab


  open curTXT
  fetch curTXT into @txtval  
  while @@sqlstatus=0 begin
    select @txtval
    select @txt=@txt+@txtval
    select @txt
    fetch curTXT into @txtval
  end
  close curTXT
  deallocate cursor curTXT

  select @txt

end
go
execute settxt

Sybase ASE 15.7 and later support text datatype in parameters and variables within stored procedures (here is my support). Earlier versions depend on page size, for example a server with 2k page size is able to work with 16,348 characters maximum. Another idea is to store data in a different way, for example writing large objects to a file and save only filenames in the database.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!