<!ELEMENT dbtransformer (transformation+)>
-<!ELEMENT transformation (comment?, gda_op*, sql*, drop_table*)>
+<!ELEMENT transformation (comment?,
+ gda_op*,
+ sql*,
+ drop_table*,
+ drop_view*)>
<!ATTLIST transformation
id CDATA #REQUIRED
<!ELEMENT drop_table (table_name)>
<!ELEMENT table_name (#PCDATA) #REQUIRED>
+
+<!ELEMENT drop_view (view_name)>
+
+<!ELEMENT view_name (#PCDATA) #REQUIRED>
}
else
{
- g_warning ("You must provide the name of the table.");
+ g_warning ("You must provide the name of the table to drop.");
+ ret = FALSE;
+ }
+
+ return ret;
+}
+
+static gboolean
+dbt_parse_drop_view (Dbt *dbt, xmlNodePtr xnode)
+{
+ DbtPrivate *priv;
+
+ gboolean ret;
+
+ xmlNodePtr cur;
+ gchar *view_name;
+
+ GError *error;
+
+ ret = TRUE;
+
+ priv = DBT_GET_PRIVATE (dbt);
+
+ view_name = NULL;
+ cur = xnode->children;
+ while (cur != NULL && ret)
+ {
+ if (xmlStrcmp (cur->name, (const xmlChar *)"view_name") == 0)
+ {
+ view_name = g_strstrip (g_strdup ((gchar *)xmlNodeGetContent (cur)));
+ }
+
+ cur = cur->next;
+ }
+
+ if (view_name != NULL && g_strcmp0 (view_name, "") != 0)
+ {
+ gchar *sql;
+ GdaStatement *stmt;
+
+ sql = g_strdup_printf ("DROP VIEW %s", view_name);
+
+ error = NULL;
+ stmt = gda_sql_parser_parse_string (priv->gda_parser, sql, NULL, &error);
+ if (stmt == NULL)
+ {
+ g_warning ("Unable to create GdaStatement from sql: %s.\n%s",
+ error != NULL && error->message != NULL ? error->message : "no detail",
+ sql);
+ ret = FALSE;
+ }
+ else
+ {
+ guint nrows;
+
+ nrows = gda_connection_statement_execute_non_select (priv->gda_conn, stmt, NULL, NULL, &error);
+ if (nrows == -1)
+ {
+ g_warning ("NON SELECT error: %s.\n%s",
+ error != NULL && error->message != NULL ? error->message : "no detail",
+ sql);
+ ret = FALSE;
+ }
+ g_object_unref (stmt);
+ }
+ }
+ else
+ {
+ g_warning ("You must provide the name of the view to drop.");
ret = FALSE;
}
{
tosave = dbt_parse_drop_table (dbt, xnode);
}
+ else if (xmlStrcmp (xnode->name, (const xmlChar *)"drop_view") == 0)
+ {
+ tosave = dbt_parse_drop_view (dbt, xnode);
+ }
else
{
g_warning ("Invalid tag: %s.", xnode->name);