2010-04-01 112 views
0

我有选择:字符串缓冲区太小

select v.accs, v.currency,v.amount,v.drcr_ind, count(*) qua,wm_concat(ids) npx_IDS, 
wm_concat(px_dtct) npx_DTCT 
from table v 
group by accs, currency, amount, drcr_ind 

,但我得到的错误ORA-06502:PL/SQL:字符串缓冲区太小,如果我要删除一个字符串,因为有时当v( .accs = 3570)COUNT(*)= 215 但是当我尝试使用wm_concat为v.accs = 3570例如这种方式跳过:

select v.accs, v.currency,v.amount,v.drcr_ind, count(*) qua,wm_concat(ids) npx_IDS, 
(case when v.accs = 3570 then wm_concat(px_dtct) else 'too many' end) npx_DTCT 
from table v 
group by accs, currency, amount, drcr_ind 

我仍然有相同的错误消息。但为什么?

回答

0

为什么?因为你仍然使用的ACCS = 3570 wm_concat ...交换你的CASE表达式的THEN和ELSE部分

select v.accs, v.currency,v.amount,v.drcr_ind, count(*) qua,wm_concat(ids) npx_IDS, 
     (case when v.accs = 3570 then 'too many' else wm_concat(px_dtct) end) npx_DTCT 
    from table v group by accs, currency, amount, drcr_ind 
+0

相同情况 – Ruslan 2010-04-01 07:37:38

+0

结果相同 – Ruslan 2010-04-01 07:39:27

0

首先,因为它已经被告知,必须切换thenelse子句在您的查询。 然后,我想你也应该类似地处理你的第二个wm_concat,与ids一起工作。

select v.accs, v.currency,v.amount,v.drcr_ind, count(*) qua, 
(case when v.accs = 3570 then 'too many' else wm_concat(ids) end) npx_IDS, 
(case when v.accs = 3570 then 'too many' else wm_concat(px_dtct) end) npx_DTCT 
from table v 
group by accs, currency, amount, drcr_ind 

最后,为什么你认为只有v.accs = 3570能够带来06502错误在你面前?我想你应该处理所有这些问题。

1

您连接查询的结果。这个查询可能导致很多行,所以最终你会用完字符串长度。也许连接不是这里的方式。取决于你想要达到的目标。