Changed handling of the session ID in the sql statement