Module: sql-implementation 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: !sql.dylan(D-kan.6) $ define open abstract class () end class; define open generic dbms-name(dbms :: , #key connection :: ) => (dbms-name :: ); define open generic dbms-version(dbms :: , #key connection :: ) => (dbms-version :: ); define open generic connections(#key dbms :: false-or()) => (connection-sequence :: ); define method connections(#key dbms: the-dbms :: false-or()) => (connection-sequence :: ) with-lock(*all-connections-lock*) if (~the-dbms) *all-connections*; else choose(compose(curry(\=, the-dbms), dbms), *all-connections*); end if; end with-lock; end method; define open generic multiple-connections?(dbms :: ) => (multiple-connections-status :: ); define open generic disconnect-all(#key dbms :: false-or()) => (); define method disconnect-all(#key dbms: the-dbms :: false-or()) => () for (a-connection in *all-connections*) if (~the-dbms | a-connection.dbms = the-dbms) disconnect(a-connection); end if; end for; end method; define open abstract class () end class; define open abstract class () end class; define open generic connect(database :: , user :: , #key) => (connection :: ); define open generic connect-with-prompt (dbms :: , #key database :: false-or(), user :: false-or()) => (connection :: ); define open generic connect-with-prompt?(dbms :: ) => (connect-with-prompt-status :: ); define constant $read-only = #"read-only"; define constant $read-write = #"read-write"; define constant = one-of($read-only, $read-write); define constant $read-uncommitted = #"read-uncommitted"; define constant $read-committed = #"read-committed"; define constant $repeatable-read = #"repeatable-read"; define constant $serializable = #"serializable"; define constant = one-of($read-uncommitted, $read-committed, $repeatable-read, $serializable); define open concrete class () slot transaction-mode :: , required-init-keyword: transaction-mode:; slot isolation-level :: , required-init-keyword: isolation-level:; slot diagnostics-size :: , required-init-keyword: diagnostics-size:; end class; define open abstract class () constant slot dbms :: , required-init-keyword: dbms:; end class; define open generic dbms(connection :: ) => (dbms :: ); define open generic database(connection :: ) => (database :: ); define open generic user(connection :: ) => (user :: ); define open generic disconnect (connection :: , #key terminate-statements :: ) => (); define open concrete class () end class; define constant $null-value :: = make(); define open abstract class () end class; define open generic execute (database-statement :: type-union(, ), #key, #all-keys) => (result-set :: false-or()); define method execute(sql-statement :: , #rest more-args, #key parameters :: = #(), coercion-policy :: = $default-coercion, datatype-hints :: = #()) => (result-set :: false-or()) let statement = make(, text: sql-statement, coercion-policy: coercion-policy, datatype-hints: datatype-hints); apply(execute, statement, more-args); end method; define open abstract class () slot text :: , required-init-keyword: text:; slot input-indicator :: = $null-value, init-keyword: input-indicator:; slot output-indicator :: = $null-value, init-keyword: output-indicator:; slot coercion-policy :: = $default-coercion, init-keyword: coercion-policy:; slot datatype-hints :: = #(), init-keyword: datatype-hints:; end class; define open generic statement-column-names (statement :: ) => (column-names :: ); define open generic text(sql-statement :: ) => (sql-statement-text :: ); define open generic text-setter (new-text :: , sql-statement :: ) => (new-text :: ); define open generic output-indicator(sql-statement :: ) => (output-indicator :: ); define open generic output-indicator-setter (new-output-indicator :: , sql-statement :: ) => (new-output-indicator :: ); define open generic input-indicator(sql-statement :: ) => (input-indicator :: ); define open generic input-indicator-setter (new-input-indicator :: , sql-statement :: ) => (new-input-indicator :: );