Index: 64-bit/src/odbc/parameter.lisp
===================================================================
--- 64-bit/src/odbc/parameter.lisp	(revision 64-bit,1)
+++ 64-bit/src/odbc/parameter.lisp	(revision 64-bit,2.1.1)
@@ -55,7 +55,7 @@
 
 (defun bind-parameter (hstmt pos param)
-  (setf (slot-value param 'ind-ptr) 
-          (cffi:foreign-alloc :long))
-  (%sql-bind-parameter 
+  (setf (slot-value param 'ind-ptr)
+        (cffi:foreign-alloc 'sql-len))
+  (%sql-bind-parameter
    hstmt
    pos
@@ -110,18 +110,20 @@
   (cond
     ((null value)
-      (setf  (cffi:mem-ref (slot-value param 'ind-ptr) :long)
-              $SQL_NULL_DATA)
-      (put-string (slot-value param 'value-ptr) ""))
-    (t 
-      (cffi:lisp-string-to-foreign value (slot-value param 'value-ptr) (1+ (length value)))
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
-              (length  value)))))
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           $SQL_NULL_DATA)
+     (put-string (slot-value param 'value-ptr) ""))
+    (t
+     (cffi:lisp-string-to-foreign value
+                                  (slot-value param 'value-ptr)
+                                  (1+ (length value)))
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           (length value)))))
 
 (defmethod get-parameter-value ((param string-parameter))
-  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA)
-      nil
-      (progn
-        (get-string (slot-value param 'value-ptr) len)))))
+        nil
+        (progn
+          (get-string (slot-value param 'value-ptr) len)))))
 
 ;;------------------------
@@ -132,5 +134,6 @@
 
 (defmethod initialize-parameter ((param unicode-string-parameter) args)
-  (let ((length-of-buffer (* 2 (or (car args) *default-string-parameter-size*))))
+  (let ((length-of-buffer
+         (* 2 (or (car args) *default-string-parameter-size*))))
     (with-slots (value-type parameter-type buffer-length 
                             column-size value-ptr
@@ -145,19 +148,19 @@
   (cond
     ((null value)
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long) 
-              $SQL_NULL_DATA)
-      ;; not necessary
-      (%put-unicode-string (slot-value param 'value-ptr) ""))
-    (t 
-      (%put-unicode-string (slot-value param 'value-ptr) value)
-      (setf  (cffi:mem-ref (slot-value param 'ind-ptr) :long)
-              (* 2 (length  value))))))
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           $SQL_NULL_DATA)
+     ;; not necessary
+     (%put-unicode-string (slot-value param 'value-ptr) ""))
+    (t
+     (%put-unicode-string (slot-value param 'value-ptr) value)
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           (* 2 (length value))))))
 
 (defmethod get-parameter-value ((param unicode-string-parameter))
-  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA)
-      nil
-      (progn
-        (%get-unicode-string (slot-value param 'value-ptr) len))))) 
+        nil
+        (progn
+          (%get-unicode-string (slot-value param 'value-ptr) len)))))
 
 ;;----------------------
@@ -174,22 +177,22 @@
     (setf value-type $SQL_C_LONG)
     (setf parameter-type $SQL_INTEGER)
-    (setf buffer-length 4)
-    (setf value-ptr (cffi:foreign-alloc :long))))
+    (setf buffer-length (cffi:foreign-type-size 'sql-integer))
+    (setf value-ptr (cffi:foreign-alloc 'sql-integer))))
 
 (defmethod set-parameter-value ((param integer-parameter) value)
-  (cond 
+  (cond
     ((null value)
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
-              $SQL_NULL_DATA))
-    (t (setf (cffi:mem-ref (slot-value param 'value-ptr) :long) 
-               value)
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long) 0))))
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           $SQL_NULL_DATA))
+    (t (setf (cffi:mem-ref (slot-value param 'value-ptr) 'sql-integer)
+             value)
+       (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len) 0))))
 
 (defmethod get-parameter-value ((param integer-parameter))
-  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA)
-      nil
-      (progn
-        (cffi:mem-ref (slot-value param 'value-ptr) :long)))))
+        nil
+        (progn
+          (cffi:mem-ref (slot-value param 'value-ptr) 'sql-integer)))))
 
 
@@ -203,23 +206,24 @@
 (defmethod initialize-parameter ((param double-parameter) args)
   (assert (not args))
-   (with-slots (value-type parameter-type buffer-length value-ptr
-                           ind-ptr) param
-     (setf value-type $SQL_C_DOUBLE)
-     (setf parameter-type $SQL_DOUBLE)
-     (setf buffer-length 8)
-     (setf value-ptr (cffi:foreign-alloc :double ))))
+  (with-slots (value-type parameter-type buffer-length value-ptr
+                          ind-ptr) param
+    (setf value-type $SQL_C_DOUBLE)
+    (setf parameter-type $SQL_DOUBLE)
+    (setf buffer-length (cffi:foreign-type-size :double))
+    (setf value-ptr (cffi:foreign-alloc :double))))
 
 (defmethod set-parameter-value ((param double-parameter) value)
-   (cond  
-     ((null value)
-       (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long) 
-               $SQL_NULL_DATA))
-     (t 
-       (setf (cffi:mem-ref (slot-value param 'value-ptr) :double)
-               (coerce value 'double-float))
-       (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long) 8))))
+  (cond
+    ((null value)
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           $SQL_NULL_DATA))
+    (t
+     (setf (cffi:mem-ref (slot-value param 'value-ptr) :double)
+           (coerce value 'double-float))
+     (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+           (cffi:foreign-type-size :double)))))
 
 (defmethod get-parameter-value ((param double-parameter))
-    (if (= (cffi:mem-ref (slot-value param 'ind-ptr) :long) $SQL_NULL_DATA)
+  (if (= (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len) $SQL_NULL_DATA)
       nil
       (cffi:mem-ref (slot-value param 'value-ptr) :double)))
@@ -242,23 +246,22 @@
      (setf value-ptr (cffi:foreign-alloc :uchar :count 24))))
 
-
 (defmethod set-parameter-value ((param date-parameter) value)
   (if (null value)
-    (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
+      (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
             $SQL_NULL_DATA)
-    (progn
-      ;; fixme warum 1?
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long) 1)
-      (multiple-value-bind (sec min hour day month year)
-          (decode-universal-time  
-           (funcall *date-datatype-to-universal-time* value))
-        (%put-sql-c-timestamp (slot-value param 'value-ptr) year month day hour min sec 0)))))
+      (progn
+        ;; fixme warum 1?
+        (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len) 1)
+        (multiple-value-bind (sec min hour day month year)
+            (decode-universal-time
+             (funcall *date-datatype-to-universal-time* value))
+          (%put-sql-c-timestamp (slot-value param 'value-ptr) year month day hour min sec 0)))))
 
 (defmethod get-parameter-value ((param date-parameter))
-  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) :long)))
-    (if (= len $SQL_NULL_DATA) 
-      nil
-      (funcall *universal-time-to-date-dataype*
-                (timestamp-to-universal-time (slot-value param 'value-ptr))))))
+  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)))
+    (if (= len $SQL_NULL_DATA)
+        nil
+        (funcall *universal-time-to-date-dataype*
+                 (timestamp-to-universal-time (slot-value param 'value-ptr))))))
 
 
@@ -280,25 +283,24 @@
 
 (defmethod set-parameter-value ((param binary-parameter) value)
-(if (null value)
-  (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
-          $SQL_NULL_DATA)
-    (if (< (slot-value param 'buffer-length) (length value))
-      (progn
-        (error "buffer is to small")
-        ; we could increase the buffer size with another bind parameter
-        ; or set data_at_execution =1
-        )
-      (progn
-        ;(break)
-        (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long) 
-                (length value))
-        (put-byte-vector (slot-value param 'value-ptr) value)))))
+  (if (null value)
+      (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+            $SQL_NULL_DATA)
+      (if (< (slot-value param 'buffer-length) (length value))
+          (progn
+            (error "buffer is to small")
+            ;; we could increase the buffer size with another bind
+            ;; parameter or set data_at_execution =1
+            )
+          (progn
+            (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+                  (length value))
+            (put-byte-vector (slot-value param 'value-ptr) value)))))
 
 
 (defmethod get-parameter-value ((param binary-parameter))
-  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) :long)))
+  (let ((len (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)))
     (if (= len $SQL_NULL_DATA) 
-      nil
-      (get-byte-vector (slot-value param 'value-ptr) len))))
+        nil
+        (get-byte-vector (slot-value param 'value-ptr) len))))
 
 
@@ -323,16 +325,16 @@
     ;; the value-ptr will be needed to find the parameter,  
     ;; we store the position there
-    (setf buffer-length 4)
-    (setf value-ptr (cffi:foreign-alloc :long))))
+    (setf buffer-length (cffi:foreign-type-size 'sql-pointer))
+    (setf value-ptr (cffi:foreign-alloc 'sql-pointer))))
 
 (defmethod set-parameter-value ((param clob-parameter) value)
   (if (null value)
-    (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
+      (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
             $SQL_NULL_DATA)
-    (progn
-      (setf (slot-value param 'temp-val) value)
-      (setf (cffi:mem-ref (slot-value param 'value-ptr) :long) 
-                                (slot-value param 'position))
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
+      (progn
+        (setf (slot-value param 'temp-val) value)
+        (setf (cffi:mem-ref (slot-value param 'value-ptr) :long)
+              (slot-value param 'position))
+        (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
               (%sql-len-data-at-exec (length value))))))
 
@@ -373,16 +375,16 @@
     ;; the value-ptr will be needed to find the parameter,  
     ;; we store the position there
-    (setf buffer-length 4)
-    (setf value-ptr (cffi:foreign-alloc :long))))
+    (setf buffer-length (cffi:foreign-type-size 'sql-pointer))
+    (setf value-ptr (cffi:foreign-alloc 'sql-pointer))))
 
 (defmethod set-parameter-value ((param uclob-parameter) value)
   (if (null value)
-    (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
+    (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
             $SQL_NULL_DATA)
     (progn
       (setf (slot-value param 'temp-val) value)
-      (setf (cffi:mem-ref (slot-value param 'value-ptr) :long)
+      (setf (cffi:mem-ref (slot-value param 'value-ptr) ':long)
               (slot-value param 'position))
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
+      (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
                  (%sql-len-data-at-exec (* 2 (length value)))))))
 
@@ -422,17 +424,19 @@
     ;; the value-ptr will be needed to find the parameter, 
     ;; we store the position there
-    (setf buffer-length 4)
-    (setf value-ptr (cffi:foreign-alloc :long))))
+    (setf buffer-length (cffi:foreign-type-size 'sql-pointer))
+    (setf value-ptr (cffi:foreign-alloc 'sql-pointer)))
+)
 
 (defmethod set-parameter-value ((param blob-parameter) value)
   (if (null value)
-    (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
+    (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
             $SQL_NULL_DATA)
     (progn
       (setf (slot-value param 'temp-val) value)
-      (setf (cffi:mem-ref (slot-value param 'value-ptr) :long)
+      (setf (cffi:mem-ref (slot-value param 'value-ptr) ':long)
               (slot-value param 'position))
-      (setf (cffi:mem-ref (slot-value param 'ind-ptr) :long)
-              (%sql-len-data-at-exec (length value))))))
+      (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+              (%sql-len-data-at-exec (length value)))
+      )))
 
 (defmethod send-parameter-data ((param blob-parameter) hstmt)
@@ -440,5 +444,5 @@
          (len (length temp-val))
          (buffer (cffi:foreign-alloc :uchar
-                                               :count (if (zerop len) 1 len))))
+                                     :count (if (zerop len) 1 len))))
     (put-byte-vector buffer
                  temp-val)
