r3067: *** empty log message ***
[umlisp.git] / sql.lisp
index 7e5ce8892f1e5d61c17b964c8711b2819cfce680..ef3be08ee04b4cd16cb7cf089fbab9a2dadb214f 100644 (file)
--- a/sql.lisp
+++ b/sql.lisp
@@ -1,11 +1,24 @@
-;;;;  -*- Mode: LISP; Syntax: Common-Lisp; Base: 10; Pkg: umlisp -*-
-;; SQL/UMLS database Layer over database backend
-;; Copyright (c) 2001 Kevin M. Rosenberg, M.D.
-;; $Id: sql.lisp,v 1.2 2002/10/08 22:13:41 kevin Exp $
+;;;; -*- Mode: Lisp; Syntax: ANSI-Common-Lisp; Base: 10; Package: umlisp -*-
+;;;; *************************************************************************
+;;;; FILE IDENTIFICATION
+;;;;
+;;;; Name:          sql.lisp
+;;;; Purpose:       Low-level SQL routines data for UMLisp
+;;;; Programmer:    Kevin M. Rosenberg
+;;;; Date Started:  Apr 2000
+;;;;
+;;;; $Id: sql.lisp,v 1.5 2002/10/16 16:05:23 kevin Exp $
+;;;;
+;;;; This file, part of UMLisp, is
+;;;;    Copyright (c) 2000-2002 by Kevin M. Rosenberg, M.D.
+;;;;
+;;;; UMLisp users are granted the rights to distribute and use this software
+;;;; as governed by the terms of the GNU General Public License.
+;;;; *************************************************************************
 
 (in-package :umlisp)
+(declaim (optimize (speed 3) (safety 1) (compilation-speed 0) (debug 3)))
 
-(declaim (optimize (speed 1) (safety 3)))
 
 (defvar *umls-sql-dsn* "KUMLS2002AC")
 (defun umls-sql-dsn ()
 
 
 
+(defun make-usrl ()
+  (with-sql-connection (conn)
+    (sql-execute "drop table if exists USRL" conn)
+    (sql-execute "create table USRL (sab varchar(80), srl integer)" conn)
+    (dolist (tuple (mutex-sql-query "select distinct SAB,SRL from MRSO order by SAB asc"))
+      (sql-execute (format nil "insert into USRL (sab,srl) values ('~a',~d)" 
+                          (car tuple) (ensure-integer (cadr tuple)))
+                  conn)))
+  (find-usrl-all))
+
+(defun find-usrl-all ()
+  (let ((usrls '())
+       (tuples (mutex-sql-query "select SAB,SRL from USRL order by SAB desc")))
+    (dolist (tuple tuples)
+      (push (make-instance 'usrl :sab (nth 0 tuple)
+                          :srl (ensure-integer (nth 1 tuple))) usrls))
+    usrls))
+
+