Module: database-viewer Author: Andy Armstrong, Keith Playford Synopsis: A simple database viewer 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 define method open-database (database :: , #key user-name :: false-or() = #f, password :: false-or() = #f) => (connection :: ) let dbms = make(); with-dbms(dbms) let user = make(, user-name: user-name | "", password: password | ""); let db = make(, datasource-name: database); connect(db, user) end with-dbms end method open-database; define method query-database (connection :: , query :: ) => (headings :: , rows :: ) with-connection (connection) let statement = make(, text: query); let result-set = execute(statement); let results = map-as(, identity, execute(query)); let headings = statement.statement-column-names; values(headings, results) end; end method query-database; define method close-database (connection :: ) => () disconnect(connection) end method close-database; define method list-all-catalogs (connection :: ) => () with-connection (connection) catalogs() end end method list-all-catalogs;