Class Database

Summary

Encapsulates an ODBC accessible database.

Superclasses:
Object

Package:
database
File:
database.icn
Methods:
abortBlock, accessDb, accessTable, close, delete, driver, endBlock, fetch, insert, limits, open, product, select, sql, startBlock, update

Methods inherited from Object:
Type, className, clone, equals, fieldNames, genMethods, getField, get_class, get_class_name, get_id, hasField, hasMethod, hash_code, instanceOf, invoke, is_instance, setField, to_string

Fields:
blockDepth, db, db_table, dbu, dsn

Source code.

Details
Constructor

Database(DSN, DB_TABLE)

Parameters:
DSN
Data store name (odbc)
DB_TABLE
 Table to access at that DSN

Methods:

abortBlock()

Abort a block transaction.


accessDb(newdb)

Parameter:
newdb
if present, database to associate with this object
Returns:
current database, which will be newdb if non-null

Access the underlying database.

Name of database to start accessing


accessTable(newTable)

Parameter:
newTable
if present, table to associate with this object
Returns:
current table, which will be newTable if non-null

Change the name of the table to access.

Name of table to start accessing


close()

Returns:
nothing useful
Fails:
if cannot close the database

Close the database.


delete(filter)

Delete entries from the database table based on some filter. e.g. db.delete("name = 'fred'") would remove all data base entries whose name field is fred. Note that calling delete with no argument deletes all entries in the table!


driver()

Returns:
database driver metadata record

Get record of database odbc driver metadata


endBlock()

Terminate a block transaction. Correctly handles nested blocks by only terminating when leaving outermost block.


fetch()

Generates:
rows that have been selected from the database

Fetch selected rows from the database. Note that, unlike the native 'fetch(db)' procedure, this method is a generator.


insert(rec)

Returns:
result of doing the insert

Insert the contents of the parameter (a table or record) into the currently active database table.

table of fields (key is field name,


limits()

Returns:
database limits

Get record of database limits


open(user, password)

Parameters:
user
Valid database user id
password
Returns:
a database access
Fails:
if unable to open database

Open a database with automatic access to a specific table

Password for that user.


product()

Returns:
database metadata record

Get record of database metadata.


select(cols:"*", filter, order)

Parameters:
cols
Columns to display (default is <b>"*"</b>)
filter
SQL where clause (w/o the 'WHERE') that identifies rows to display
order
SQL order clause (w/o the 'ORDER BY')
Returns:
result of performing query

Select rows from the currently active database table.


sql(sqlstatement)

Returns:
result of executing sqlstatement

Execute an arbitrary SQL command/query on the database

Arbitrary SQL statement


startBlock()

Start a block transaction if not in one already. Counts nested blocks to ensure correct handling of block ends.


update(rec, whereClause)

Parameters:
rec
table of fields (key is field name, entry is new field value) to update <i>(Can also be a record)</i>
whereClause
SQL where clause (w/o the 'WHERE') that identifies rows to modify
Returns:
result of updating rows

Update rows in the currently active database table.


Fields:
blockDepth

db

db_table

dbu

dsn


This page produced by UniDoc on 2021/04/15 @ 23:59:53.