As mentioned above, I think there is a misunderstanding. oo
I canβt explain why he does this, but here is the template for the type of request that you have:
If you generalize it a bit, where [A] and [B] are integers, and [STRING] is any text you want:
select cast(col as char([A])) from ( select '[STRING]' as col from dual union all select '[STRING]' as col from dual ) group by cast(col as char([B]));
it seems like this always fails if one of the two conditions below is true (there may be others):
- (LENGTH ([STRING]) <[B] OR LENGTH ([STRING]> [B]) and [A] = LENGTH ([STRING])
- (LENGTH ([STRING]) = [B] AND [A] <> LENGTH ([STRING]))
Otherwise, it will return a string.
But if you take your example, which runs and uses it in the CREATE TABLE statement, it will fail because it sets the column width to 2 and cannot accommodate 3 lines of characters that come in.
To add to the oddity, if you add something at the beginning and end of a line, like this:
select '\*'||cast(col as char([A]))||'\*' from ( select '[STRING]' as col from dual union all select '[STRING]' as col from dual ) group by cast(col as char([B]));
This will only work if [A]> = [B], otherwise it will not work on ORA-01489: the string concatenation result is too long.
Curious...
source share