/*****************************************************************************
FILE:               O2CI7Context.h
LANGUAGE:           Objective-C
SYSTEM:             GNUstep
USER-INTERFACE:     None
DESCRIPTION

    This class is a private class of the GNUstep/db adaptor to the 
    Oracle databases.
    It implements an object interface to the O2CI7 primitives.
    It's implementation is based on the O2CI7 v7, and should be compatible
    with, at least, both Oracle7 and Oracle8 databases.

AUTHORS
    <PJB> Pascal J. Bourguignon <pjb@imaginet.fr>
MODIFICATIONS
    1999/07/25 Creation.
BUGS
    - ...
LEGAL
    Written by:  Pascal J. Bourguignon <pjb@imaginet.fr>
    Funds from:  Orange Concept (http://www.orange-concept.com/)
    Date:        August 1999 - February 2000

    This file is part of the Oracle7 Adaptor, GNUstep Database Library.
    The Oracle7 Adaptor allows access to Oracle[678] databases from GDL.

    Copyright (C) 2000 Free Software Foundation, Inc.

    This  library is  free software;  you can  redistribute  it and/or
    modify it under the terms of the GNU Lesser General Public License
    as published by the Free  Software Foundation; either version 2 of
    the License, or (at your option) any later version.

    This library  is distributed in the  hope that it  will be useful,
    but  WITHOUT ANY WARRANTY;  without even  the implied  warranty of
    MERCHANTABILITY or FITNESS FOR  A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have  received a copy of the  GNU Lesser General Public
    License  along  with this  library;  if  not,  write to  the  Free
    Software  Foundation, Inc.,  59 Temple  Place, Suite  330, Boston,
    MA 02111-1307 USA
*****************************************************************************/
#ifndef __O2CI7Context_h__
#define __O2CI7Context_h__
#include <O2CI7Object.h>
#include <O2CI7Cursor.h>
#include <oci.h>
#include <ocidem.h>



@interface O2CI7Context:O2CI7Object
{
    Lda_Def         lda;                      //valid only when isConnected.
    ub4             hda[512/*HDA_SIZE*//sizeof(ub4)];//valid only when isConnected.
    BOOL            isConnected;
    BOOL            doAutoCommit;
    text*           tname;
    text*           tword;
    text*           tstring;
}


// NSObject methods:

    -(id)init;
    -(void)dealloc;


// O2CI7Context methods:

    +(void)initializeWithMode:(ub4)mode;
        /*
            DO:         Initialize the OCI API.
                        The mode parameter of the opinit() call indicates 
                        whether the application making the call is running 
                        a single- or multi-threaded environment. 
                        mode=OCI_EV_DEF ==> single threaded.
                        mode=OCI_EV_TSF ==> multiple threaded.

            NOTE:       Only the first message is taken into account. 
                        The initialization can be done only once per process.
        */



    -(BOOL)loginName:(NSString*)name 
            password:(NSString*)password 
            connectString:(NSString*)connectString;
        /*
            RETURN:     Whether the login succeeded.
        */

    -(BOOL)logout;
        /*
            RETURN:     Whether the logout succeeded.
        */

    -(BOOL)isConnected;
        /*
            RETURN:     The context is connected to the database.
        */




    -(BOOL)setAutoCommit:(BOOL)autoCommit;
        /*
            RETURN:     Whether setAutoCommit: succeeded.
        */

    -(BOOL)transCommit;
        /*
            RETURN:     Whether the transaction successfully commited.
        */

    -(BOOL)transRollback;
        /*
            RETURN:     Whether the transaction successfully rolled back.
        */


    -(O2CI7Cursor*)openCursor;


    -(void)reportErrorFromOCI;
    -(void)reportErrorOnLogout;
    -(void)reportErrorAlreadyConnected;
    -(void)reportErrorNotConnected;
    -(void)reportErrorCode:(ub2)rc functionCode:(ub1)fc;
    -(NSString*)errorMessageForCode:(ub2)rc;
    -(NSString*)functionNameForCode:(ub1)fc;


    -(Lda_Def*)lda;

@end // O2CI7Context;



#endif /* __O2CI7Context_h__ */
/*** O2CI7Context.h                   -- 2000-02-21 07:11:19 -- PJB ***/
