Oracle® Data Provider for .NET Developer's Guide 10g Release 2 (10.2) Part Number B14307-01 |
|
|
View PDF |
The OracleGlobalization
class is used to obtain and set the Oracle globalization settings of the session, thread, and local computer (read-only).
Class Inheritance
Object
OracleGlobalization
Declaration
public sealed class OracleGlobalization : ICloneable, IDisposable
Thread Safety
All public static methods are thread-safe, although instance methods do not guarantee thread safety.
Remarks
An exception is thrown for invalid property values. All newly set property values are validated, except the TimeZone
property.
Changing the OracleGlobalization
object properties does not change the globalization settings of the session or the thread. Either the SetSessionInfo
method of the OracleConnection
object or the SetThreadInfo
method of the OracleGlobalization
object must be called to alter the session's and thread's globalization settings, respectively.
Example
// C# using System; using Oracle.DataAccess.Client; class OracleGlobalizationSample { static void Main() { // Get thread's globalization info OracleGlobalization glob = OracleGlobalization.GetThreadInfo(); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); // Set language on thread's globalization info glob.Language = "FRENCH"; OracleGlobalization.SetThreadInfo(glob); OracleGlobalization.GetThreadInfo(glob); // Prints "glob.Language = FRENCH" Console.WriteLine("glob.Language = " + glob.Language); glob.Dispose(); } }
Requirements
Namespace: Oracle.DataAccess.Client
Assembly: Oracle.DataAccess.dll
OracleGlobalization
members are listed in the following tables:
OracleGlobalization Static Methods
The OracleGlobalization
static methods are listed in Table 8-1.
Table 8-1 OracleGlobalization Static Methods
Name | Description |
---|---|
GetClientInfo | Returns an OracleGlobalization object that represents the Oracle globalization settings of the local computer (Overloaded) |
GetThreadInfo | Returns or refreshes an OracleGlobalization instance that represents Oracle globalization settings of the current thread (Overloaded) |
SetThreadInfo | Sets Oracle globalization parameters to the current thread |
OracleGlobalization Properties
The OracleGlobalization
properties are listed in Table 8-2.
Table 8-2 OracleGlobalization Properties
Name | Description |
---|---|
Calendar | Specifies the calendar system |
ClientCharacterSet | Specifies a client character set |
Comparison | Specifies a method of comparison for WHERE clauses and comparison in PL/SQL blocks |
Currency | Specifies the string to use as a local currency symbol for the L number format element |
DateFormat | Specifies the date format for Oracle Date type as a string |
DateLanguage | Specifies the language used to spell day and month names and date abbreviations |
DualCurrency | Specifies the dual currency symbol, such as Euro, for the U number format element |
ISOCurrency | Specifies the string to use as an international currency symbol for the C number format element |
Language | Specifies the default language of the database |
LengthSemantics | Enables creation of CHAR and VARCHAR2 columns using either byte or character (default) length semantics |
NCharConversionException | Determines whether or not data loss during an implicit or explicit character type conversion reports an error |
NumericCharacters | Specifies the characters used for the decimal character and the group separator character for numeric values in strings |
Sort | Specifies the collating sequence for ORDER by clause |
Territory | Specifies the name of the territory |
TimeStampFormat | Specifies the string format for TimeStamp types |
TimeStampTZFormat | Specifies the string format for TimeStampTZ types |
TimeZone | Specifies the time zone region name |
OracleGlobalization Public Methods
OracleGlobalization
public methods are listed in Table 8-6.
Table 8-3 OracleGlobalization Public Methods
Public Method | Description |
---|---|
Clone | Creates a copy of an OracleGlobalization object |
Dispose |
Inherited from Component |
The OracleGlobalization
static methods are listed in Table 8-4.
Table 8-4 OracleGlobalization Static Methods
Name | Description |
---|---|
GetClientInfo | Returns an OracleGlobalization object that represents the Oracle globalization settings of the local computer (Overloaded) |
GetThreadInfo | Returns or refreshes an OracleGlobalization instance that represents Oracle globalization settings of the current thread (Overloaded) |
SetThreadInfo | Sets Oracle globalization parameters to the current thread |
GetClientInfo
returns an OracleGlobalization
object instance that represents the Oracle globalization settings of the local computer.
Overload List:
This method returns an OracleGlobalization
instance that represents the globalization settings of the local computer.
GetClientInfo(OracleGlobalization)
This method refreshes the provided OracleGlobalization
object with the globalization settings of the local computer.
This method returns an OracleGlobalization
instance that represents the globalization settings of the local computer.
Declaration
// C# public static OracleGlobalization GetClientInfo();
Return Value
An OracleGlobalization
instance.
Example
// C# using System; using Oracle.DataAccess.Client; class GetClientInfoSample { static void Main() { // Get client's globalization info OracleGlobalization glob = OracleGlobalization.GetClientInfo(); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); glob.Dispose(); } }
This method refreshes the provided OracleGlobalization
object with the globalization settings of the local computer.
Declaration
// C#
public static void GetClientInfo(OracleGlobalization oraGlob);
Parameters
oraGlob
The OracleGlobalization
object being updated.
Example
// C# using System; using Oracle.DataAccess.Client; class GetClientInfoSample { static void Main() { // Get client's globalization info OracleGlobalization glob = OracleGlobalization.GetClientInfo(); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); // Get client's globalization info using overload OracleGlobalization.GetClientInfo(glob); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); glob.Dispose(); } }
GetThreadInfo
returns or refreshes an OracleGlobalization
instance.
Overload List:
This method returns an OracleGlobalization
object instance of the current thread.
GetThreadInfo(OracleGlobalization)
This method refreshes the OracleGlobalization
object instance with the globalization settings of the current thread.
This method returns an OracleGlobalization
instance of the current thread.
Declaration
// C# public static OracleGlobalization GetThreadInfo();
Return Value
An OracleGlobalization
instance.
Remarks
Initially, GetThreadInfo()
returns an OracleGlobalization
object that has the same property values as that returned by GetClientInfo()
, unless the application changes it by invoking SetThreadInfo()
.
Example
// C# using System; using Oracle.DataAccess.Client; class GetThreadInfoSample { static void Main() { // Get thread's globalization info OracleGlobalization glob = OracleGlobalization.GetThreadInfo(); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); // Get thread's globalization info using overloaded OracleGlobalization.GetThreadInfo(glob); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); glob.Dispose(); } }
This method refreshes the OracleGlobalization
object with the globalization settings of the current thread.
Declaration
// C#
public static void GetThreadInfo(OracleGlobalization oraGlob);
Parameters
oraGlob
The OracleGlobalization
object being updated.
Remarks
Initially GetThreadInfo()
returns an OracleGlobalization
object that has the same property values as that returned by GetClientInfo()
, unless the application changes it by invoking SetThreadInfo()
.
Example
// C# using System; using Oracle.DataAccess.Client; class GetThreadInfoSample { static void Main() { // Get thread's globalization info OracleGlobalization glob = OracleGlobalization.GetThreadInfo(); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); // Get thread's globalization info using overloaded OracleGlobalization.GetThreadInfo(glob); // Prints "glob.Language = AMERICAN" Console.WriteLine("glob.Language = " + glob.Language); glob.Dispose(); } }
This method sets Oracle globalization parameters to the current thread.
Declaration
// C#
public static void SetThreadInfo(OracleGlobalization oraGlob);
Parameters
oraGlob
An OracleGlobalization
object.
Remarks
Any .NET string conversions to and from Database Change Notification Types, as well as ODP.NET Type constructors, use the globalization property values where applicable. For example, when constructing an OracleDate
structure from a .NET string, that string is expected to be in the format specified by the OracleGlobalization
.DateFormat
property of the thread.
Example
// C# using System; using Oracle.DataAccess.Client; class SetThreadInfoSample { static void Main() { // Get thread's globalization info OracleGlobalization glob1 = OracleGlobalization.GetThreadInfo(); // Prints "glob1.Language = AMERICAN" Console.WriteLine("glob1.Language = " + glob1.Language); // Set language on thread's globalization info glob1.Language = "FRENCH"; OracleGlobalization.SetThreadInfo(glob1); OracleGlobalization glob2 = OracleGlobalization.GetThreadInfo(); // Prints "glob2.Language = FRENCH" Console.WriteLine("glob2.Language = " + glob2.Language); glob1.Dispose(); glob2.Dispose(); } }
The OracleGlobalization
properties are listed in Table 8-5.
Table 8-5 OracleGlobalization Properties
Name | Description |
---|---|
Calendar | Specifies the calendar system |
ClientCharacterSet | Specifies a client character set |
Comparison | Specifies a method of comparison for WHERE clauses and comparison in PL/SQL blocks |
Currency | Specifies the string to use as a local currency symbol for the L number format element |
DateFormat | Specifies the date format for Oracle Date type as a string |
DateLanguage | Specifies the language used to spell day and month names and date abbreviations |
DualCurrency | Specifies the dual currency symbol, such as Euro, for the U number format element |
ISOCurrency | Specifies the string to use as an international currency symbol for the C number format element |
Language | Specifies the default language of the database |
LengthSemantics | Enables creation of CHAR and VARCHAR2 columns using either byte or character (default) length semantics |
NCharConversionException | Determines whether or not data loss during an implicit or explicit character type conversion reports an error |
NumericCharacters | Specifies the characters used for the decimal character and the group separator character for numeric values in strings |
Sort | Specifies the collating sequence for ORDER by clause |
Territory | Specifies the name of the territory |
TimeStampFormat | Specifies the string format for TimeStamp types |
TimeStampTZFormat | Specifies the string format for TimeStampTZ types |
TimeZone | Specifies the time zone region name |
This property specifies the calendar system.
Declaration
// C# public string Calendar {get; set;}
Property Value
A string representing the Calendar
.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_CALENDAR
setting of the local computer. This value is the same regardless of whether or not the OracleGlobalization
object represents the settings of the client, thread, or session.
This property specifies a client character set.
Declaration
// C# public string ClientCharacterSet {get;}
Property Value
A string that the provides the name of the character set of the local computer.
Remarks
The default value is the character set of the local computer.
This property represents a method of comparison for WHERE
clauses and comparison in PL/SQL blocks.
Declaration
// C# public string Comparison {get; set;}
Property Value
A string that provides the name of the method of comparison.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_COMP
setting of the local computer.
This property specifies the string to use as a local currency symbol for the L number format element.
Declaration
// C# public string Currency {get; set;}
Property Value
The string to use as a local currency symbol for the L number format element.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_CURRENCY
setting of the local computer.
This property specifies the date format for Oracle Date
type as a string.
Declaration
// C# public string DateFormat {get; set;}
Property Value
The date format for Oracle Date
type as a string
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_DATE_FORMAT
setting of the local computer.
This property specifies the language used to spell names of days and months, and date abbreviations (for example: a.m., p.m., AD, BC).
Declaration
// C# public string DateLanguage {get; set;}
Property Value
A string specifying the language.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_DATE_LANGUAGE
setting of the local computer.
This property specifies the dual currency symbol, such as Euro, for the U number format element.
Declaration
// C# public string DualCurrency {get; set;}
Property Value
A string that provides the dual currency symbol.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_DUAL_CURRENCY
setting of the local computer.
This property specifies the string to use as an international currency symbol for the C number format element.
Declaration
// C# public string ISOCurrency {get; set;}
Property Value
The string used as an international currency symbol.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_ISO_CURRENCY
setting of the local computer.
This property specifies the default language of the database.
Declaration
// C# public string Language {get; set;}
Property Value
The default language of the database.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_LANGUAGE
setting of the local computer.
Language
is used for messages, day and month names, and sorting algorithms. It also determines NLS_DATE_LANGUAGE
and NLS_SORT
parameter values.
This property indicates whether or not CHAR
and VARCHAR2
columns use byte or character (default) length semantics.
Declaration
// C# public string LengthSemantics {get; set;}
Property Value
A string that indicates either byte or character length semantics.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_LENGTH_SEMANTICS
setting of the local computer.
This property determines whether or not data loss during an implicit or explicit character type conversion reports an error.
Declaration
// C# public bool NCharConversionException {get; set;}
Property Value
A string that indicates whether or not a character type conversion causes an error message.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value of NLS_NCHAR_CONV_EXCP
is False
, unless it is overridden by a setting in the INIT.ORA
file.
This property specifies the characters used for the decimal character and the group separator character for numeric values in strings.
Declaration
// C# public string NumericCharacters {get; set;}
Property Value
A string that represents the characters used.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_NUMERIC_CHARACTERS
setting of the local computer.
This property specifies the collating sequence for ORDER
by clause.
Declaration
// C# public string Sort {get; set;}
Property Value
A string that indicates the collating sequence.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_SORT
setting of the local computer.
This property specifies the name of the territory.
Declaration
// C# public string Territory {get; set;}
Property Value
A string that provides the name of the territory.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_TERRITORY
setting of the local computer.
Changing this property changes other globalization properties.
This property specifies the string format for TimeStamp
types.
Declaration
// C# public string TimeStampFormat {get; set;}
Property Value
The string format for TimeStamp
types.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_TIMESTAMP_FORMAT
setting of the local computer.
This property specifies the string format for TimeStampTZ
types.
Declaration
// C# public string TimeStampTZFormat {get; set;}
Property Value
The string format for TimeStampTZ
types.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the NLS_TIMESTAMP_TZ_FORMAT
setting of the local computer.
This property specifies the time zone region name or hour offset.
Declaration
// C# public string TimeZone {get; set;}
Property Value
The string represents the time zone region name or the time zone offset.
Exceptions
ObjectDisposedException
- The object is already disposed.
Remarks
The default value is the time zone region name of the local computer
TimeZone
is only used when the thread constructs one of the TimeStamp
structures. TimeZone
has no effect on the session.
TimeZone
can be either an hour offset, for example, 7:00, or a valid time zone region name that is provided in V$TIMEZONE_NAMES
, such as US/Pacific. Time zone abbreviations are not supported.
Note: PST is a time zone region name as well as a time zone abbreviation; therefore it is accepted byOracleGlobalization . |
This property returns an empty string if the OracleGlobalization
object is obtained using GetSessionInfo()
or GetSessionInfo(OracleGlobalization)
. Initially, by default, the time zone of the session is identical to the time zone of the thread. Therefore, given that the session time zone is not changed by invoking ALTER
SESSION
calls, the session time zone can be fetched from the client's globalization settings.
OracleGlobalization
public methods are listed in Table 8-6.
Table 8-6 OracleGlobalization Public Methods
Public Method | Description |
---|---|
Clone | Creates a copy of an OracleGlobalization object |
Dispose |
Inherited from Component |
This method creates a copy of an OracleGlobalization
object.
Declaration
// C# public object Clone();
Return Value
An OracleGlobalization
object.
Implements
ICloneable
Remarks
The cloned object has the same property values as that of the object being cloned.