Main Page   Namespace List   Compound List   File List   Namespace Members   Compound Members   File Members  

oralib::connection Class Reference

Handles connection to an Oracle server. More...

#include <connection.h>

List of all members.

Public Methods

 connection (void)
 Creates a new connection class instance.

 connection (IN const char *service_name, IN const char *login, IN const char *password, IN OPTIONAL unsigned long env_mode=OCI_OBJECT, IN OPTIONAL bool non_blocking_mode=false)
 Creates a new connection class instance and attempts to attach and to authenticate to an Oracle server.

 ~connection ()
 connection class destructor.

void open (IN const char *service_name, IN const char *login, IN const char *password, IN OPTIONAL unsigned long env_mode=OCI_OBJECT, IN OPTIONAL bool non_blocking_mode=false)
 Attempts to attach and to authenticate to an Oracle server.

void close (void)
 Terminates user session and detaches from an Oracle server.

void execute (IN const char *sql_block, IN OPTIONAL int sql_len=-1)
 Immediately executes a SQL (or PL/SQL) statement.

statementprepare (IN const char *sql_block, IN OPTIONAL int sql_len=-1)
 Prepares (but doesn't executes) a SQL (or PL/SQL) statement.

resultsetselect (IN const char *select, IN OPTIONAL int select_len=-1)
 Executes SQL select statement and returns fetched data as a resultset.

void commit (void)
 Commits changes.

void rollback (void)
 Rollbacks changed.


Friends

class statement
class parameter
class resultset
class column


Detailed Description

Handles connection to an Oracle server.


Constructor & Destructor Documentation

oralib::connection::connection IN const char *    service_name,
IN const char *    login,
IN const char *    password,
IN OPTIONAL unsigned long    env_mode = OCI_OBJECT,
IN OPTIONAL bool    non_blocking_mode = false
 

Creates a new connection class instance and attempts to attach and to authenticate to an Oracle server.

Calls open to establish the connection. Check open() for more information.

If close method is not called connection will be automatically closed when class instance is deleted. After close connection could be reused with subsequent open call.

oralib::connection::~connection  
 

connection class destructor.

If connection is still opened close will be automatically called.


Member Function Documentation

void oralib::connection::open IN const char *    service_name,
IN const char *    login,
IN const char *    password,
IN OPTIONAL unsigned long    env_mode = OCI_OBJECT,
IN OPTIONAL bool    non_blocking_mode = false
 

Attempts to attach and to authenticate to an Oracle server.

Parameters:
service_name  specifies database server to use
login  database username
password  database password
env_mode  initial mode for environment handle connection will work under (for more information locate OCIEnvCreate in Oracle* Call Interface Programmer's Guide; OCI_OBJECT should be included in order date/time and number conversion functions to work)
non_blocking_mode  whether to open connection in non-blocking mode (at this point it is better to work in blocking mode, since non-blocking is not yet fully implemented)

Database server name, login and password should be all in ANSI and are all required (that is they cannot be NULLs). Unicode support is planned because of Oracle OCI 9.

In case of an error an exception will be thrown.

Connection should not be already opened otherwise resources will be leaked. In debug builds this rule is checked with assert statement.

void oralib::connection::close void   
 

Terminates user session and detaches from an Oracle server.

After close connection could be reused with subsequent open call.

void oralib::connection::execute IN const char *    sql_block,
IN OPTIONAL int    sql_len = -1
 

Immediately executes a SQL (or PL/SQL) statement.

Parameters:
sql_block  NULL-terminated SQL (or PL/SQL) statement to be executed
sql_len  (optional) length of the statement in characters; when -1 is passed, strlen will be used to get the string length

execute method could be used to run a DDL (data-definition language) statement, such as create table or drop table or any other SQL statement that could be called with no parameters and which doesn't return any result (for example insert or update).

Internally execute prepares the statement, calls statement::execute, and, finally calls statement::release.

In case of an error an exception will be thrown.

No cleanup is necessary after execute has been called.

statement * oralib::connection::prepare IN const char *    sql_block,
IN OPTIONAL int    sql_len = -1
 

Prepares (but doesn't executes) a SQL (or PL/SQL) statement.

Parameters:
sql_block  NULL-terminated SQL (or PL/SQL) statement to be prepared
sql_len  (optional) length of the statement in characters; when -1 is passed, strlen will be used to get the string length
Returns :
a prepared statement

prepare method could be used to prepare a SQL (or PL/SQL) statement so parameters could be bound and/or statement could be executed more than once. For example a same insert statement taking its data from bound variables could be executed several times with only changing values of the bound variables.

statement::release should be called when statement is no longer needed.

resultset * oralib::connection::select IN const char *    select,
IN OPTIONAL int    select_len = -1
 

Executes SQL select statement and returns fetched data as a resultset.

Parameters:
select  NULL-terminated select statement to be executed
select_len  (optional) length of the statement in characters; when -1 is passed, strlen will be used to get the string length
Returns :
a resultset

select method is the fastest way to execute SQL select statement.

In case of an error an exception will be thrown.

resultset::release should be called when resultset is no longer needed.


The documentation for this class was generated from the following files:
Generated on Sun Aug 18 13:56:27 2002 for OraLib by doxygen1.2.17