[Zope-Checkins] CVS: Products/DCOracle2/src - dco2.c:1.128

Matthew T. Kromer matt@zope.com
Tue, 10 Dec 2002 21:08:19 -0500


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

Modified Files:
	dco2.c 
Log Message:
Remove old (busted) native numeric mode code, add code based on OCINumber
calls.  Binding arrays of type SQLT_VNU will convert input assignments to
SQLT_VNU from the original format.  LONG values must be 40 digits or less; 40
digits is the maximum value that SQLT_VNU can accept.


=== Products/DCOracle2/src/dco2.c 1.127 => 1.128 === (451/551 lines abridged)
--- Products/DCOracle2/src/dco2.c:1.127	Mon Dec  9 17:24:55 2002
+++ Products/DCOracle2/src/dco2.c	Tue Dec 10 21:08:18 2002
@@ -175,7 +175,30 @@
 #define PYFREE(x) PyMem_Free(x)
 #endif
 
-#define NATIVENUMERIC 0			/* XXX DO NOT ENABLE -- BROKEN XXX */
+/*
+** Native Numeric mode requires connecting with OCI Object mode enabled.
+** It uses OCINumber calls to manipulate numbers as SQLT_VNU types.  Input
+** binds are still bound as INT, FLOAT, or STRING (based on if they are 
+** INT, FLOAT, or LONG python types) but binding arrays created as type
+** SQLT_VNU will convert their input parameters to SQLT_VNU.  With Native
+** numerics, output SQLT_NUM results will be requested as SQLT_VNU as well,
+** with Native Numeric off, output SQLT_NUM will be retrieved as SQLT_STR.
+*/
+#define NATIVENUMERIC 1		
+
+/* Set STRICT_SCALE=1 to make scale=0 precision=0 return floats, otheriwse
+ * it will return INTs
+ */
+
+#define STRICT_SCALE 0			
+
+/*
+** Number format string for Oracle
+*/
+
+/*                          1         2         3         4
+**                 12345678901234567890123456789012345678901234567890 */
+#define NUMFORMAT "9999999999999999999999999999999999999999D999999999"
 
 /* TRACE defines (trace globals are elsewhere)
 ** 
@@ -665,6 +688,7 @@
 CONVERTOUTF(SQLT_BIN);
 CONVERTOUTF(SQLT_AFC);
 CONVERTOUTF(SQLT_NUM);
+CONVERTOUTF(SQLT_VNU);
 CONVERTOUTF(SQLT_INT);
 CONVERTOUTF(SQLT_FLT);
 CONVERTOUTF(SQLT_DAT);
@@ -676,11 +700,6 @@
 CONVERTOUTF(SQLT_CUR);
 CONVERTOUTF(SQLT_RSET);
 
-#if NATIVENUMERIC
-static PyObject *decodeNumber(void *number, int len, int precision, int scale);
-static int encodeNumber(PyObject *object);
-#endif

[-=- -=- -=- 451 lines omitted -=- -=- -=-]

-
-	stop = m - mantissa + precision + 1;
-
-	if (exponent % 2) {
-		stop++;
-		if (exponent < 0) exponent--;
-		else exponent++;
-	}
-
-	if ((stop - (m - mantissa)) % 2) m--;
-
-	exponent /= 2;
-	exponent += 65;
-	if (sign) exponent |= 0x80;
-
-	l = 1;
-
-	printf("%02d ", exponent);
-
-	for (i = m - mantissa; i < stop; i+=2) {
-		digit = mantissa[i+1] + mantissa[i] * 10;
-		if (digit == 0 && emit == 0) continue;
-		if (!sign) digit = 101 - digit;
-		else digit++;
-		emit = 1;
-
-		printf ("%02d ", digit);
-		l++;
-	}
-
-	if (!sign && l < 22) printf("102 ");
-
-	printf("(%d)\n", l);
-
-}
-#endif
-
 /* 
 ** --------------------------------------------------------------------
 ** Trace support -- returns the address of the trace code for the
@@ -8047,6 +7891,9 @@
 #endif
 #ifdef _REENTRANT
 		"-D_REENTRANT "
+#endif
+#if STRICT_SCALE
+		"-DSTRICT_SCALE=1 "
 #endif
 	));