问题
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