[Liblas-commits] hg: add BindClob/DefineClob methods for using CLOB columns -- us...

liblas-commits at liblas.org liblas-commits at liblas.org
Wed Mar 30 15:09:28 EDT 2011


details:   http://hg.liblas.orghg/rev/b046bca41932
changeset: 2912:b046bca41932
user:      Howard Butler <hobu.inc at gmail.com>
date:      Wed Mar 30 14:09:18 2011 -0500
description:
add BindClob/DefineClob methods for using CLOB columns -- use that for setting the PC BOUNDARY column

diffstat:

 apps/las2oci.cpp     |  20 ++++++++++++--------
 apps/oci_wrapper.cpp |  52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 apps/oci_wrapper.h   |   2 ++
 3 files changed, 66 insertions(+), 8 deletions(-)

diffs (129 lines):

diff -r 5584bb0f50ef -r b046bca41932 apps/las2oci.cpp
--- a/apps/las2oci.cpp	Mon Mar 28 10:52:41 2011 -0500
+++ b/apps/las2oci.cpp	Wed Mar 30 14:09:18 2011 -0500
@@ -387,7 +387,7 @@
                     std::string const& header_blob_column,
                     std::vector<boost::uint8_t> const& header_data,
                     std::string const& boundary_column,
-                    std::string const& bounary_wkt)
+                    std::string const& boundary_wkt)
 {
     ostringstream oss;
 
@@ -529,17 +529,21 @@
     
     }
     
-    std::string wkt(bounary_wkt); // copy the string to satisfy the compiler's const complaints
+    std::string wkt(boundary_wkt); // copy the string to satisfy the compiler's const complaints
+    
     if (!boundary_column_u.empty()){
         OCILobLocator** locator =(OCILobLocator**) VSIMalloc( sizeof(OCILobLocator*) * 1 );
-        statement->Define( locator, 1 ); 
+        statement->DefineClob( locator, 1 ); 
+    
+        
+        statement->BindClob((char*)wkt.c_str(),(long)wkt.size());
 
-        statement->Bind((char*)&(wkt[0]),(long)bounary_wkt.size());
+        // statement->Bind((char*)&(wkt[0]),(long)wkt.size());
 
-        long* srid_d = 0;
-        srid_d = (long*) malloc (1 * sizeof(long));
-        srid_d[0] = srid;
-        statement->Bind(srid_d);        
+        // long* srid_d = 0;
+        // srid_d = (long*) malloc (1 * sizeof(long));
+        // srid_d[0] = srid;
+        statement->Bind(&srid);        
     }
 
 
diff -r 5584bb0f50ef -r b046bca41932 apps/oci_wrapper.cpp
--- a/apps/oci_wrapper.cpp	Mon Mar 28 10:52:41 2011 -0500
+++ b/apps/oci_wrapper.cpp	Wed Mar 30 14:09:18 2011 -0500
@@ -695,6 +695,29 @@
         hError );
 }
 
+void OWStatement::BindClob( char* pData, long nData )
+{
+    OCIBind* hBind = NULL;
+
+    nNextBnd++;
+
+    CheckError( OCIBindByPos(
+        hStmt,
+        &hBind,
+        hError,
+        (ub4) nNextBnd,
+        (dvoid*) pData,
+        (sb4) nData,
+        (ub2) SQLT_LNG,
+        (void*) NULL,
+        (ub2*) NULL,
+        (ub2*) NULL,
+        (ub4) NULL,
+        (ub4) NULL,
+        (ub4) OCI_DEFAULT ),
+        hError );
+}
+
 void OWStatement::Bind( char* pData, long nData )
 {
     OCIBind* hBind = NULL;
@@ -1053,6 +1076,35 @@
         (ub4) OCI_DEFAULT ), hError );
 }
 
+void OWStatement::DefineClob( OCILobLocator** pphLocator, long nIterations )
+{
+    OCIDefine* hDefine = NULL;
+
+    nNextCol++;
+
+    long i;
+
+    for (i = 0; i < nIterations; i++)
+    {
+        OCIDescriptorAlloc(
+            poConnection->hEnv,
+            (void**) &pphLocator[i],
+            OCI_DTYPE_LOB, (size_t) 0, (void**) 0);
+    }
+
+    CheckError( OCIDefineByPos( hStmt,
+        &hDefine,
+        hError,
+        (ub4) nNextCol,
+        (dvoid*) pphLocator,
+        (sb4) -1,
+        (ub2) SQLT_CLOB,
+        (void*) 0,
+        (ub2*) 0,
+        (ub2*) 0,
+        (ub4) OCI_DEFAULT ), hError );
+}
+
 int OWStatement::GetInteger( OCINumber* ppoData )
 {
     sb4 nRetVal;
diff -r 5584bb0f50ef -r b046bca41932 apps/oci_wrapper.h
--- a/apps/oci_wrapper.h	Mon Mar 28 10:52:41 2011 -0500
+++ b/apps/oci_wrapper.h	Wed Mar 30 14:09:18 2011 -0500
@@ -374,6 +374,7 @@
     void                Bind( long* pnData );
     void                Bind( double* pnData );
     void                Bind( char* pData, long nData );
+    void                BindClob( char* pData, long nData );
     void                Bind( sdo_geometry** pphData );
     void                Bind( OCILobLocator** pphLocator );
     void                Bind( OCIArray** pphData, OCIType* type );
@@ -383,6 +384,7 @@
     void                Define( double* pnData );
     void                Define( char* pszData, int nSize = OWNAME );
     void                Define( OCILobLocator** pphLocator);
+    void                DefineClob( OCILobLocator** pphLocator, long nIterations );
     void                Define( OCIArray** pphData );
     void                Define( sdo_georaster** pphData );
     void                Define( sdo_geometry** pphData );


More information about the Liblas-commits mailing list