indexing
     status: "See notice at end of class"
     date: "$Date$"
     revision: "$Revision$"
     access: change, modify, update, insert, delete
     product: eiffelstore
     database: all_bases

class interface
     DB_CHANGE

create

     make
                 -- Create an interface object to change active base.

feature -- Access

     last_parsed_query: STRING
                 -- Last parsed SQL query
     
feature -- Status report

     is_connected: BOOLEAN
                 -- Has connection to the database server succeeded?
                 -- (from DB_STATUS_USE)

     is_ok: BOOLEAN
                 -- Is last SQL statement ok ?
                 -- (from DB_STATUS_USE)
     
feature -- Status report

     is_mapped (key: STRING): BOOLEAN
                 -- Is key mapped to an Eiffel entity?
                 -- (from STRING_HDL)
           require -- from STRING_HDL
                 keys_exists: key /= void

     last_query: STRING
                 -- Last SQL statement used
                 -- (from DB_EXPRESSION)

     mapped_value (key: STRING): ANY
                 -- Value mapped with key
                 -- (from STRING_HDL)
           require -- from STRING_HDL
                 key_exists: key /= void
                 key_mapped: is_mapped (key)
           ensure -- from STRING_HDL
                 result_exists: Result /= void
     
feature -- Status setting

     set_trace
                 -- Trace queries sent to database server.
                 -- (from DB_EXEC_USE)
           ensure -- from DB_EXEC_USE
                 trace_status: is_tracing
     
feature -- Status setting

     clear_all
                 -- Remove all mapped keys.
                 -- (from STRING_HDL)

     set_map_name (n: ANY; key: STRING)
                 -- Store item n with key key.
                 -- n can be Void.
                 -- (from STRING_HDL)
           require -- from STRING_HDL
                 key_exists: key /= void
                 not_key_in_table: not is_mapped (key)
           ensure -- from STRING_HDL
                 ht.count = old ht.count + 1

     set_query (query: STRING)
                 -- Set last_query with query.
                 -- (from DB_EXPRESSION)
           require -- from DB_EXPRESSION
                 query_not_void: query /= void
           ensure -- from DB_EXPRESSION
                 last_query_changed: last_query = query

     unset_map_name (key: STRING)
                 -- Remove item associated with key key.
                 -- (from STRING_HDL)
           require -- from STRING_HDL
                 key_exists: key /= void
                 item_exists: is_mapped (key)
           ensure -- from STRING_HDL
                 ht.count = old ht.count - 1
     
feature -- Basic operations

     execute_query
                 -- Execute modify with last_query.
           require -- from DB_EXPRESSION
                 last_query_not_void: last_query /= void

     modify (request: STRING)
                 -- Execute request to modify persistent objects.
                 -- When using the DBMS layer the request must be
                 -- SQL-like compliant.
           require
                 connected: is_connected
                 request_exists: request /= void
                 is_ok: is_ok
           ensure
                 last_query_changed: last_query = request
     
invariant

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

end -- class DB_CHANGE