这是声明。目的并不重要,只是我需要能够判断发布规则属于哪种类型的对象。谢谢!
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 语句的嵌套选择中。这可能是相当简单的事情,只是以前没有遇到过这个错误