Safir SDK Core
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Safir::Databases::Odbc::Environment Class Reference

The Environment class models the necessary setup each application neeeds in order to access the database. More...

#include <Safir/Databases/Odbc/Environment.h>

Inheritance diagram for Safir::Databases::Odbc::Environment:
Collaboration diagram for Safir::Databases::Odbc::Environment:

Public Member Functions

 Environment (void)
 Constructor. More...
 
 ~Environment (void)
 Destructor. More...
 
void Alloc ()
 Allocates a new environment for the database. More...
 
void Free ()
 Frees the environment previously allocated for the database. More...
 
void SetEnvAttr (long lAttribute, long lValue)
 Sets an integer Environment attribute. More...
 
void SetEnvAttr (long lAttribute, const std::wstring &wszValue, unsigned long ulLength)
 Sets an string Environment attribute. More...
 
void GetEnvAttr (long lAttribute, long &lValue) const
 Gets the value of an integer Environment attribute. More...
 
void GetEnvAttr (long lAttribute, wchar_t *wszValue, unsigned long ulLength) const
 Gets the value of a string Environment attribute. More...
 
bool GetDiagRec (short sRecNumber, std::wstring &SqlState, boost::int32_t &NativeError, std::wstring &MessageText, bool &bDataRead) const
 Get a diagnostics record. More...
 
bool IsValid () const
 Checks if this environment is a valid allocated environment. More...
 
SQLHENV Handle () const
 Returns the ODBC Handle of the environment. More...
 

Detailed Description

The Environment class models the necessary setup each application neeeds in order to access the database.

Only one Environment is necessary in a application and all environments needs to be Allocated and Deallocated before use.

Constructor & Destructor Documentation

Safir::Databases::Odbc::Environment::Environment ( void  )

Constructor.

Safir::Databases::Odbc::Environment::~Environment ( void  )

Destructor.

Member Function Documentation

void Safir::Databases::Odbc::Environment::Alloc ( )

Allocates a new environment for the database.

See SQLAllocHandle in ODBC documentation for more info.

Exceptions
ReconnectException- SQLAllocHandle failed. Check GetDiagRec for info.
void Safir::Databases::Odbc::Environment::Free ( )

Frees the environment previously allocated for the database.

See SQLFreeHandle in ODBC documentation for more info.

bool Safir::Databases::Odbc::Environment::GetDiagRec ( short  sRecNumber,
std::wstring &  SqlState,
boost::int32_t &  NativeError,
std::wstring &  MessageText,
bool &  bDataRead 
) const

Get a diagnostics record.

See SQLGetDiagRec in ODBC documentation for more info.

Parameters
[in]sRecNumber- The sql error record. Starts at 1.
[out]SqlState- The five char sql state error code.
[out]NativeError- Driver specific error code.
[out]MessageText- The diagnostic message text string.
[out]bDataRead- true if data has been placed in the buffers.
void Safir::Databases::Odbc::Environment::GetEnvAttr ( long  lAttribute,
long &  lValue 
) const

Gets the value of an integer Environment attribute.

Some attributes can be retrieved without allocating the environment first. See SQLGetEnvAttr in ODBC documentation for more info.

Parameters
[in]lAttribute- An integer representing the attribute
[out]lValue- The value of the attribute to be set
Exceptions
ReconnectException- SQLGetEnvAttr failed. Check GetDiagRec for info.
void Safir::Databases::Odbc::Environment::GetEnvAttr ( long  lAttribute,
wchar_t *  wszValue,
unsigned long  ulLength 
) const

Gets the value of a string Environment attribute.

Some attributes can be retrieved without allocating the environment first. See SQLGetEnvAttr in ODBC documentation for more info.

Parameters
[in]lAttribute- An integer representing the attribute
[out]wszValue- The value of the attribute to be set
[in]ulLength- The length of string.
Exceptions
ReconnectException- SQLGetEnvAttr failed. Check GetDiagRec for info.
SQLHENV Safir::Databases::Odbc::Environment::Handle ( ) const

Returns the ODBC Handle of the environment.

Returns
An ODBC Environment handle.
bool Safir::Databases::Odbc::Environment::IsValid ( ) const

Checks if this environment is a valid allocated environment.

Returns
True if the environment is ok to use.
void Safir::Databases::Odbc::Environment::SetEnvAttr ( long  lAttribute,
long  lValue 
)

Sets an integer Environment attribute.

Some attributes can be set without allocating the environment first. See SQLSetEnvAttr in ODBC documentation for more info.

Parameters
[in]lAttribute- An integer representing the attribute
[in]lValue- The value of the attribute to be set
Exceptions
ReconnectException- SQLSetEnvAttr failed. Check GetDiagRec for info.
void Safir::Databases::Odbc::Environment::SetEnvAttr ( long  lAttribute,
const std::wstring &  wszValue,
unsigned long  ulLength 
)

Sets an string Environment attribute.

Some attributes can be set without allocating the environment first. See SQLSetEnvAttr in ODBC documentation for more info.

Parameters
[in]lAttribute- An integer representing the attribute
[in]wszValue- The value of the attribute to be set
[in]ulLength- The length of string.
Exceptions
ReconnectException- SQLSetEnvAttr failed. Check GetDiagRec for info.