INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES

indexing

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

RECORDSET
export
{NONE}
attach,
build
redefine
on_attach,
on_close,
open,
query
select
copy,
is_equal,
out
end

DB_CATALOG_ITEM
rename
copy as useless_copy,
is_equal as useless_is_equal,
out as useless_out
end
creation

open
creation {TABLES}

make
feature -- Attributes:

name: STRING

owner: STRING

qualifier: STRING

type: STRING

remarks: STRING

query: SQL_SELECT
feature -- Command:

open (db: DATABASE; s: STRING)
-- redefined from RECORDSET; opens the table with
-- the specified name
ensure
valid_record: record /= void and then record.is_attached and then record.count = fields.count

add (r: like record)
-- add the specified record to the end of the table
-- note: no guarantee that this record will be really at the end
require
attached: is_attached
valid_record: valid_record (r)
allowed: is_protected implies tw_scrollable
ensure
successfully_added: is_protected implies count = count + 1

insert (cs: RS_CURSOR; r: like record)
-- insert the specified record into the recordset before
-- the current record; note: no guarantee that this record
-- will be really where the cursor declaims
require
attached: is_attached
valid_cursor: cs /= void and then is_inside (cs)
valid_record: valid_record (r)
allowed: tw_scrollable
ensure
successfully_inserted: count = count + 1
cursor_promoted: not cs.is_finished and then cs.position = cs.position + 1

put (cs: RS_CURSOR; r: like record)
-- update current record
require
attached: is_attached
valid_cursor: cs /= void and then is_inside (cs)
valid_record: valid_record (r)
allowed: tw_scrollable
ensure
size_not_changed: count = count
cursor_in_the_same_place: not cs.is_finished implies cs.position = cs.position

delete (cs: RS_CURSOR)
-- delete current record
require
attached: is_attached
valid_cursor: cs /= void and then is_inside (cs)
allowed: tw_scrollable
ensure
successfully_deleted: count = count - 1
cursor_may_be_demoted: not cs.is_finished implies cs.position <= cs.position

add_list (a: ARRAY [ANY])
-- add the record presented by list of values to the end
-- of the recordset
require
attached: is_attached
valid_list: valid_list (a)
allowed: is_protected implies tw_scrollable
ensure
successfully_added: is_protected implies count = count + 1

insert_list (cs: RS_CURSOR; a: ARRAY [ANY])
-- insert the record presented by list of values into
-- the recordset before the current record
require
attached: is_attached
valid_cursor: cs /= void and then is_inside (cs)
valid_list: valid_list (a)
allowed: tw_scrollable
ensure
successfully_inserted: count = count + 1
cursor_promoted: not cs.is_finished and then cs.position = cs.position + 1

put_list (cs: RS_CURSOR; a: ARRAY [ANY])
-- update current record by the record presented by list of values
require
attached: is_attached
valid_cursor: cs /= void and then is_inside (cs)
valid_list: valid_list (a)
allowed: tw_scrollable
ensure
size_not_changed: count = count
cursor_in_the_same_place: not cs.is_finished implies cs.position = cs.position
feature -- SQL strings:

create_sql (dbtype: INTEGER): STRING
-- Returns the SQL string which creates the table.

drop_sql (dbtype: INTEGER): STRING
-- Returns the SQL string which dropes the index.
feature -- Shortcuts:

where, filter (s: STRING)
-- set filter for records
require
attached: is_attached
valid_string: s /= void
ensure
not_protected: not is_protected

order_by (s: STRING)
-- define the order for records
require
attached: is_attached
valid_string: s /= void
ensure
not_protected: not is_protected
feature -- Query:

fields: FIELDS
-- returns table's structure
ensure
valid_result: Result /= void and then Result.count >= 0

indexes: INDEXES
-- returns table's structure
ensure
valid_result: Result /= void

primary_key: PRIMARY_KEY
-- returns table's structure
ensure
valid_result: Result /= void

empty_record: like record
-- delivers new empty record
require
attached: is_attached
ensure
well_done: Result /= void and then Result.count = record.count
feature -- Validations:

valid_record (r: like record): BOOLEAN
-- returns TRUE if the specified record is valid

valid_list (a: ARRAY [ANY]): BOOLEAN
-- returns TRUE if this array can be used as prototype
-- for a record

valid_qualifier (q: STRING): BOOLEAN
-- table qualifier is Void if and only if it isn't used

valid_owner (o: STRING): BOOLEAN
-- table owner is Void if and only if it isn't used
feature {TABLES}

make (db: DATABASE; q, o, n, t, rem: STRING)
-- creation procedure; associates this table object with
-- the specified database and assigns all table's attributes
require
valid_database: db /= void implies db.is_connected
valid_qualifier: valid_qualifier (q)
valid_owner: valid_owner (o)
valid_name: n /= void and then not n.is_empty
valid_table_type: t /= void and then not t.is_empty
end -- class DB_TABLE

INDEX CLUSTER FEATURES SHORT FRAMES NO FRAMES