Archives of the TeradataForum
Message Posted: Mon, 05 Jul 2004 @ 17:46:30 GMT
Subj: | | Re: String variable concatenation in a Stored Procedure |
|
From: | | Victor Sokovin |
| How can I concatenate a string variable in a stored procedure? I want to concatenate a variable in few steps but with the second step I get
"Variable too long" error. | |
| Here is an example of a code that I want to use: | |
DECLARE var1 VARCHAR(20000);
set var1 = 'AAA';
set var1 = var1 || 'BBB';
I don't know whether there is any difference between SP and usual SQL in this case. If SQL is any indication, then I would explain this
error by the fact that VARCHAR literal is by default in UNICODE, and a UNICODE string length has the maximum of 32000.
select
cast ('A' as VARCHAR(20000)) VC
, VC || VC || VC ;
fails with the error message similar to yours but the following statement seems to work:
select
cast (TRANSLATE('A' USING UNICODE_TO_LATIN) as VARCHAR(20000)) VC
, VC || VC || VC ;
64000 should be the maximum for Latin strings. Concatenation of 4 VCs fails.
Regards,
Victor
|