I am having a very strange issue in SQL Anywhere version 22.214.171.12458, here is a very simple sample (in real life there are much more columns and conditions):
Why can't I pass an alias to
When you try to call a stored procedure with a column as argument and want to join the procedure's result set with other columns, you are basically making a LATERAL call, and therefore I would recommend to try that or the alternative CROSS APPLY operator, i.e. something like
Note: I've checked that with v126.96.36.19936, which also accepts your sample query "SELECT 123 as a, (select c2 from proc2(a))" but rejects "SELECT c1 as a, (select c2 from proc2(a))", so I'm not sure whether both suggested queries work with v11...