[Liblas-commits] r1305 - trunk/apps

liblas-commits at liblas.org liblas-commits at liblas.org
Mon Jul 6 12:18:26 EDT 2009


Author: hobu
Date: Mon Jul  6 12:18:25 2009
New Revision: 1305
URL: http://liblas.org/changeset/1305

Log:
connection parsing and block table dependency droppping

Modified:
   trunk/apps/las2oci.cpp

Modified: trunk/apps/las2oci.cpp
==============================================================================
--- trunk/apps/las2oci.cpp	(original)
+++ trunk/apps/las2oci.cpp	Mon Jul  6 12:18:25 2009
@@ -137,20 +137,23 @@
 
 }
 
-bool DeleteTable(OWConnection* connection, const char* tableName)
+bool DeleteTable(OWConnection* connection, const char* tableName, const char* cloudTableName, const char* cloudColumnName)
 {
     ostringstream oss;
     OWStatement* statement = 0;
 
-    oss << "DELETE from hobu ";
+    oss << "DELETE from " <<cloudTableName;
     statement = Run(connection, oss);
     if (statement != 0) delete statement; else return false;
     oss.str("");
 
-    // oss << "DROP table hobu ";
-    // statement = Run(connection, oss);
-    // if (statement != 0) delete statement; else return false;
-    // oss.str("");
+oss << "declare\n"
+"begin \n"
+"  mdsys.sdo_pc_pkg.drop_dependencies('"<<cloudTableName<<"', '"<<cloudColumnName<<"');"
+"end;";
+    statement = Run(connection, oss);
+    if (statement != 0) delete statement; else return false;
+    oss.str("");
     
     oss << "DROP TABLE "<< tableName ;
     statement = Run(connection, oss);
@@ -536,9 +539,20 @@
             exit(1);
         }
     }
-    
-    OWConnection* con = new OWConnection("lidar","lidar","ubuntu/crrel.local");
-    if (con->Succeeded()) std::cout <<"Oracle Connection succeded" << std::endl;
+
+    string::size_type slash_pos = connection.find("/",0);
+    username = connection.substr(0,slash_pos);
+    string::size_type at_pos = connection.find("@",slash_pos);
+    std::cout <<"slash_pos: " << slash_pos << " at_pos: " << at_pos<<std::endl;
+    password = connection.substr(slash_pos+1, at_pos-slash_pos-1);
+    instance = connection.substr(at_pos+1);
+    std::cout << "Connecting with username: " << username << " password: "<< password<< " instance: " << instance << std::endl;    
+    OWConnection* con = new OWConnection(username.c_str(),password.c_str(),instance.c_str());
+    if (con->Succeeded()) {
+        std::cout <<"Oracle connection succeded" << std::endl;
+    } else {
+        std::cout <<"Oracle connection failed" << std::endl; exit(1);
+    }
 
 
     std::istream* istrm;
@@ -558,7 +572,7 @@
     string::size_type dot_pos = input.find_first_of(".");
     string table_name = input.substr(0,dot_pos);
     
-    if (bDropTable) DeleteTable(con, table_name.c_str());
+    if (bDropTable) DeleteTable(con, table_name.c_str(), "HOBU", "CLOUD");
     CreateTable(con, table_name.c_str());
 
     LASReader* reader = new LASReader(*istrm);


More information about the Liblas-commits mailing list