I frequently need to access two databases with different NLS_LANG (e.g. AL32UTF8 and WE8MSWIN1252) at the same time. Oracle permits multiple environments through OCIEnvNlsCreate. However, with just one global environment pointer in OCI8, oci8_global_envhp, this becomes impossible. I have tried out in a simple setup with two basic connections a solution where the default oci8_global_envhp is created as usual through the dummy_env_method_missing in Init_oci8. Then I have added a nlslang parameter to the OCI8 initialize function and create an environment with the proper NLS_LANG when a new instance of OCI8 is created. A pointer to the environment (envhp) is stored in a new instance variable. Because I do not have a complete overview of all the uses of oci8_global_envhp I have chosen a strategy of setting oci8_global_envhp to the instance envhp each time the connection instance is accessed. When a connection is closed the instance envhp is destroyed and the default oci8_global_envhp is restored. I leave this as a suggestion in case other people have the same need and some of the developers would like to implement a solution.
I frequently need to access two databases with different NLS_LANG (e.g. AL32UTF8 and WE8MSWIN1252) at the same time. Oracle permits multiple environments through OCIEnvNlsCreate. However, with just one global environment pointer in OCI8, oci8_global_envhp, this becomes impossible. I have tried out in a simple setup with two basic connections a solution where the default oci8_global_envhp is created as usual through the dummy_env_method_missing in Init_oci8. Then I have added a nlslang parameter to the OCI8 initialize function and create an environment with the proper NLS_LANG when a new instance of OCI8 is created. A pointer to the environment (envhp) is stored in a new instance variable. Because I do not have a complete overview of all the uses of oci8_global_envhp I have chosen a strategy of setting oci8_global_envhp to the instance envhp each time the connection instance is accessed. When a connection is closed the instance envhp is destroyed and the default oci8_global_envhp is restored. I leave this as a suggestion in case other people have the same need and some of the developers would like to implement a solution.