Index: unicode/src/odbc/parameter.lisp
===================================================================
--- unicode/src/odbc/parameter.lisp	(revision unicode,3)
+++ unicode/src/odbc/parameter.lisp	(revision unicode,5.1.1)
@@ -305,4 +305,24 @@
 
 
+
+;;; LOB parameters
+;;; lob parameters are handled differently, the buffer is not filled with the
+;;; parameters value but we send data at execution time.
+;;; This is done with the call:
+;;; (setf (cffi:mem-ref (slot-value param 'ind-ptr) 'sql-len)
+;;;              (%sql-len-data-at-exec (length value))))))
+;;; At execution time the result of %sql-execute or %sql-exec-direct
+;;; is $SQL_NEED_DATA. 
+;;; The next call to %sql-param-data gives the address of the data buffer 
+;;; of the needed bind parameter.
+;;; For the LOB parameters we store in this buffer the position of the
+;;; bind parameter. At execution time we get the buffer address of the
+;;; bind parameter. From this buffer we retrieve the parameter position
+;;; and so we know which parameter to send.
+;;; see functions exec-sql-statement and sql-param-data-position
+;;; in odbc-main.lisp
+;;; there is also the Microsoft documentation on SQLPutData, SQLParamData, 
+;;;  SQL_NEED_DATA  and etc.
+
 ;;;-----------------------
 ;;;    clob parameter
@@ -315,5 +335,4 @@
 
 (defclass clob-parameter (lob-parameter) ())
-
 
 (defmethod initialize-parameter ((param clob-parameter) args)
@@ -325,6 +344,6 @@
     ;; the value-ptr will be needed to find the parameter,  
     ;; we store the position there
-    (setf buffer-length (cffi:foreign-type-size 'sql-pointer))
-    (setf value-ptr (cffi:foreign-alloc 'sql-pointer))))
+    (setf buffer-length (cffi:foreign-type-size :long))
+    (setf value-ptr (cffi:foreign-alloc :long))))
 
 (defmethod set-parameter-value ((param clob-parameter) value)
@@ -375,6 +394,6 @@
     ;; the value-ptr will be needed to find the parameter,  
     ;; we store the position there
-    (setf buffer-length (cffi:foreign-type-size 'sql-pointer))
-    (setf value-ptr (cffi:foreign-alloc 'sql-pointer))))
+    (setf buffer-length (cffi:foreign-type-size :long))
+    (setf value-ptr (cffi:foreign-alloc ':long))))
 
 (defmethod set-parameter-value ((param uclob-parameter) value)
@@ -384,5 +403,5 @@
     (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) 'sql-len)
@@ -424,6 +443,6 @@
     ;; the value-ptr will be needed to find the parameter, 
     ;; we store the position there
-    (setf buffer-length (cffi:foreign-type-size 'sql-pointer))
-    (setf value-ptr (cffi:foreign-alloc 'sql-pointer)))
+    (setf buffer-length (cffi:foreign-type-size :long))
+    (setf value-ptr (cffi:foreign-alloc :long)))
 )
 
