This is a nice one ;-)
Index/Position only works with strings, so there's an automatic typecast. 123456 is an integer, whereas 1 is a byteint.
sel format(123456), format(1);
*** Query completed. One row found. 2 columns returned.
*** Total elapsed time was 1 second.
Format(123456) Format(1)
------------------------------ ------------------------
-(10)9 -(3)9
So let's see how the casted string looks like:
sel '''' || 123456 || '''', '''' || 1 || '''';
*** Query completed. One row found. 2 columns returned.
*** Total elapsed time was 1 second.
((''''||123456)||'''') ((''''||1)||'''')
---------------------- -----------------
' 123456' ' 1'
So your query is equal to:
sel position(' 1' in ' 123456') as x,
position(' 3' in ' 123456') as y;
*** Query completed. One row found. 2 columns returned.
*** Total elapsed time was 1 second.
x y
------ ------
3 0
qed
I'll definitly use that example in my trainings, it's weirder than my usual ones
select cast(127 as char(3)), 127 (char(3));
select cast(128 as char(3)), 128 (char(3));
Dieter