Question

Here is the statement. The purpose isn't really important, just that I need to be able to tell what type of object the publication rule belongs to. Thanks!

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;

EDIT: a little more clarification...this worked just fine until I put those 'Domain' 'Catalog' 'MediaItem' entries into the nested selects on the else statements. It's probably something fairly simple, just haven't run into that error before

Was it helpful?

Solution

The error indicate you should return single column instead of two

One way to fix is to use concat_ws like

select concat_ws(':', 'Domain', domainguid') ... <-- ':' is the delimiter
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top