Module: dylan-user Author: eec Copyright: Original Code is Copyright (c) 1995-2004 Functional Objects, Inc. All rights reserved. License: Functional Objects Library Public License Version 1.0 Dual-license: GNU Lesser General Public License Warranty: Distributed WITHOUT WARRANTY OF ANY KIND // $HopeName: !library.dylan(D-kan.4) $ define library sql use functional-dylan; use generic-arithmetic; use c-ffi; use io; export sql; end library; define module result-set create , // Open abstract class , // Open abstract class // Parents: , // Open concrete class // Parents: , // Open abstract class // Parents: , // Open abstract class // Parents: liaison, // GF: liaison result-set => function // result-set Instance of . // function Instance of . // Returns the liaison function associated with result-set. // The liaison function is invoked by SQL on each record // retrieved from the database. The results of the liaision // function make up the content of the result-set. // Liaison signature: fn(record :: ) => (obj :: ) liaison-setter; create , // Open concrete class // Parents: rowset-size, // GF: rowset-size policy => size // policy Instance of . // size Instance of type-union(, singleton(#"all")). // Returns the rowset-size of policy. scrollable?, // GF: scrollable? policy => scrollable? // policy Instance of . // scrollable? Instance of . // Returns the scrollable indicator of policy. scroll-window, // GF: scroll-window policy => window-size // policy Instance of . // window-size Instance of . // Returns the scroll-window size of policy. asynchronous, // GF: asynchronous policy => async? // policy Instance of . // async? Instance of . // Returns the asynchronous indicator of policy. $default-result-set-policy, // Constant Module Variable: $scrollable-result-set-policy, // Constant Module Variable: record-available?; // GF: record-available? result-set index => available? // result-set Instance of . // index Instance of . // available? Instance of . // Indicates if record with key index is available without blocking. // Useful if result-set is retrieving records asynchronously. create , // Open abstract class // Parents: , // Open abstract class // Parents: is-null?, // GF: is-null? record column-key => null-state // record Instance of . // column-key Instance of . // null-state Instance of . // Returns a null-value indication for the supplied column key. indicator-policy, // GF: indicator-policy record => policy // record Instance of . // policy Instance of . // Returns the indicator policy of record. (This value is from the // SQL statement object supplied to the execute method.) record-coercion-policy; // GF: record-coercion-policy record => policy // record Instance of . // policy Instance of . // Returns the coercion policy of record. (This value is from the // SQL statement object supplied to the execute method.) create , // Constant module variable // Type: type-union(singleton($default-conercion), ) default-conversion, // GF: default-conversion value => converted-value // value Instance of . // converted-value Instance of . // Performs the default conversion of value. // The SQL library provides a default conversion for C-FFI // objects to a Dylan object. $default-coercion, // Constant Module Variable: #"default-coercion" $no-coercion, // Constant Module Variable: #"no-coercion" convert-value, // GF: convert-value coercion-policy value key => converted-value // coercion-policy Instance of . // value Instance of . // key Instance of . // converted-value Instance of . // Converts value as dictated by coercion-policy indexed by key. acquire-null-value; // GF: acquire-null-value indicator index => null-value // indicator Instance of . // index Instance of . // null-value Instance of . // Returns the apporiate null-value from indicator as indicated // by the index. create $no-indicator, // Constant module variable: #"no-indicator" ; // Constant module variable // type: type-union(singleton($no-indicator), ) end module; define module sql use result-set, import: all, export: all; create , // Open abstract class // Parents: dbms-name, dbms-version, \with-dbms, // Statement macro: with-dbms(dbms) body end with-dbms; // Establishes dbms as the default dbms for the execution of body. // If, within the execution of body, the make method is invoked // on , , or , dbms-specific instances // of these classes will be created. connections, // GF: connections #key dbms => seq // dbms An instance of false-or(). // seq Instance of . // Returns a sequence of all active connections against the supplied // dbms or a sequence of all active connections if dbms is #f. multiple-connections?, // GF: multiple-connections? dbms => status // dbms An instance of . // status An instance of . // Returns #t if multiple connections are supported on dbms otherwise, // #f is returned. disconnect-all; // GF: disconnect-all #key dbms => () // dbms An instance of false-or(). // Terminates all connections served by dbms. If dbms is #f, all // active connections are terminated. create , // Open abstract class // Parents: , // Open abstract class // Parents: connect, // GF: connect database user => connection // database Instance of . // user Instance of . // connection Instance of . // Establishes a connection to the given database for the supplied // user. connect-with-prompt, // GF: connect-with-prompt dbms #key database user => connection // dbms Instance of . // database Instance of . // user Instance of . // connection Instance of . // Prompts the user for the information necessary to connect to a // given database and establishes a connection to this database. // Use connect-with-prompt? to determine if this feature is supported. connect-with-prompt?; // GF: connect-with-prompt? dbms => promptable? // dbms Instance of . // promptable? Instance of . // Returns #t if dbms supports the connect-with-prompt feature. create , // Open abstract class // Parents: dbms, // GF: dbms connection => dbms // connection Instance of . // dbms Instance of . // Returns the dbms object associated with connection. database, // GF: database connection => database // connection Instance of . // database Instance of . // Returns the database object associated with connection. user, // GF: user connection => user // connection Instance of . // user Instance of . // Returns the user object associated with connection. disconnect; // GF: disconnect connection #key terminate-statements => () // connection Instance of . // terminate-statements Instance of . // Terminates the given connection. If any SQL statements are executing // asynchronously or a SQL-select statement has results pending, a // condition will be signaled unless terminate-statements is #t. create default-dbms, // GF: default-dbms => dbms // dbms Instance of . // Returns the dbms established by the with-dbms macro. Signals // if no default dbms has be established. default-connection, // GF: default-connection => connection // connection Instance of . // Returns the connection established by the with-database or // with-connection macro. Signals if no // default connection has not been established. *all-connections*, // For use in implementing DBMS-specific implementation of sql. // Clients of sql or any dbms-specific implementation of // sql should not call this method. *all-connections-lock*, // For use in implementing DBMS-specific implementation of sql. \with-connection, // Statement Macro: with-connection(connection) body end // Within the dynamic scope of body, establishes connection as the // default connection. The result of the macro is the last expression // executed within body. \with-database, // Statement Macro: with-database(database, user) body end // This macro applies the connect function to its parameters and // establishes the resulting connection as the default connection // within the dynamic scope of body. The connection is terminated // when execution leaves the scope of body. The result of this macro // is the last expression in body executed. \sql, // Statement macro: NOT IMPLEMENTED!! make-dbms-specific; // For use in implementing DBMS-specific implementation of sql. // Clients of sql or any dbms-specific implementation of // sql should not call this method. create , // Open concrete class // Parents: $null-value; // Constant Module Variable: // The canonical null-value. create , // Open abstract class // Parents: execute, // GF: execute statement #key all-keys => result-set // statement Instance of . // result-set Instance of false-or(). // Sends the statement to the DBMS server for execution. , // Open abstract class // Parents: statement-column-names, text, // GF: text statement => text // statement Instance of . // text Instance of . // Returns a string containing the text of statement text-setter, // GF: text-setter text statement => text // text Instance of . // statement Instance of . // Changes the text of statement output-indicator, // GF: output-indicator statement => indicators // statement Instance of . // indicators Instance of . // Returns the output-indicator for statement. output-indicator-setter, // GF: output-indicator-setter indicators statement => indicators // indicators Instance of . // statement Instance of . // Sets the output-indicator for statement to indicators. input-indicator, // GF: input-indicator statement => indicators // statement Instance of . // indicators Instance of . // Returns input-indicator for statement. input-indicator-setter, // GF: input-indicator-setter indicators statement => indicators // indicators Instance of . // statement Instance of . // Changes the input-indicator of statement to indicators. coercion-policy, // GF: coercion-policy statement => policy // statement Instance of . // policy Instance of . // Returns the coercion-policy of statement. coercion-policy-setter, // GF: coercion-policy-setter policy statement => policy // policy Instance of . // statement Instance of . // Changes the coercion-policy of statement to policy. datatype-hints, // GF: datatype-hints statement => hints // statement Instance of . // hints Instance of // Returns the datatype-hints of statement. datatype-hints-setter; // GF: datatype-hints-setter hints statement => hints // hints Instance of . // statement Instance of . // Changes the datatype-hints of statement. create // SQL specific conditions. , // Open concrete class // Parents: , // Open concrete class // Parents: , // Open concrete class // Parents: , // Open concrete class // Parents: , // Open concrete class // Parents: ; // Open concrete class // Parents: create , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ; create , , , , , , constraints, , , , , , catalogs, catalogs-assist, // I don't like having to export this! column-name, default-value, domain, indexes, nullable?, unique-index?, indexed-table, indexed-table-setter, fields, fields-setter, connection, connection-setter, database-object-name, database-object-name-setter; create catalog-from-name, schema-from-name, table-from-name, , , , ; create rollback-transaction, commit-transaction, default-diagnostics-size, default-transaction-mode, default-isolation-level, default-diagnostics-size, \with-transaction; create , , , , class-code, subclass-code, , conditions-not-recorded?, row-count, command-function, dynamic-function, condition-number, returned-sqlstate, class-origin, subclass-origin, constraint-catalog, constraint-schema, constraint-name, connection-name, environment-name, catalog-name, schema-name, table-name, column-name, cursor-name, message-text, possible-explanation, next-dbms-diagnostic, diagnostic-to-string; create , install-diagnostic, install-diagnostic-key, installation-functions, register-diagnostic-installer, find-diagnostic, $diagnostic-table; create , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ; create , transaction-mode, transaction-mode-setter, isolation-level, isolation-level-setter, diagnostics-size, diagnostics-size-setter; //++ Do not export to client applications. create start-transaction, end-transaction; create , $read-only, $read-write; create , $read-uncommitted, $read-committed, $repeatable-read, $serializable; end module; define module result-set-implementation use functional-dylan; use generic-arithmetic, prefix: "big/"; use dylan-extensions; use machine-words; use machine-word-lowlevel; use c-ffi; use format-out; use finalization; use sql; use result-set; end module; define module sql-implementation use functional-dylan; use threads; use finalization; use sql; use result-set; use format-out; use format; end module sql-implementation;