Next: , Previous: , Up: Database Macros   [Contents][Index] Within-database

Function: within-database database statement-1 …

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.

Syntax: define-command (<name> <rdb>) "comment" <expression1> <expression2>
Syntax: define-command (<name> <rdb>) <expression1> <expression2>

Adds to the *commands* table a command <name>:

(lambda (<name> <rdb>) <expression1> <expression2> …)
Syntax: define-table <name> <descriptor-name> <descriptor-name> <rows>
Syntax: define-table <name> <primary-key-fields> <other-fields> <rows>

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>)


(<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.

Function: add-macro-support database

The relational database database must be mutable. add-macro-support adds a *macros* table and define-macro macro to database; then database is returned.

Syntax: define-macro (<name> arg1 …) "comment" <expression1> <expression2>
Syntax: define-macro (<name> arg1 …) <expression1> <expression2>

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)
  (message "Defining FOO...")
  ;; ... defining FOO ...
  (message "Defining BAR...")
  ;; ... defining BAR ...

Next: , Previous: , Up: Database Macros   [Contents][Index]