Copyright (C) 2000-2012 |
GNU Info (slib.info)Table OperationsTable Operations ---------------- These are the descriptions of the methods available from an open relational table. A method is retrieved from a table by calling the table with the symbol name of the operation. For example: (define telephone-table-desc ((my-database 'create-table) 'telephone-table-desc)) (require 'common-list-functions) (define ndrp (telephone-table-desc 'row:insert)) (ndrp '(1 #t name #f string)) (ndrp '(2 #f telephone (lambda (d) (and (string? d) (> (string-length d) 2) (every (lambda (c) (memv c '(#\0 #\1 #\2 #\3 #\4 #\5 #\6 #\7 #\8 #\9 #\+ #\( #\ #\) #\-))) (string->list d)))) string)) Some operations described below require primary key arguments. Primary keys arguments are denoted KEY1 KEY2 .... It is an error to call an operation for a table which takes primary key arguments with the wrong number of primary keys for that table. The term "row" used below refers to a Scheme list of values (one for each column) in the order specified in the descriptor (table) for this table. Missing values appear as `#f'. Primary keys must not be missing. - Function: get column-name Returns a procedure of arguments KEY1 KEY2 ... which returns the value for the COLUMN-NAME column of the row associated with primary keys KEY1, KEY2 ... if that row exists in the table, or `#f' otherwise. ((plat 'get 'processor) 'djgpp) => i386 ((plat 'get 'processor) 'be-os) => #f - Function: get* column-name Returns a procedure of optional arguments MATCH-KEY1 ... which returns a list of the values for the specified column for all rows in this table. The optional MATCH-KEY1 ... arguments restrict actions to a subset of the table. See the match-key description below for details. ((plat 'get* 'processor)) => (i386 8086 i386 8086 i386 i386 8086 m68000 m68000 m68000 m68000 m68000 powerpc) ((plat 'get* 'processor) #f) => (i386 8086 i386 8086 i386 i386 8086 m68000 m68000 m68000 m68000 m68000 powerpc) (define (a-key? key) (char=? #\a (string-ref (symbol->string key) 0))) ((plat 'get* 'processor) a-key?) => (m68000 m68000 m68000 m68000 m68000 powerpc) ((plat 'get* 'name) a-key?) => (atari-st-turbo-c atari-st-gcc amiga-sas/c-5.10 amiga-aztec amiga-dice-c aix) - Function: row:retrieve Returns a procedure of arguments KEY1 KEY2 ... which returns the row associated with primary keys KEY1, KEY2 ... if it exists, or `#f' otherwise. ((plat 'row:retrieve) 'linux) => (linux i386 linux gcc) ((plat 'row:retrieve) 'multics) => #f - Function: row:retrieve* Returns a procedure of optional arguments MATCH-KEY1 ... which returns a list of all rows in this table. The optional MATCH-KEY1 ... arguments restrict actions to a subset of the table. See the match-key description below for details. ((plat 'row:retrieve*) a-key?) => ((atari-st-turbo-c m68000 atari turbo-c) (atari-st-gcc m68000 atari gcc) (amiga-sas/c-5.10 m68000 amiga sas/c) (amiga-aztec m68000 amiga aztec) (amiga-dice-c m68000 amiga dice-c) (aix powerpc aix -)) - Function: row:remove Returns a procedure of arguments KEY1 KEY2 ... which removes and returns the row associated with primary keys KEY1, KEY2 ... if it exists, or `#f' otherwise. - Function: row:remove* Returns a procedure of optional arguments MATCH-KEY1 ... which removes and returns a list of all rows in this table. The optional MATCH-KEY1 ... arguments restrict actions to a subset of the table. See the match-key description below for details. - Function: row:delete Returns a procedure of arguments KEY1 KEY2 ... which deletes the row associated with primary keys KEY1, KEY2 ... if it exists. The value returned is unspecified. - Function: row:delete* Returns a procedure of optional arguments MATCH-KEY1 ... which Deletes all rows from this table. The optional MATCH-KEY1 ... arguments restrict deletions to a subset of the table. See the match-key description below for details. The value returned is unspecified. The descriptor table and catalog entry for this table are not affected. - Function: row:update Returns a procedure of one argument, ROW, which adds the row, ROW, to this table. If a row for the primary key(s) specified by ROW already exists in this table, it will be overwritten. The value returned is unspecified. - Function: row:update* Returns a procedure of one argument, ROWS, which adds each row in the list of rows, ROWS, to this table. If a row for the primary key specified by an element of ROWS already exists in this table, it will be overwritten. The value returned is unspecified. - Function: row:insert Adds the row ROW to this table. If a row for the primary key(s) specified by ROW already exists in this table an error is signaled. The value returned is unspecified. - Function: row:insert* Returns a procedure of one argument, ROWS, which adds each row in the list of rows, ROWS, to this table. If a row for the primary key specified by an element of ROWS already exists in this table, an error is signaled. The value returned is unspecified. - Function: for-each-row Returns a procedure of arguments PROC MATCH-KEY1 ... which calls PROC with each ROW in this table in the (implementation-dependent) natural ordering for rows. The optional MATCH-KEY1 ... arguments restrict actions to a subset of the table. See the match-key description below for details. _Real_ relational programmers would use some least-upper-bound join for every row to get them in order; But we don't have joins yet. The (optional) MATCH-KEY1 ... arguments are used to restrict actions of a whole-table operation to a subset of that table. Those procedures (returned by methods) which accept match-key arguments will accept any number of match-key arguments between zero and the number of primary keys in the table. Any unspecified MATCH-KEY arguments default to `#f'. The MATCH-KEY1 ... restrict the actions of the table command to those records whose primary keys each satisfy the corresponding MATCH-KEY argument. The arguments and their actions are: `#f' The false value matches any key in the corresponding position. an object of type procedure This procedure must take a single argument, the key in the corresponding position. Any key for which the procedure returns a non-false value is a match; Any key for which the procedure returns a `#f' is not. other values Any other value matches only those keys `equal?' to it. - Function: close-table Subsequent operations to this table will signal an error. - Constant: column-names - Constant: column-foreigns - Constant: column-domains - Constant: column-types Return a list of the column names, foreign-key table names, domain names, or type names respectively for this table. These 4 methods are different from the others in that the list is returned, rather than a procedure to obtain the list. - Constant: primary-limit Returns the number of primary keys fields in the relations in this table. automatically generated by info2www version 1.2.2.9 |