]> saetta.ns0.it Git - gdadbcopy/commitdiff
Used GdaServerOperation to drop tables/views.
authorAndrea Zagli <azagli@libero.it>
Sun, 25 Nov 2012 09:42:37 +0000 (10:42 +0100)
committerAndrea Zagli <azagli@libero.it>
Sun, 25 Nov 2012 09:42:37 +0000 (10:42 +0100)
.anjuta_sym_db.db
src/main.c
tests/db.db

index ae8119988f733c8bc0f0a4e628a02a4f71866ffe..63a109627e1ec22d05f954f6d9479ef14d9e05c9 100644 (file)
Binary files a/.anjuta_sym_db.db and b/.anjuta_sym_db.db differ
index 9a03c04d7ef30d3feafda7ef2627f61219bd46f8..ea90fb3981ac4f8304b691c899c5363bdba23b92 100644 (file)
@@ -424,15 +424,38 @@ read_tables ()
 
                                        if (drop_tables)
                                                {
-                                                       gchar *sql;
-
-                                                       sql = g_strdup_printf ("DROP TABLE %s",
-                                                                              table->name);
-                                                       gda_connection_execute_non_select_command (gda_conn_db,
-                                                                                                  sql,
-                                                                                                  NULL);
+                                                       error = NULL;
+                                                       op = gda_connection_create_operation (gda_conn_db, GDA_SERVER_OPERATION_DROP_TABLE, NULL, &error);
+                                                       if (op == NULL
+                                                           || error != NULL)
+                                                               {
+                                                                       g_warning ("Error on creating GdaServerOperation: %s.",
+                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                               }
+                                                       else
+                                                               {
+                                                                       error = NULL;
+                                                                       if (!gda_server_operation_set_value_at (op, table->name, &error, 
+                                                                                                               "/TABLE_DESC_P/TABLE_NAME"))
+                                                                               {
+                                                                                       g_warning ("Error on setting GdaServerOperation's value: %s.",
+                                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                                               }
+                                                                       else
+                                                                               {
+                                                                                       error = NULL;
+                                                                                       if (!gda_connection_perform_operation (gda_conn_db, op, &error))
+                                                                                               {
+                                                                                                       g_warning ("Error on performing GdaServerOperation: %s.",
+                                                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                                                       }
+                                                                               }
+                                                               }
 
-                                                       g_free (sql);
+                                                       if (op != NULL)
+                                                               {
+                                                                       g_object_unref (op);
+                                                               }
                                                }
 
                                        /* sql builder for insert into */
@@ -550,15 +573,38 @@ read_views ()
 
                                        if (drop_tables)
                                                {
-                                                       gchar *sql;
-
-                                                       sql = g_strdup_printf ("DROP VIEW %s",
-                                                                              view_name);
-                                                       gda_connection_execute_non_select_command (gda_conn_db,
-                                                                                                  sql,
-                                                                                                  NULL);
+                                                       error = NULL;
+                                                       op = gda_connection_create_operation (gda_conn_db, GDA_SERVER_OPERATION_DROP_VIEW, NULL, &error);
+                                                       if (op == NULL
+                                                           || error != NULL)
+                                                               {
+                                                                       g_warning ("Error on creating GdaServerOperation: %s.",
+                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                               }
+                                                       else
+                                                               {
+                                                                       error = NULL;
+                                                                       if (!gda_server_operation_set_value_at (op, view_name, &error, 
+                                                                                                               "/VIEW_DESC_P/VIEW_NAME"))
+                                                                               {
+                                                                                       g_warning ("Error on setting GdaServerOperation's value: %s.",
+                                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                                               }
+                                                                       else
+                                                                               {
+                                                                                       error = NULL;
+                                                                                       if (!gda_connection_perform_operation (gda_conn_db, op, &error))
+                                                                                               {
+                                                                                                       g_warning ("Error on performing GdaServerOperation: %s.",
+                                                                                                                  error != NULL && error->message != NULL ? error->message : "no details");
+                                                                                       }
+                                                                               }
+                                                               }
 
-                                                       g_free (sql);
+                                                       if (op != NULL)
+                                                               {
+                                                                       g_object_unref (op);
+                                                               }
                                                }
 
                                        error = NULL;
index 86481fb785ce84b99270de96b8a2cfd0b4e5c059..d6c7e7119b23df6253eb0ca93b99e8077c213c6e 100644 (file)
Binary files a/tests/db.db and b/tests/db.db differ