Andrew,
I though I should point out a couple of problem with my proposed case
statement before you run into them. A case expression can only return a
single value, so you can't return name and otherdata at the same time,
you can only get one field (otherdata in this case). Also the subselects
in the case expression must be enclosed in brackets. Finally you may
want to alias the result of the case expression to give it a name that
matches the data you are returning since the default name of an
expression result column is the expression itself (which isn't really
very useful in this case). Try this instead;
select
case :uid % 10
when 1 then
(select otherdata from main.sometable where id = :uid / 10)
when 2 then
(select otherdata from database2.sometable where id = :uid / 10)
end
as otherdata;
Dennis Cote