此表达式中不允许使用Blob

时间:2013-02-17 09:41:05

标签: sql blob informix

我遇到以下问题:

  

-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_contentattach_content的类型为BYTE;其他列的类型为INT

1 个答案:

答案 0 :(得分: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