Running on Adaptive Server Enterprise/15.0.3/EBF 17157 ESD#3/P/x86_64/Enterprise Linux/ase1503/2726/64-bit/FBO/
The below code should never enter the substring case, however I am presented with a Sybase Error 536.
Is this a form of optimization where it evaluates all paths regardless of the actual value??
We can work around this but wish to know why?
declare @test float
declare @test1 char(10)
create table #TestTable
(
Dno int,
Code varchar(10)
)
Insert into #TestTable values (1,'code')
set @test1 = 'ddd'
print 'test'
select @test = case
when (1=1) then 2
when (1=0) then (select Dno FROM #TestTable WHERE Code = substring('abc',1,charindex(@test1,'a')-1) AND Dno = 1)
else 10
end
select @test
drop table #TestTable