1

我面临以下问题:

-615:此表达式中不允许出现 Blob。

SELECT ser
      ,task_code
      ,trans_serial
      ,trans_year
      ,CASE when nvl(length(signed_content), 0) <> '' THEN  signed_content  ELSE  attach_content  END AS signed_content
      ,CASE WHEN nvl(length(signed_content), 0) <> '' THEN 'signed_content' ELSE 'attach_content' END AS comes_from
FROM attach_detail
WHERE serial = 5 AND task_code = 88 AND trans_year = 2012 AND trans_serial = 23728

注:signed_content,attach_content属于BYTE; 其他列是 type INT

4

1 回答 1

2

您的问题似乎是 Informix 不允许在CASE表达式中使用 blob。

要解决此问题,您可以将其CASE转换为两个子查询:

SELECT ser
      ,task_code
      ,trans_serial
      ,trans_year
      ,signed_content AS signed_content
      ,'signed_content' AS comes_from
FROM attach_detail
WHERE nvl(length(signed_content), 0) <> ''
  AND serial = 5 AND task_code = 88 AND trans_year = 2012 AND trans_serial = 23728
UNION ALL
SELECT ser
      ,task_code
      ,trans_serial
      ,trans_year
      ,attach_content AS signed_content
      ,'attach_content' AS comes_from
FROM attach_detail
WHERE nvl(length(signed_content), 0) = ''
  AND serial = 5 AND task_code = 88 AND trans_year = 2012 AND trans_serial = 23728
于 2013-02-17T18:26:08.023 回答