Skip Headers

Oracle Data Provider for .NET Developer's Guide
Release 9.2.0.2

Part Number A96160-01
Go To Table Of Contents
Contents
Go To Index
Index

Go to previous page Go to beginning of chapter Go to next page

Oracle.DataAccess.Client Namespace, 12 of 26


OracleGlobalization Class

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#
//  Sets thread globalization info.
...
string ConStr = "User Id=myschema;Password=mypassword;" +
   "Data Source=oracle;";
OracleConnection con = new OracleConnection(ConStr);
con.Open();

//Retrieves thread globalization info
OracleGlobalization ogi = OracleGlobalization.GetThreadInfo();

//Print the language name in thread globalization info
Console.WriteLine("Thread language: " + ogi.Language);

//Set thread's language
ogi.Language = "FRENCH";
OracleGlobalization.SetThreadInfo(ogi);

OracleGlobalization ogi2;
OracleGlobalization.GetThreadInfo(ogi2);

//Print the language name in thread globalization info
Console.WriteLine("Thread language: " + ogi2.Language);

Requirements

Namespace: Oracle.DataAccess.Client

Assembly: Oracle.DataAccesss.dll

See Also:

OracleGlobalization Members

OracleGlobalization members are listed in the following tables:

OracleGlobalization Static Methods

The OracleGlobalization static methods are listed in Table 4-75.

Table 4-75 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 4-76.

Table 4-76 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 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 4-80.

Table 4-77 OracleGlobalization Public Methods  
Public Method Description

Clone

Creates a copy of an OracleGlobalization object

Dispose

Inherited from Component

See Also:

OracleGlobalization Static Methods

The OracleGlobalization static methods are listed in Table 4-78.

Table 4-78 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

See Also:

GetClientInfo

GetClientInfo returns an OracleGlobalization object instance that represents the Oracle globalization settings of the local computer.

Overload List:

GetClientInfo()

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#
//  Retrieves the client globalization info.
...
string ConStr = "User Id=myschema;Password=mypassword;" +
     "Data Source=oracle;";
OracleConnection con = new OracleConnection(ConStr);
con.Open();

//Retrieves the client globalization info
OracleGlobalization ogi = OracleGlobalization.GetClientInfo();

//Retrieves the client globalization info using overloaded method
OracleGlobalization ogi2;
OracleGlobalization.GetClientInfo(ogi2);

//Print the language name in client globalization info
Console.WriteLine("Client machine language: " + ogi.Language);
Console.WriteLine("Client machine language: " + ogi2.Language);

See Also:

GetClientInfo(OracleGlobalization)

This method refreshes the provided OracleGlobalization object with the globalization settings of the local computer.

Declaration
// C#
public static void GetClientInfo(OracleGlobalization oraGlob);
Parameters
Example
// C#
//  Retrieves the client globalization info.
...
string ConStr = "User Id=myschema;Password=mypassword;" +
     "Data Source=oracle;";
OracleConnection con = new OracleConnection(ConStr);
con.Open();

//Retrieves the client globalization info
OracleGlobalization ogi = OracleGlobalization.GetClientInfo();

//Retrieves the client globalization info using overloaded method
OracleGlobalization ogi2;
OracleGlobalization.GetClientInfo(ogi2);

//Print the language name in client globalization info
Console.WriteLine("Client machine language: " + ogi.Language);
Console.WriteLine("Client machine language: " + ogi2.Language);

See Also:

GetThreadInfo

GetThreadInfo returns or refreshes an OracleGlobalization instance.

Overload List:

GetThreadInfo()

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#
Retrieves the thread globalization info.
...
string ConStr = "User Id=myschema;Password=mypassword;" +
       "Data Source=oracle;";
OracleConnection con = new OracleConnection(ConStr);
con.Open();

//Retrieves the thread globalization info
OracleGlobalization ogi = OracleGlobalization.GetThreadInfo();

//Retrieves the thread globalization info using overloaded method
OracleGlobalization ogi2;
OracleGlobalization.GetThreadInfo(ogi2);

//Print the language name in thread globalization info
Console.WriteLine("Thread language: " + ogi.Language);
Console.WriteLine("Thread language: " + ogi2.Language);

See Also:

GetThreadInfo(OracleGlobalization)

This method refreshes the OracleGlobalization object with the globalization settings of the current thread.

Declaration
// C#
public static void GetThreadInfo(OracleGlobalization oraGlob);
Parameters
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#
Retrieves the thread globalization info.
...
string ConStr = "User Id=myschema;Password=mypassword;" +
       "Data Source=oracle;";
OracleConnection con = new OracleConnection(ConStr);
con.Open();

//Retrieves the thread globalization info
OracleGlobalization ogi = OracleGlobalization.GetThreadInfo();

//Retrieves the thread globalization info using overloaded method
OracleGlobalization ogi2;
OracleGlobalization.GetThreadInfo(ogi2);

//Print the language name in thread globalization info
Console.WriteLine("Thread language: " + ogi.Language);
Console.WriteLine("Thread language: " + ogi2.Language);

See Also:

SetThreadInfo

This method sets Oracle globalization parameters to the current thread.

Declaration
// C#
public static void SetThreadInfo(OracleGlobalization oraGlob);
Parameters
Remarks

Any .NET string conversions to and from ODP.NET 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#
//  Sets thread globalization info.
...
string ConStr = "User Id=myschema;Password=mypassword;" +
   "Data Source=oracle;";
OracleConnection con = new OracleConnection(ConStr);
con.Open();

//Retrieves thread globalization info
OracleGlobalization ogi = OracleGlobalization.GetThreadInfo();

//Print the language name in thread globalization info
Console.WriteLine("Thread language: " + ogi.Language);

//Set thread's language
ogi.Language = "FRENCH";
OracleGlobalization.SetThreadInfo(ogi);

OracleGlobalization ogi2;
OracleGlobalization.GetThreadInfo(ogi2);

//Print the language name in thread globalization info
Console.WriteLine("Thread language: " + ogi2.Language);

See Also:

OracleGlobalization Properties

The OracleGlobalization properties are listed in Table 4-79.

Table 4-79 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 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

See Also:

Calendar

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 the OracleGlobalization object represents the settings of the client, thread, or session.

See Also:

ClientCharacterSet

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.

See Also:

Comparison

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.

See Also:

Currency

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.

See Also:

DateFormat

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.

See Also:

DateLanguage

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.

See Also:

DualCurrency

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.

See Also:

ISOCurrency

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.

See Also:

Language

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.

See Also:

LengthSemantics

This property indicates whether 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.

See Also:

NCharConversionException

This property determines whether 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 is the NLS_NCHAR_CONV_EXCP setting of the local computer.

See Also:

NumericCharacters

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.

See Also:

Sort

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.

See Also:

Territory

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.

See Also:

TimeStampFormat

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.

See Also:

TimeStampTZFormat

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.

See Also:

TimeZone

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 by OracleGlobalization.


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.

See Also:

OracleGlobalization Public Methods

OracleGlobalization public methods are listed in Table 4-80.

Table 4-80 OracleGlobalization Public Methods  
Public Method Description

Clone

Creates a copy of an OracleGlobalization object

Dispose

Inherited from Component

See Also:

Clone

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.

Example
// C#
...
//Need a proper casting for the return value when cloned
OracleGlobalization ogi_cloned = (OracleGlobalization) ogi.Clone();
...

See Also:


Go to previous page Go to beginning of chapter Go to next page
Oracle
Copyright © 2002 Oracle Corporation.

All Rights Reserved.
Go To Table Of Contents
Contents
Go To Index
Index