0

这是声明。目的并不重要,只是我需要能够判断发布规则属于哪种类型的对象。谢谢!

select case(select count(mediaitemguid) from mediaitempublicationrules where publicationruleguid = '<snip>')
       when 0 then case(select count(catalogguid) from catalogpublicationrules where publicationruleguid = '<snip>')
           when 0 then case(select count(domainguid) from domaindefaultpublicationrules where publicationruleguid = '<snip>')
              when 0 then null
             else (select 'Domain', domainguid from domaindefaultpublicationrules where publicationruleguid = '<snip>')
             end
           else (select 'Catalog', catalogguid from catalogpublicationrules where publicationruleguid = '<snip>')
           end
       else (select 'MediaItem', mediaitemguid from mediaitempublicationrules where publicationruleguid = '<snip>')
       end;

编辑:再澄清一点......这工作得很好,直到我将那些“域”“目录”“媒体项目”条目放入 else 语句的嵌套选择中。这可能是相当简单的事情,只是以前没有遇到过这个错误

4

1 回答 1

0

该错误表明您应该返回单列而不是两列

一种解决方法是使用concat_wslike

select concat_ws(':', 'Domain', domainguid') ... <-- ':' is the delimiter
于 2010-12-22T23:03:14.760 回答