Alter DateFormat Settings for Session
-
- Posts: 18
- Joined: Wed 02 Jun 2010 16:28
Alter DateFormat Settings for Session
Hello,
we have some problems putting values into a oracle database when triggers with another nls_language exists than used by our local environment.
For example - the database has nls_language=german; nls_date_format='dd.mm.yy'; my local development environment has both english. When i try to update a row, i get an invalid date format exception of of a database trigger.
It seems, that my local settings are used instead of the database settings. so we have to alter the session settings. But where in our code can we do this? We use the entity framework together with devart.
Where can we set OracleGlobalization.SetApplicationInfo
Thanks
roman
we have some problems putting values into a oracle database when triggers with another nls_language exists than used by our local environment.
For example - the database has nls_language=german; nls_date_format='dd.mm.yy'; my local development environment has both english. When i try to update a row, i get an invalid date format exception of of a database trigger.
It seems, that my local settings are used instead of the database settings. so we have to alter the session settings. But where in our code can we do this? We use the entity framework together with devart.
Where can we set OracleGlobalization.SetApplicationInfo
Thanks
roman
-
- Posts: 18
- Joined: Wed 02 Jun 2010 16:28
We tried to solve the problem as suggested - but it does not work.
We inserted this code in our application - just before the creation of the object context.
this is our Code:
...
But this does not work. We get the same error although the globalisation settings were displayed right.
It seems thas something happens after the creation of the context.
The second solution does also not work, because OracleConnection.SetSessionInfo does not exist.
Did we have to place the code anywhere else?
We inserted this code in our application - just before the creation of the object context.
Code: Select all
var locale = OracleGlobalization.GetApplicationInfo();
locale.DateFormat = "dd.mm.yyyy";
locale.DateLanguage = "GERMAN";
locale.Territory = "GERMANY";
OracleGlobalization.SetApplicationInfo(locale);
Code: Select all
public partial class SibisEntities : global::System.Data.Objects.ObjectContext
{
///
/// Initialisiert ein neues SibisEntities-Objekt mithilfe der in Abschnitt 'SibisEntities' der
///Anwendungskonfigurationsdatei gefundenen Verbindungszeichenfolge.
///
public SibisEntities() :
base("name=SibisEntities", "SibisEntities")
{
*****here we placed the new locale settings*****
this.OnContextCreated();
}
But this does not work. We get the same error although the globalisation settings were displayed right.
It seems thas something happens after the creation of the context.
The second solution does also not work, because OracleConnection.SetSessionInfo does not exist.
Did we have to place the code anywhere else?
-
- Posts: 18
- Joined: Wed 02 Jun 2010 16:28
Yes sure we can post it here
this is our SQL statement:
this is the exception we get:
and this ist the part of the trigger (line 55) which causes the exception:
this is the only part of the trigger which handels with dates.
When we insert following lines before the execution of the SQL statement above, we get no errors.
this is our SQL statement:
Code: Select all
update AZUBI
set DB_PREIS_ID = 251, DB_PREIS_KZF = 0, VERR_ENDE = to_date('2012/08/31','YYYY/MM/DD')
where (DB_AZUBIID = 32511)
Code: Select all
Error 58 ORA-01843: not a valid month
ORA-06512: at "TU_BA_AZUBI", line 55
ORA-04088: error during execution of trigger 'TU_BA_AZUBI'
Code: Select all
begin
-- indiv.Ausbildungsende
if nvl(:old.db_abbruch,'01.01.2000') nvl(:new.db_abbruch ,'01.01.2000') then
update azubi_bestellen
set st_ba_pruefung=2 , st_abbruch=1, aend_id = :new.aend_id
where db_azubiid = :OLD.db_azubiid and st_ba_pruefung > 0;
end if;
end;
When we insert following lines before the execution of the SQL statement above, we get no errors.
Code: Select all
alter session set nls_language=german;
alter session set nls_territory=germany;
alter session set nls_date_format='dd.mm.yy';