INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

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

SIMPLE_QUERY
rename
out as comparable_out,
compare as comparable_compare
redefine
is_active,
is_ready_for_execution,
on_attach,
on_close,
on_discard_results,
infix "<"
select
copy,
is_equal,
three_way_comparison,
infix "<"
end

STRING
rename
infix "<" as string_less,
infix "+" as string_plus,
three_way_comparison as string_three_way_comparison,
is_equal as string_is_equal,
copy as string_copy,
set as set_from_substring
select
compare,
out
end
creation

attach,
make,
send,
set
feature -- Attributes:

is_prepared: BOOLEAN

params_values: ARRAY [ANY]
feature -- Commands:
-- attach (prnt: DATABASE) is
-- -- ...
-- do
-- make (0)
-- Precursor (prnt)
-- end

set (s: STRING)
-- create query from the specified string or another query
require
not_void: s /= void

set_query_parameters (val: ANY; no: INTEGER)
-- ...
require
prepared: is_prepared

execute
-- redefined from SIMPLE_QUERY; executes query and
-- creates a recordset if there are any results

prepare
-- prepare this query on attached database
require
attached: is_attached
ready: is_ready_for_preparing
not_prepared: not is_prepared

prepare_on (db: DATABASE)
-- attach to database and prepare this query on it
require
valid_database: db /= void and then db.is_connected

send (db: DATABASE; s: STRING)
-- shortcut feature to create a query from the
-- specified string and execute it immidiately
require
valid_database: db /= void and then db.is_connected
valid_string: s /= void and then not s.is_empty
feature -- Queries:

parameters: PARAMETERS
-- query parameters
require
attached: is_attached
ensure
not_void: Result /= void

sql_string: STRING
-- returns SQL string that can be prepared or executed

to_string: STRING
-- convert to string
ensure
not_void: Result /= void
feature -- SQL composing infixes:

infix "&+", infix "+", plus_string (other: ANY): like Current
-- extend contents of the current query by 'other'
require
valid_type: valid_object_type (other, true )
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&.", infix "*", plus_char (other: CHARACTER): like Current
-- extend contents of the current query by 'other' character
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&", merge (other: ANY): like Current
-- extend contents of the current query by 'other'
-- with automitic enfoldering
-- 'other' can be QUERY, STRING, INTEGER, REAL, DOUBLE, BOOLEAN,
-- DATETIME, FIELDS or ARRAY [*]
-- note: Void means "null"
require
valid_type: valid_object_type (other, true )
ensure
well_done: Result /= void and then Result.count >= Result.count

infix "|", infix "&,", merge_via_comma (other: ANY): like Current
-- extend contents of the current query by 'other' via comma
-- with automitic enfoldering
-- 'other' can be QUERY, STRING, INTEGER, REAL, DOUBLE, BOOLEAN,
-- DATETIME, FIELDS or ARRAY [*]
-- note: Void means "null"
require
valid_type: valid_object_type (other, true )
ensure
well_done: Result /= void and then Result.count >= Result.count
feature -- Type-dependent SQL composing infixes:

infix "&b" (other: BOOLEAN): like Current
-- extend contents of the current query by 'other'
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&c" (other: CHARACTER): like Current
-- extend contents of the current query by 'other' with enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&i" (other: INTEGER): like Current
-- extend contents of the current query by 'other'
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&r" (other: REAL): like Current
-- extend contents of the current query by 'other'
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&w" (other: DOUBLE): like Current
-- extend contents of the current query by 'other'
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&s" (other: STRING): like Current
-- extend contents of the current query by 'other'
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&d" (other: DATE): like Current
-- extend contents of the current query by 'other'
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&t" (other: TIME): like Current
-- extend contents of the current query by 'other'
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "&dt" (other: TIMESTAMP): like Current
-- extend contents of the current query by 'other'
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|b", infix "&,b" (other: BOOLEAN): like Current
-- extend contents of the current query by 'other' via comma
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|c", infix "&,c" (other: CHARACTER): like Current
-- extend contents of the current query by 'other' via comma
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|i", infix "&,i" (other: INTEGER): like Current
-- extend contents of the current query by 'other' via comma
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|r", infix "&,r" (other: REAL): like Current
-- extend contents of the current query by 'other' via comma
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|w", infix "&,w" (other: DOUBLE): like Current
-- extend contents of the current query by 'other' via comma
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|s", infix "&,s" (other: STRING): like Current
-- extend contents of the current query by 'other' via comma
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|d", infix "&,d" (other: DATE): like Current
-- extend contents of the current query by 'other' via comma
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|t", infix "&,t" (other: TIME): like Current
-- extend contents of the current query by 'other' via comma
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count

infix "|dt", infix "&,dt" (other: TIMESTAMP): like Current
-- extend contents of the current query by 'other' via comma
-- with automitic enfoldering
ensure
well_done: Result /= void and then Result.count > Result.count
feature -- Attributes:

is_active: BOOLEAN
feature -- Commands:

unprotect, edit
-- turn this query to unprotected mode where the contents may be modified
ensure
not_protected: not is_protected
feature -- Queries:

is_protected: BOOLEAN
-- is modification forbidden?

is_ready_for_preparing: BOOLEAN
-- returns True if this query is currently ready to be prepared

is_ready_for_execution: BOOLEAN
-- redefined from SIMPLE_QUERY

infix "<" (other: like Current): BOOLEAN
-- redefined from ODBC_ELEMENT
feature -- Validation:

valid_object_type (v: ANY; containers_enabled: BOOLEAN): BOOLEAN
-- ...
require
not_void: v /= void
invariant

modification_allowed: is_contents_changed implies not is_protected
end -- class QUERY

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES