INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

title: "Represents the notion of connection to the database server"
project: "Visual Eiffel"
revision: "$Revision: 1.1 $"
copyright: "Copyright (C) 1996-2005 Object Tools Group"
license: "http://visual-eiffel.com/license"
cluster: dale
class DATABASE
inherit

ODBC_ELEMENT
rename
parent as session,
children as queries,
is_active as is_connected
redefine
attach,
queries,
session
end
creation

attach,
connect,
driver_connect,
make,
prompt_connect
feature -- Attributes:

name: STRING

is_connected: BOOLEAN

transact: TRANSACTION

connect_string: STRING

connect_attributes: ARRAY [CONNECTION_ATTRIBUTE]

options: DB_OPTIONS

info: DB_INFORMATION
feature -- Commands:

make
-- creation procedure; uses default session object

attach (sess: SESSION)
-- ...

prompt_connect
-- connect to data source via stardard ODBC prompt

connect (dsn, uid, pwd: STRING)
-- connect to data source
-- parameters:
-- 'dsn' - data source name
-- 'uid' - user ID
-- 'pwd' - password
require
valid_parameters: dsn /= void and uid /= void and pwd /= void

driver_connect (hwnd: INTEGER; s: STRING; dc: INTEGER)
-- connect to data source with specified connection string
-- or via the Driver Manager's connection dialog
-- parameters:
-- 'hwnd' - Windows handler - parent of dialog (0 allowed)
-- 's' - connection string (Void allowed)
-- 'dc' - defines scenario of connecting
-- see also the 'browse_connect' in advanced features section
require
valid_driver_completion: valid_driver_completion (dc)

disconnect
-- disconnect from data source
require
connected: is_connected

begin_transaction
-- begin new transaction or does nothing if transactions aren't
-- supported in this DBMS
require
transaction_is_not_open: not is_transact_open
ensure
not_auto: transact /= void implies not transact.autocommit_mode
transaction_is_open: is_transact_open

break_transaction
-- break current transaction or does nothing if transactions aren't
-- supported in this DBMS
require
transaction_is_open: is_transact_open
ensure
transaction_is_not_open: not is_transact_open

end_transaction
-- end current transaction or does nothing if transactions aren't
-- supported in this DBMS
require
transaction_is_open: is_transact_open
ensure
transaction_is_not_open: not is_transact_open

execute (s: STRING)
-- the simplest way to create and execute a query; although,
-- it supposed, there won't be any results, latter are
-- available via the 'recordset' feature
require
connected: is_connected
valid_string: s /= void and then not s.is_empty
feature -- Queries:

types: TYPES
-- returns list of data types of this database
require
connected: is_connected
ensure
not_void: Result /= void

tables: TABLES
-- returns list of tables of this database
require
connected: is_connected
ensure
not_void: Result /= void

procedures: PROCEDURES
-- returns list of stored procedures of this database
require
connected: is_connected
available: procedures_available
ensure
not_void: Result /= void

recordset: RECORDSET
-- returns a recordset if available after 'execute'
require
connected: is_connected
valid_query: query /= void

table (s: STRING): DB_TABLE
-- returns a table with specified name or Void if there's no
-- such table in this database
require
connected: is_connected
valid_string: s /= void and then not s.is_empty
accessible_tables: tables /= void

procedure (s: STRING): DB_PROCEDURE
-- returns a stored procedure with specified name or Void
-- if no such procedure in this database
require
connected: is_connected
available: procedures_available
valid_string: s /= void and then not s.is_empty
feature

session: SESSION

is_transact_open: BOOLEAN

query: QUERY

queries: SORTED_LIST_ [QUERY]
feature

procedures_supported: BOOLEAN
-- returns True only if the given data source supports
-- stored procedures
require
connected: is_connected

procedures_available: BOOLEAN
-- returns True only if the given data source supports
-- stored procedures and ODBC allows to enumerate them
require
connected: is_connected

it_is_ms_access: BOOLEAN
-- returns True if connected database is MS Access
require
connected: is_connected

it_is_ms_sql_server: BOOLEAN
-- returns True if connected database is MS SQL Server
require
connected: is_connected

it_is_informix: BOOLEAN
-- returns True if connected database is Informix
require
connected: is_connected

it_is_oracle: BOOLEAN
-- returns True if connected database is Oracle
require
connected: is_connected

it_is_DB2: BOOLEAN
-- returns True if connected database is DB/2
require
connected: is_connected

str_terminator (s: STRING; dbtype: INTEGER): STRING
-- terminator SQL string for all databases

sql_str_terminator (s: STRING): STRING
-- terminator SQL string for current database
feature -- Validations:

valid_driver_completion (dc: INTEGER): BOOLEAN
-- is this driver completion code valid?
feature

DBMS_NONE: INTEGER

DBMS_MS_Access: INTEGER

DBMS_MS_SQL_Server: INTEGER

DBMS_Informix: INTEGER

DBMS_Oracle: INTEGER

DBMS_DB2: INTEGER

DBMS_OTHER, DBMS_LAST: INTEGER

dbms_code: INTEGER
end -- class DATABASE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES