如何从列中单元格的最后一个字符中获取字符

问题描述 投票:0回答:1

限制:最大字符串长度为268,435,456个Unicode字符(256个兆字符)或536,870,912字节。这是大小限制。

这是情况:我需要最后一个字符的大小限制。甲骨文抛出了类似错误

:不一致的数据类型:预期-获得CLOB

如何解决此类错误,XMLAGG是一种选择吗?

下面是测试代码:

`  WITH q AS (
SELECT 'All aboard! 

Hahahahaha

Aye Aye Aye Aye Aye Aye...
Crazy, but that s how it goes
Millions of people living as foes
Maybe it s not too late

To learn how to love and forget how to hate
Mental wounds not healing
Life s a bitter shame
I m going off the rails on a crazy train
I m going off the rails on a crazy train

I ve listened to preachers, I ve listened to fools
I ve watched all the dropouts who make their own rules
One person conditioned to rule and control
The media sells it and you live the role

Mental wounds still screaming
Driving me insane
I m going off the rails on a crazy train
I m going off the rails on a crazy train

I know that things are going wrong for me
You gotta listen to my words

Yeah
Heirs of a cold war, that s what we ve become
Inheriting troubles, I m mentally numb
Crazy, I just cannot bear
I m living with something that just isn t fair
Mental wounds stop healing
Who and what s to blame

I m going off the rails on a crazy train' AS sentence FROM DUAL)

SELECT SUBSTR(sentence,-256) AS Y FROM Q; `

结果:

呀冷战的继承者,这就是我们所成为的继承麻烦,我精神麻木疯了,我就是受不了我生活在不公平的地方精神伤口停止愈合谁和谁应该受到谴责我正在疯狂的火车上脱轨

测试方案:代码必须返回以下方案的值

'您好,我们篮子里有14.个苹果,我们正在将它们运送到日本通过澳大利亚以23142美元的价格使用#1243432航班号'

'塑料如何假装在受支持的新来者顶部?为什么恐怖不能超过慈善骑士?头盔在想!病房如何打码变送器?高级内核会忽略具有感知数组的集合。解剖学在背部缺陷周围大笑?'

''949490909232哟,怎么了'

'谢谢'

'1941年5月16日'

'1.嗨,人

  1. 这不是最好的主意;

  2. 是足球是世界上最受欢迎的运动

  3. 白宫可以容纳多少只大象

  4. 狮子可以吃2年内有6头鹿,4头斑马和8头水牛']]

  5. 限制:最大字符串长度为268,435,456个Unicode字符(256个兆字符)或536,870,912字节。这是大小限制。这是一种情况:我需要最后一个的大小限制...

sql oracle plsql clob
1个回答
0
投票

我想您需要一个简单的CASE语句-

SELECT CASE WHEN LENGTH(sentence) <= 256
                 THEN sentence
            ELSE SUBSTR(sentence,-256) 
       END AS Y
FROM Q;
© www.soinside.com 2019 - 2024. All rights reserved.