update, concatenation strings
Posted in 2003
Topics: General Discussion
create table test
(
test1 char(30),
test2 char(30)
);
insert into test values ("aaa","bbb");
insert into test values ("bbb","bbb");
insert into test values ("ccc","bbb");
update test set test1=test.test1||"xxx";
select * from test;
How to concatenate strings in update statement. I would like to update field
with existing value + string from some other column or arbitrary string.
When I execute update statment (above), I don't get result as I expect like
str1xxx.
Mitja
Mitja Udovc wrote:
> create table test
> (
> test1 char(30),
> test2 char(30)
> );>
> insert into test values ("aaa","bbb");
> insert into test values ("bbb","bbb");
> insert into test values ("ccc","bbb");>
> update test set test1=test.test1||"xxx";>
> select * from test;>
> How to concatenate strings in update statement. I would like to update
field
> with existing value + string from some other column or arbitrary string.
> When I execute update statment (above), I don't get result as I expect
like
> str1xxx.
The stored data is 30 characters long; you need to trim the trailing spaces
before concatenating the new string. Try:
update test set test1 = trim(test.test1)||"xxx";
Using TRIM as shown will remove both leading and trailing blanks. If your
data includes leading blanks that you wish to keep, you can use an argument
to the TRIM function to retain those spaces. See the Informix Guide to SQL:
Syntax manual for more information.
--
June Hunt