indexing
     description: "DB_CHANGE for dynamic sql"
     date: "$Date$"
     revision: "$Revision$"

class interface
     DB_DYN_CHANGE

create

     make
                 -- Creation routine

feature -- Initialization

     make
                 -- Creation routine
     
feature -- Access

     last_parsed_query: STRING
                 -- Last parsed SQL query
                 -- (from DB_CHANGE)
     
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_executed: BOOLEAN
                 -- Is the statement has been executed ?
                 -- (from PARAMETER_HDL)

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

     is_prepared: BOOLEAN
                 -- Is the statement has been prepared ?
                 -- (from PARAMETER_HDL)

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

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

     parameter_name_exist (key: STRING): BOOLEAN
                 -- (from PARAMETER_HDL)
           require -- from PARAMETER_HDL
                 not_void: key /= 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

     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
     
feature -- Element change

     bind_parameter
                 -- Bind of the prarameters of the sql statement
           require
                 prepared_statement: is_prepared

     execute
                 -- Execute the sql statement
           require
                 prepare_statement: is_prepared

     parameter_count: INTEGER
           ensure -- from PARAMETER_HDL
                 Result > 0 implies is_prepared

     prepare (s: STRING)
                 -- Parse of the sql statement s
           require
                 not_void: s /= void
                 meaning_full_sql: s.count > 0
                 is_ok: is_ok
                 is_allocatable: is_allocatable
           ensure
                 prepared_statement: is_prepared
     
feature -- Basic operations

     execute_query
                 -- Execute modify with last_query.
                 -- (from DB_CHANGE)
           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.
                 -- (from DB_CHANGE)
           require -- from DB_CHANGE
                 connected: is_connected
                 request_exists: request /= void
                 is_ok: is_ok
           ensure -- from DB_CHANGE
                 last_query_changed: last_query = request
     
feature

     clear_all
                 -- (from PARAMETER_HDL)

     set_map_name (n: ANY; key: STRING)
                 -- Store item n whith key key.
                 -- (from PARAMETER_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

     unset_map_name (key: STRING)
                 -- Remove item associated with key key.
                 -- (from PARAMETER_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

     terminate
     
feature -- Status Report

     is_allocatable: BOOLEAN
     
feature -- setting

     set_executed (b: BOOLEAN)
                 -- (from PARAMETER_HDL)

     set_parameter (value: ANY; key: STRING)
                 -- (from PARAMETER_HDL)
           require -- from PARAMETER_HDL
                 key_not_void: key /= void
                 has_parameters: parameter_count > 0

     set_parameters_value (p: ARRAY [ANY])
                 -- (from PARAMETER_HDL)
           require -- from PARAMETER_HDL
                 has_parameters: parameter_count > 0

     set_prepared (b: BOOLEAN)
                 -- (from PARAMETER_HDL)

     setup_parameters
                 -- setup parameters_value with actual parameters value
                 -- (from PARAMETER_HDL)
     
invariant

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

end -- class DB_DYN_CHANGE