indexing
     description: "Specification of the database. Generic parameter"
     date: "$Date$"
     revision: "$Revision$"

deferred class interface
     DATABASE

feature

     database_handle_name: STRING
                 -- Database handle name.
     
feature -- DATABASE_BOOLEAN

     sql_name_boolean: STRING
                 -- SQL type name for boolean
     
feature -- DATABASE_CHARACTER

     sql_name_character: STRING
                 -- SQL type name for character
     
feature -- DATABASE_DATETIME

     sql_name_datetime: STRING
                 -- SQL type name for datetime
     
feature -- DATABASE_DOUBLE

     sql_name_double: STRING
                 -- SQL type name for double
     
feature -- DATABASE_INTEGER

     sql_name_integer: STRING
                 -- SQL type name for integer
     
feature -- DATABASE_REAL

     sql_name_real: STRING
                 -- SQL type name for real
     
feature -- DATABASE_STRING

     sql_name_string: STRING
                 -- SQL type name of string
     
feature -- External features

     begin
                 -- Begin a data base transaction

     c_boolean_type: INTEGER
                 -- Boolean Eiffel type

     c_character_type: INTEGER
                 -- Character Eiffel type

     c_date_type: INTEGER
                 -- Datetime Eiffel type

     c_float_type: INTEGER
                 -- Float Eiffel type

     c_integer_type: INTEGER
                 -- Integer Eiffel type

     c_real_type: INTEGER
                 -- Real Eiffel type

     c_string_type: INTEGER
                 -- String Eiffel type

     close_cursor (no_descriptor: INTEGER)
                 -- A SQL has been performed in DYNAMIC EXECUTION mode,
                 -- Then if the DYNAMICALLY EXECUTED SQL statement is a SELECT
                 -- statement, then the cursor is closed.
                 -- Then one can do an other selection on the previous cursor.

     commit
                 -- Commit the current transaction

     connect (user_name, user_passwd, data_source, application, hostname, roleid, rolepasswd, groupid: STRING)
                 -- Connect to an ODBC database

     conv_type (indicator: INTEGER; index: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     database_make (i: INTEGER)
                 -- Initialize database c-module

     disconnect
                 -- Disconnect the current connection with an database

     exec_immediate (no_descriptor: INTEGER; command: STRING)
                 -- In IMMEDIATE EXECUTE mode perform the SQL statement,
                 -- and then check if there is warning message for the execution,

     get_boolean_data (no_descriptor: INTEGER; ind: INTEGER): BOOLEAN
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_col_len (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_col_type (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_count (no_descriptor: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_data_len (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_date_data (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_day (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_error_code: INTEGER
                 -- Function related with the error processing

     get_error_message: POINTER
                 -- Function related with the error processing

     get_float_data (no_descriptor: INTEGER; ind: INTEGER): DOUBLE
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_hour (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_integer_data (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_min (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_month (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_real_data (no_descriptor: INTEGER; ind: INTEGER): REAL
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_sec (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     get_warn_message: POINTER
                 -- Function related with the error processing

     get_year (no_descriptor: INTEGER; ind: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     identifier_quoter: STRING
                 -- Return the string used to quote identifiers in SQL command,
                 -- for example, if the quoter is `, and we want to select on
                 -- table "my table", we should express the query as:
                 -- select * from `My table`
                 -- Only for ODBC

     init_order (no_descriptor: INTEGER; command: STRING)
                 -- In DYNAMICALLY EXECUTE mode perform the SQL statement
                 -- But this routine only get things ready for dynamic execution:
                 -- 1. get the SQL statement PREPAREd; and check if there are
                 -- warning message for the SQL statement;
                 -- 2. DESCRIBE the SQL statement and get enough information to
                 -- allocate enough memory space for the corresponding descriptor.

     is_null_data (no_descriptor: INTEGER; ind: INTEGER): BOOLEAN
                 -- Is last retrieved data null?

     new_descriptor: INTEGER
                 -- A descriptor is used to store a row fetched by FETCH command
                 -- Whenever perform a SELECT statement, allocate a new descriptor
                 -- by int_new_descriptor(), the descriptor is freed
                 -- when the SELECT statement terminates.

     next_row (no_descriptor: INTEGER)
                 -- A SELECT statement is now being executed in DYNAMIC EXECUTION mode,
                 -- the  routine is to FETCH a new tuple from database
                 -- and if a new tuple is fetched, return 1 otherwise return 0.

     put_col_name (no_descriptor: INTEGER; index: INTEGER; ar: SPECIAL [CHARACTER]; max_len: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     put_data (no_descriptor: INTEGER; index: INTEGER; ar: SPECIAL [CHARACTER]; max_len: INTEGER): INTEGER
                 -- Function used to get data from structure SQLDA filled  by FETCH clause.

     qualifier_seperator: STRING
                 -- When "qualifier" and "owner" are used to identifier
                 -- a database object, they should be seperated by a string called
                 -- "qualifier seperator"
                 -- Only for ODBC

     rollback
                 -- Commit the current transaction

     sensitive_mixed: BOOLEAN
                 -- Is the database sensitive to lower or
                 -- upper case?
                 -- Only for ODBC, Ingres

     start_order (no_descriptor: INTEGER)
                 -- Finish execution of a SQL statement in DYNAMICLLY EXECUTION mode:                                                         */
                 -- 1. if the PREPAREd SQL statement is a NON_SELECT statement,
                 -- just EXECUTE it; otherwise, DEFINE a CURSOR for it and
                 -- OPEN the CURSOR. In the process, if error occurs, do some
                 -- clearence;

     terminate_order (no_descriptor: INTEGER)
                 -- A SQL has been performed in DYNAMIC EXECUTION mode,
                 -- so the routine is to do some clearence:
                 -- 1. if the DYNAMICLLY EXECUTED SQL statement is a NON_SELECT
                 -- statement, just free the memory for ODBCSQLDA and clear
                 -- the cell in 'descriptor' to NULL; otherwise, CLOSE the CURSOR
                 -- and then do the same clearence.
                 -- 2. return error number.

     trancount: INTEGER
                 -- Return the number of transactions now active
     
feature -- For DATABASE_CHANGE

     descriptor_is_available: BOOLEAN
                 -- Is a new descritor available?

     hide_qualifier (c_temp: STRING): POINTER
                 -- When "qualifier" is used to identify an database object,
                 -- we have to hide ":" in the qualifier first, otherwise, it
                 -- will be misinterpreted by feature SQL_SCAN::parse
                 -- Only for ODBC

     pre_immediate (descriptor, i: INTEGER)
                 -- In IMMEDIATE EXECUTE mode, if the performed SQL statement is
                 -- a call to a stored procedure, allocate some area used by the
                 -- stored procedure
                 -- Only for ODBC

     results_order (no_descriptor: INTEGER): INTEGER
                 -- Fetch all the rows resulting from the sql query
                 -- Default value zero
                 -- Only for Sybase
     
feature -- For DATABASE_DYN_STORE

     unset_catalog_flag (desc: INTEGER)
                 -- Default value zero
                 -- Only for ODBC.
     
feature -- For DATABASE_FORMAT

     date_to_str (object: DATE_TIME): STRING
                 -- String representation in SQL of object
                 -- For ODBC, ORACLE

     false_representation: STRING
                 -- Database representation of the boolean False

     string_format (object: STRING): STRING
                 -- String representation in SQL of object

     true_representation: STRING
                 -- Database representation of the boolean True
     
feature -- For DATABASE_PROC

     drop_proc_not_supported
                 -- Display the text saying that the database
                 -- does not support stored procedure dropping
                 -- Redefined for ODBC

     exec_proc_not_supported
                 -- Display the text saying that the database
                 -- does not support stored procedure executing
                 -- Redefined for ODBC

     has_row_number: BOOLEAN
                 -- May the database store the text of a stored procedure in more than one
                 -- row?
                 -- Default value False
                 -- Redefined for Ingres

     map_var_after: STRING
                 -- Redefined for Sybase

     map_var_before: STRING
                 -- Redefined for Sybase

     map_var_between: STRING
                 -- @ symbol for ODBC and Sybase

     map_var_between_2: STRING
                 -- Equal type
                 -- Only for Ingres

     name_proc_lower: BOOLEAN
                 -- Has the name of the stored procedure to be in lower case?

     proc_args: BOOLEAN
                 -- True if the execution of the stored procedure is
                 -- "execute procedure_name (argument1='sireude')"
                 -- False if "execute procedure_name ('sireude')"
                 -- Default value False
                 -- True for Sybase

     select_exists (name: STRING): STRING
                 -- SQL query to test stored procedure existing

     select_text: STRING
                 -- SQL query to get stored procedure text

     sql_adapt_db (sql: STRING): STRING
                 -- Adapt the SQL string for the database
                 -- Only for Sybase and ODBC

     sql_after_exec: STRING
                 -- End of the stored procedure execution string.

     sql_as: STRING
                 -- Creating a stored procedure "as"...

     sql_creation: STRING
                 -- Begining of the stored procedure creation string.

     sql_end: STRING
                 -- End of the stored procedure creation string.

     sql_execution: STRING
                 -- Begining of the stored procedure execution string.

     store_proc_not_supported
                 -- Display the text saying that the database
                 -- does not support stored procedure creating
                 -- Redefined for ODBC

     support_drop_proc: BOOLEAN
                 -- Does the database support stored procedure dropping from server?

     support_proc: INTEGER
                 -- Does the database support stored procedure?
                 -- 1 if True, 0 if False
                 -- Redefined for ODBC

     support_sql_of_proc: BOOLEAN
                 -- Does the database support SQL attachment to the stored procedure?

     support_stored_proc: BOOLEAN
                 -- Does the database support creating a stored procedure?

     text_not_supported: STRING
                 -- Display the text saying that the database
                 -- does not support stored procedure text retrieving
                 -- Redefined for ODBC
     
feature -- For DATABASE_REPOSITORY

     max_char_size: INTEGER
                 -- Limit size before being a text
                 -- Except for ODBC

     selection_string (rep_qualifier, rep_owner, repository_name: STRING): STRING
                 -- String to select the table needed

     sql_string: STRING
                 -- Database type of a string
                 -- with a size less than Max_char_size

     sql_string2 (int: INTEGER): STRING
                 -- Database type of a string
                 -- with a size more than Max_char_size
     
feature -- For DATABASE_SELECTION, DATABASE_CHANGE

     bind_parameter (value: ARRAY [ANY]; parameters: ARRAY [ANY]; descriptor: INTEGER; sql: STRING)
                 -- Bind the parameters from the parameters array with
                 -- the values from the value array. It has been implemented
                 -- for the use of dynamic sql
                 -- Only for ODBC and Oracle, it has to be done for Sybase and Ingres

     normal_parse: BOOLEAN
                 -- Should the SQL string be normal parsed,
                 -- using SQL_SCAN?

     parse (descriptor: INTEGER; uht: HASH_TABLE [ANY, STRING]; uhandle: HANDLE; sql: STRING): BOOLEAN
                 -- Prepare string sql by appending map
                 -- variables name from to sql. Map variables are used
                 -- for set input arguments
                 -- For ODBC

     result_order (descriptor: INTEGER)
                 -- Fetch one row resulting from the sql query
                 -- Default value zero
                 -- For Sybase
     
feature -- For DATABASE_STATUS

     clear_error
                 -- Reset database error status.

     found: BOOLEAN
                 -- Is there any record matching the last
                 -- selection condition used ?

     is_error_updated: BOOLEAN
                 -- Has a database function been called since last update which may have
                 -- updated error code, error message or warning message?
     
feature -- For DATABASE_STORE

     dim_rep_diff (repository_dimension, db_field_count: INTEGER): BOOLEAN
                 -- Is the dimension of the repository different to the field count of the object to insert?
                 -- If yes, make a default map_table
                 -- Default value False
                 -- Only for Sybase

     put_column_name (repository: DATABASE_REPOSITORY [like Current]; map_table: ARRAY [INTEGER]): STRING
                 -- Add the columns names to sql_string in the feature put
                 -- Redefined for ODBC

     update_map_table_error (db_handle: HANDLE; map_table: ARRAY [INTEGER]; ind: INTEGER)
                 -- Set error number as 200
                 -- Except for ODBC and for Oracle
     
feature -- For database types

     convert_string_type (r_any: ANY; field_name, class_name: STRING): ANY
                 -- Convert r_any to the expected object.
                 -- By default returns r_any, redefined in ORACLE to return
                 -- an INTEGER_REF when field_name is "data_type".
           require
                 r_any_not_void: r_any /= void
                 field_name_not_void: field_name /= void
                 class_name_not_void: class_name /= void
           ensure
                 valid_result: Result /= void
     
feature -- LOGIN and DATABASE_APPL only for password_ok

     password_ensure (name, passwd, uname, upasswd: STRING): BOOLEAN
                 -- Is name equal to uname and passwd equal to upasswd?

     password_ok (upasswd: STRING): BOOLEAN
                 -- Can the user password be Void?

     user_name_ok (uname: STRING): BOOLEAN
                 -- Can the user name be Void?
                 -- Yes only for ODBC
     
invariant

           -- from ANY
     reflexive_equality: standard_is_equal (Current)
     reflexive_conformance: conforms_to (Current)

end -- class DATABASE