I have already tried calling GetEnvironmentVariable, and the value is indeed changed (correct), both before and after the call to Logon. For some reason the Oracle session is just not picking it up.
I've been trying to debug this with a co-worker for over a day, we're completely baffled by this...