How can I fix this so that it doesn't do essentially the same scan
twice, but it gives the same results (a single row where
IDENTITY_MODIFI ER is either 'identityoverri de' or '' and
ROWCHANGETIMEST AMP_MODIFIER is either 'rowchangetimes tampoverride' or ''?
select
case
when exists (
select *
from syscat.columns
where tabschema = 'FRANK'
and tabname = 'INVOICE'
and identity = 'Y'
) then 'identityoverri de'
else ''
end as identity_modifi er
, case
when exists (
select *
from syscat.columns
where tabschema = 'FRANK'
and tabname = 'INVOICE'
and rowchangetimest amp = 'Y'
) then 'rowchangetimes tampoverride'
else ''
end as rowchangetimest amp_modifier
from sysibm.sysdummy 1;
Results:
IDENTITY_MODIFI ER ROWCHANGETIMEST AMP_MODIFIER
----------------- ---------------------------
identityoverrid e rowchangetimest ampoverride
1 record(s) selected.
twice, but it gives the same results (a single row where
IDENTITY_MODIFI ER is either 'identityoverri de' or '' and
ROWCHANGETIMEST AMP_MODIFIER is either 'rowchangetimes tampoverride' or ''?
select
case
when exists (
select *
from syscat.columns
where tabschema = 'FRANK'
and tabname = 'INVOICE'
and identity = 'Y'
) then 'identityoverri de'
else ''
end as identity_modifi er
, case
when exists (
select *
from syscat.columns
where tabschema = 'FRANK'
and tabname = 'INVOICE'
and rowchangetimest amp = 'Y'
) then 'rowchangetimes tampoverride'
else ''
end as rowchangetimest amp_modifier
from sysibm.sysdummy 1;
Results:
IDENTITY_MODIFI ER ROWCHANGETIMEST AMP_MODIFIER
----------------- ---------------------------
identityoverrid e rowchangetimest ampoverride
1 record(s) selected.
Comment