Next: Within-database Example, Previous: Database Macros, Up: Database Macros [Contents][Index]
within-database creates a lexical scope in which the commands
define-table and define-command create tables and
*commands*-table entries respectively in open relational
database database. The expressions in ‘within-database’ form
are executed in order.
within-database Returns database.
Adds to the *commands* table a command
<name>:
(lambda (<name> <rdb>) <expression1> <expression2> …)
where <name> is the table name, <descriptor-name> is the symbol name of a descriptor table, <primary-key-fields> and <other-fields> describe the primary keys and other fields respectively, and <rows> is a list of data rows to be added to the table.
<primary-key-fields> and <other-fields> are lists of field descriptors of the form:
(<column-name> <domain>)
or
(<column-name> <domain> <column-integrity-rule>)
where <column-name> is the column name, <domain> is the domain
of the column, and <column-integrity-rule> is an expression whose
value is a procedure of one argument (which returns #f to signal
an error).
If <domain> is not a defined domain name and it matches the name of this table or an already defined (in one of spec-0 …) single key field table, a foreign-key domain will be created for it.
The relational database database must be mutable.
add-macro-support adds a *macros* table and
define-macro macro to database; then database is
returned.
Adds a macro <name> to the *macros*.
Note: within-database creates lexical scope where not
only define-command and define-table, but every command
and macro are defined, ie.:
(within-database my-rdb
(define-command (message rdb)
(lambda (msg)
(display "message: ")
(display msg)
(newline)))
(message "Defining FOO...")
;; ... defining FOO ...
(message "Defining BAR...")
;; ... defining BAR ...
)
Next: Within-database Example, Previous: Database Macros, Up: Database Macros [Contents][Index]