Sybase NNTP forums - End Of Life (EOL)

The NNTP forums from Sybase - forums.sybase.com - are now closed.

All new questions should be directed to the appropriate forum at the SAP Community Network (SCN).

Individual products have links to the respective forums on SCN, or you can go to SCN and search for your product in the search box (upper right corner) to find your specific developer center.

Append string value to column of type text

2 posts in Windows NT Last posting was on 2000-05-05 22:40:53.0Z
Paul Fennell Posted on 2000-05-05 15:33:01.0Z
From: "Paul Fennell" <paul.fennell@rebusmedia.com>
Subject: Append string value to column of type text
Date: Fri, 5 May 2000 16:33:01 +0100
Lines: 23
Organization: Rebus Media Solutions
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.00.2014.211
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2014.211
Message-ID: <PC1m2hqt$GA.201@forums.sybase.com>
Newsgroups: sybase.public.sqlserver.nt
NNTP-Posting-Host: 212.2.24.33
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2199
Article PK: 1089631

Hi,

I need to append a string to existing data in a column of type text.

update test_table set
test_text = test_text+"hello"
from test_table
where test_key = 1

But of course this does work because you cannot concatenate values on to
columns of type text. I have a feeling that readtext and writetext could be
used but have not stumbled on the answer by experiment or referral to the
Sybase documentation.

Any help would be appreciated.

Regards,

Paul


Bret Halford Posted on 2000-05-05 22:40:53.0Z
Message-ID: <39134DF5.9FC832F1@sybase.com>
Date: Fri, 05 May 2000 16:40:53 -0600
From: Bret Halford <bret@sybase.com>
Organization: Sybase, Inc.
X-Mailer: Mozilla 4.5 [en]C-CCK-MCD (WinNT; I)
X-Accept-Language: en,ja
MIME-Version: 1.0
Subject: Re: Append string value to column of type text
References: <PC1m2hqt$GA.201@forums.sybase.com>
Content-Type: multipart/mixed; boundary="------------21855D90693C07BF193AC0DB"
Newsgroups: sybase.public.sqlserver.nt
Lines: 515
NNTP-Posting-Host: bret-pc.sybase.com 157.133.80.211
Path: forums-1-dub!forums-master.sybase.com!forums.sybase.com
Xref: forums-1-dub sybase.public.sqlserver.nt:2198
Article PK: 1089634


Paul Fennell wrote:

> Hi,
>
> I need to append a string to existing data in a column of type text.
>
> update test_table set
> test_text = test_text+"hello"
> from test_table
> where test_key = 1
>
> But of course this does work because you cannot concatenate values on to
> columns of type text. I have a feeling that readtext and writetext could be
> used but have not stumbled on the answer by experiment or referral to the
> Sybase documentation.

Hi Paul,


Historically, the intention has been that text manipulation will be done on the
client side, using probably a custom-coded Open Client program, that woud use
READTEXT to read the current value into a buffer, append whatever to it, then
use WRITETEXT to put it back in the server.

In ASE 11.5, the new CIS features opened up a few possibilities for hacks to
allow some limited server-side manipulation. I wrote up two techniques, one
which takes a text column and breaks it down into as many char(n) columns as
required or desired, the second can combine up to ~255 char(n) values into one
TEXT column. People have had some limited success using them.

In ASE 12.0, using the optional server-side JAVA feature, this process is
actually pretty easy.

I'm appending the techniques, starting with the 12.0 version, then the two 11.5
versions, below.

My advise: upgrade to ASE 12.0 and use that technique.

-bret

--------------------------------------------------------------------------
-- Example of using JAVA to concatenate two char strings into a TEXT column


create table foo(a varchar(255), b varchar(255), c int)
create table goo(t text null)

insert foo
values("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",


"zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz",1)


declare @y varchar(255)
select @y = a from foo where c=1
declare @x java.lang.StringBuffer
select @x = new java.lang.StringBuffer(@y)
declare @a varchar(255)
select @a = b from foo where c=1
select @x = @x>>append(convert(java.lang.String,@a))
insert goo values (@x>>toString())
select * from goo

-----------------------------------------------------------------------------