/* create an SQL parser */
parser = gda_connection_create_parser (priv->gda_conn);
- if (!parser) /* @cnc doe snot provide its own parser => use default one */
+ if (!parser) /* @cnc does not provide its own parser => use default one */
{
parser = gda_sql_parser_new ();
}
return ret;
}
+static gboolean
+dbt_parse_sql (Dbt *dbt, xmlNodePtr xnode)
+{
+ DbtPrivate *priv;
+
+ gchar *sql;
+ GError *error;
+ GdaStatement *stmt;
+ GdaSqlParser *parser;
+
+ gboolean ret;
+
+ ret = TRUE;
+
+ priv = DBT_GET_PRIVATE (dbt);
+
+ parser = g_object_get_data (G_OBJECT (priv->gda_conn), "parser");
+ if (!parser)
+ {
+ g_warning ("Invalid sql parser.");
+ return;
+ }
+
+ sql = (gchar *)xmlNodeGetContent (xnode);
+
+ error = NULL;
+ stmt = gda_sql_parser_parse_string (parser, g_strstrip (sql), NULL, &error);
+ if (stmt == NULL)
+ {
+ g_warning ("Unable to create GdaStatement from sql: %s\n%s",
+ sql, error && error->message ? error->message : "No detail");
+ 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\n", sql,
+ error && error->message ? error->message : "No detail");
+ ret = FALSE;
+ }
+ g_object_unref (stmt);
+ }
+
+ return ret;
+}
+
void
dbt_transform (Dbt *dbt)
{
xpresult = xmlXPathEvalExpression ((const xmlChar *)"child::dbtransformation", xpcontext);
if (!xmlXPathNodeSetIsEmpty (xpresult->nodesetval))
{
- GdaSqlParser *parser = g_object_get_data (G_OBJECT (priv->gda_conn), "parser");
- if (!parser)
- {
- g_warning ("Invalid sql parser.");
- return;
- }
-
xnodeset = xpresult->nodesetval;
if (xnodeset->nodeNr < 1)
xnode = xnodeset->nodeTab[i]->children;
while (xnode != NULL)
{
- if (!xmlNodeIsText (xnode)
- && xmlStrcmp (xnode->name, (const xmlChar *)"sql") == 0)
+ if (!xmlNodeIsText (xnode))
{
- gchar *sql = (gchar *)xmlNodeGetContent (xnode);
-
- GdaStatement *stmt;
-
- error = NULL;
- stmt = gda_sql_parser_parse_string (parser, g_strstrip (sql), NULL, &error);
- if (stmt == NULL)
+ if (xmlStrcmp (xnode->name, (const xmlChar *)"sql") == 0)
{
- g_warning ("Unable to create GdaStatement from sql: %s\n%s",
- sql, error && error->message ? error->message : "No detail");
- tosave = FALSE;
+ tosave = dbt_parse_sql (dbt, xnode);
+ }
+ else if (xmlStrcmp (xnode->name, (const xmlChar *)"gda_op") == 0)
+ {
+ //tosave = dbt_parse_gda_op (dbt, xnode);
}
else
{
- guint 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\n", sql,
- error && error->message ? error->message : "No detail");
- tosave = FALSE;
- }
- g_object_unref (stmt);
+ g_warning ("Invalid tag: %s", xnode->name);
+ tosave = FALSE;
}
}
- else if (!xmlNodeIsText (xnode))
- {
- g_warning ("Invalid tag: %s", xnode->name);
- tosave = FALSE;
- }
xnode = xnode->next;
}