Re: ORA-01000: maximum open cursors exceeded

Edi Weitz <[email protected]> Thu, 08 Sep 2005 16:45:04 +0200
Newsgroups gmane.lisp.clsql.devel
Message-ID <[email protected]>
On Thu, 8 Sep 2005 08:10:16 -0600, Kevin Rosenberg <kevin-HJRc7zDS/[email protected]> wrote:

> I'm releasing version 3.2.2 now with the simple solution (and a few
> minor UFFI foreign object cleanups. Perhaps you wouldn't mind
> testing it.

I had to apply the attached patch to make it compile but other than
that it seems to work fine and the problems I reported are gone.

Once again - thanks for the quick fix!

Cheers,
Edi.

_______________________________________________
CLSQL-Devel mailing list
[email protected]
http://lists.b9.com/mailman/listinfo/clsql-devel
clsql.diff (text/x-patch, 3.1 KB)
diff -ru /tmp/clsql-3.2.2-orig/db-oracle/oracle-sql.lisp clsql-3.2.2/db-oracle/oracle-sql.lisp
--- /tmp/clsql-3.2.2-orig/db-oracle/oracle-sql.lisp	2005-09-08 08:10:42.000000000 +0200
+++ clsql-3.2.2/db-oracle/oracle-sql.lisp	2005-09-08 16:39:43.121126400 +0200
@@ -129,7 +129,7 @@
   (cond
     (database
      (with-slots (errhp) database
-       (let ((errcode (uffi:allocate-foreign-string :long))
+       (let ((errcode (uffi:allocate-foreign-object :long))
 	     (errbuf (uffi:allocate-foreign-string #.+errbuf-len+)))
 	 ;; ensure errbuf empty string
 	 (setf (uffi:deref-array errbuf '(:array :unsigned-char) 0)
@@ -469,35 +469,36 @@
 
 (defun sql-stmt-exec (sql-stmt-string db result-types field-names)
   (with-slots (envhp svchp errhp) db
-    (let ((stmthp (uffi:allocate-foreign-object :pointer-void)))
+    (let ((stmthp (uffi:allocate-foreign-object :pointer-void))
+          select-p)
+      
       (uffi:with-foreign-object (stmttype :unsigned-short)
-
 	(unwind-protect
-	     (progn
-	       (oci-handle-alloc (deref-vp envhp)
-				 stmthp
-				 +oci-htype-stmt+ 0 +null-void-pointer-pointer+)
-	       (oci-stmt-prepare (deref-vp stmthp)
-				 (deref-vp errhp)
-				 (uffi:convert-to-cstring sql-stmt-string)
-				 (length sql-stmt-string)
-				 +oci-ntv-syntax+ +oci-default+ :database db)
-	       (oci-attr-get (deref-vp stmthp)
-			     +oci-htype-stmt+
-			     stmttype
-			     +unsigned-int-null-pointer+
-			     +oci-attr-stmt-type+
-			     (deref-vp errhp)
-			     :database db)
-
-	       (let* ((select-p (= (uffi:deref-pointer stmttype :unsigned-short) 1))
-		      (iters (if select-p 0 1)))
-
-		 (oci-stmt-execute (deref-vp svchp)
-				   (deref-vp stmthp)
-				   (deref-vp errhp)
-				   iters 0 +null-void-pointer+ +null-void-pointer+ +oci-default+
-				   :database db)))
+            (progn
+              (oci-handle-alloc (deref-vp envhp)
+                                stmthp
+                                +oci-htype-stmt+ 0 +null-void-pointer-pointer+)
+              (oci-stmt-prepare (deref-vp stmthp)
+                                (deref-vp errhp)
+                                (uffi:convert-to-cstring sql-stmt-string)
+                                (length sql-stmt-string)
+                                +oci-ntv-syntax+ +oci-default+ :database db)
+              (oci-attr-get (deref-vp stmthp)
+                            +oci-htype-stmt+
+                            stmttype
+                            +unsigned-int-null-pointer+
+                            +oci-attr-stmt-type+
+                            (deref-vp errhp)
+                            :database db)
+              
+              (setq select-p (= (uffi:deref-pointer stmttype :unsigned-short) 1))
+              (let ((iters (if select-p 0 1)))
+
+                (oci-stmt-execute (deref-vp svchp)
+                                  (deref-vp stmthp)
+                                  (deref-vp errhp)
+                                  iters 0 +null-void-pointer+ +null-void-pointer+ +oci-default+
+                                  :database db)))
 	  ;; free resources unless a query
 	  (unless select-p
 	    (oci-handle-free (deref-vp stmthp) +oci-htype-stmt+)