something i thought would be simple has turned into the "query from hell"
I have a simple looping query...
DECLARE i INT ;
SET i = 1;
WHILE i <= 9 LOOP
if (select count(*) from tblSpecialFieldConfiguration where sfc_szname = 'Extra ' + cast(i as char)) = 0
insert into tblSpecialFieldConfiguration
SFC_szName, SFC_boolDetailVisible, SFC_boolEditable, SFC_bytMaxLength, SFC_lChangeCtr, SFC_bytWorkQTranslate)
(select dt_lkey from tbldevicetype where dt_szcode like '%dcunit%'),
47 + i,
(select max(sfc_lsequence) + 20 from tblSpecialFieldConfiguration),
'Extra ' + cast(i as char),
SET i = i + 1;
That query runs fine...
NOW - i simply wanted to put a big if statement around
this loop using this query...
if (select count(*) from tbldevicetype where dt_szcode like '%dcunit%') = 1
////// query from above goes here....
Each part of the two step process works fine, seperately....