[Zope-Checkins] CVS: Products/DCOracle2/DCOracle2 - DCOracle2.py:1.82

Matthew T. Kromer matt@zope.com
Mon, 25 Feb 2002 11:21:36 -0500


Update of /cvs-repository/Products/DCOracle2/DCOracle2
In directory cvs.zope.org:/tmp/cvs-serv2436/DCOracle2

Modified Files:
	DCOracle2.py 
Log Message:
merges from object test branch


=== Products/DCOracle2/DCOracle2/DCOracle2.py 1.81 => 1.82 ===
 
 DEFAULTPROCSIZE=256
+DEFAULTPROCCOUNT=256
 
 DateConversion = [None,] 
 
@@ -158,7 +159,10 @@
         113: 'BLOB',
         114: 'FLOB',
         155: 'STRING',    # Really STRING
-        156: 'DATE' 
+        156: 'DATE',
+        250: 'RECORD',      # strange documentation...
+        251: 'TABLE',       # from the net points out...
+        252: 'BOOLEAN'      # these typecodes (not official!)
     }
 
     if  type(n) == types.StringType:
@@ -426,6 +430,9 @@
 
             answer.append((dtype, size, precision, scale, isnull, inout))
 
+            if dtype == 251: # Table of
+                answer[-1] = answer[-1] + ( self.collapsedesc(args[0]) ,)
+
         if type == "table" or type == "view":
             columns = desc['OCI_ATTR_LIST_COLUMNS']
             contains = []
@@ -490,9 +497,9 @@
             rtype = Type(args[0]['OCI_ATTR_DATA_TYPE'])
             if rtype == "NUMBER" and scale != 0:
                 rtype = "%s(%s,%s)" % (rtype, precision, scale)
-            elif rtype == "NUMBER" and precision != 38 and precision != 0:
-                rtype = "%s(%s)" % (rtype, precision)
-            elif precision != 0:
+            elif rtype == "NUMBER" and precision == 38 or precision == 0:
+                pass
+            elif precision != 0 :
                 rtype = "%s(%s)" % (rtype, precision)
             returns = "returns %s " % rtype
         else: returns = ""
@@ -527,6 +534,7 @@
                     dtype = "%s(%s,%s)" % (dtype, precision, scale)
                 elif precision != 38 and precision != 0:
                     dtype = "%s(%s)" % (dtype, precision)
+            elif dtype == "TABLE": dtype = 'TABLE OF'
             elif dtype == "REF CURSOR": pass
             elif precision != 0:
                 dtype = "%s(%s)" % (dtype, precision)
@@ -544,6 +552,11 @@
             for i in range(0, len(columns)):
                 answer = "%s\n%s%s" % (answer, "\t" * indent,
                     self.decodedesc(columns[i],indent+1))
+        elif dtype == 'TABLE OF':
+            columns = desc['OCI_ATTR_LIST_ARGUMENTS']
+            for i in range(0, len(columns)):
+                answer = "%s %s" % (answer, 
+                    join(split(self.decodedesc(columns[i],indent+1))[3:]))
 
         return answer
 
@@ -577,7 +590,11 @@
             elif etype == "argument":
                 if name is not None:
                     answer = "%s%s " % (answer, name)
-                (dtype, size, precision, scale, isnull, inout) = sdesc
+                if len(sdesc) > 6:
+                   (dtype, size, precision, scale, isnull, inout, tabof) = sdesc
+                else:
+                   (dtype, size, precision, scale, isnull, inout) = sdesc
+                   tabof = ()
                 dtype = Type(dtype)
                 if dtype == "NUMBER":
                     if scale != 0:
@@ -585,6 +602,8 @@
                     elif precision != 38 and precision != 0:
                         dtype = "%s(%s)" % (dtype, precision)
                 elif dtype == "REF CURSOR": pass
+                elif dtype == "TABLE":
+                    dtype = "TABLE OF %s" % self.decodecdesc(tabof)[2:]
                 elif precision != 0:
                     dtype = "%s(%s)" % (dtype, precision)
                 answer = "%s%s %s\n" % (answer, join(inout), dtype)
@@ -652,8 +671,8 @@
     _operation = None
     _connection = None
     _mapproc = {}
-    _prefetch = (200,1048576) # default 200 records, size <= 1M
-    arraysize = 200
+    _prefetch = (20,1048576) # default 20 records, size <= 1M
+    arraysize = 20
     rowcount = -1
     description = None
     __allow_access_to_unprotected_subobjects__ = 1  # For Zope
@@ -914,9 +933,10 @@
             # XXX                                                 XXX
             # XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX XXX
 
-            baoa[c].setStatic(1)    # Mark this as a static binding
+            #baoa[c].setStatic(1)    # Mark this as a static binding
 
-            self._cursor.bindbypos(c + 1, baoa[c])
+            # ERROR -- this is too early for a normal binding array bind
+            #self._cursor.bindbypos(c + 1, baoa[c])
 
         # now populate the binding array by our batch size
         for i in xrange((rows + BATCHSZ -1) / BATCHSZ):
@@ -933,6 +953,9 @@
                         baoa[c][br] = p.value
                     else:
                         baoa[c][br] = p
+            for c in xrange(columns):
+                # (re-)bind the binding array so it has the proper length
+                self._cursor.bindbypos(c + 1, baoa[c])
 
             # Execute the batch
             result = self._cursor.execute(batchend-batchstart)
@@ -1143,19 +1166,21 @@
             v = d[1]
             # Now, if this is an IN parameter?
             #print d
-            if 'IN' in d[3][5]:
+            mode = d[3][5]
+
+            if 'IN' in mode:
                 if keymap.has_key(v):
-                    argmap.append([keymap[v], d[3][5], d[3]])
+                    argmap.append([keymap[v], mode, d[3]])
                     #print "Binding argument %s= %s" % (v, keymap[v])
                 else:
                     if len(args) <= argsused:
                         raise ValueError, "Not enough arguments"
-                    argmap.append([args[argsused], d[3][5], d[3]])
+                    argmap.append([args[argsused], mode, d[3]])
                     #print "Binding argument %s= %s" % (v, args[argsused])
                     argsused = argsused + 1
             # Otherwise, it's an OUT parameter, and we pass in NULL for those
             else: 
-                argmap.append([None, d[3][5], d[3]])
+                argmap.append([None, mode, d[3]])
 
             argconvert.append(None)
             arglist.append(str(i+1))
@@ -1186,10 +1211,21 @@
                     l = DEFAULTPROCSIZE
 
                 dty = a[2][0]
+                count = 1
 
                 # Based on the data type, we may need to do some special
                 # transforms (e.g. sending numbers through as strings)
 
+                if dty == 251: # PL/SQL Table of 
+                    # go find out what the table is really of
+                    tabof = a[2][6][3]
+                    dty = tabof[0]
+                    l = tabof[1]
+                    if len(cursor._sizes) > i:
+                        count = cursor._sizes[i] or DEFAULTPROCCOUNT
+                    else:
+                        count = DEFAULTPROCCOUNT
+
                 if dty == 102:  # SQLT_CUR
                     dty = 'SQLT_RSET'
                     l = 4   # Was 38 ?  harumph
@@ -1198,7 +1234,7 @@
                     argconvert[i] = 2
 
                 #print "Creating new BindingArray of size %s, type %s" % (l, dty)
-                ba = cursor._connection.BindingArray(1, l, dty)
+                ba = cursor._connection.BindingArray(count, l, dty)
                 olda = a[0]
                 a[0] = ba  # Swap in our new binding array for the output