I need Sybase datatype to save string of indefinite Length.

回眸只為那壹抹淺笑 提交于 2019-12-10 09:08:03

问题


My requirement is to declare a datatype which accepts xml value with maximum size.
Question: Do we have text, xml or varchar(max) datatype in Sybase?


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/15071829/i-need-sybase-datatype-to-save-string-of-indefinite-length

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