#include <config.h>
#endif
+#include <stdarg.h>
#include <string.h>
#include <gio/gio.h>
else
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
ret = NULL;
}
if (error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else
{
if (error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else
{
if (error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else
{
if (error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else
{
if (v == NULL || error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else if (!gda_value_is_null (v))
{
if (v == NULL || error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else if (!gda_value_is_null (v))
{
if (v == NULL || error != NULL)
{
g_warning ("Error on retrieving field's value: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else if (!gda_value_is_null (v))
{
if (error != NULL)
{
g_warning ("Error opening transaction: %s\n",
- error->message);
+ error->message != NULL ? error->message : "no details");
}
else
{
if (error != NULL)
{
g_warning ("Error parsing sql: %s\n%s\n",
- error->message, sql);
+ error->message != NULL ? error->message : "no details", sql);
return -1;
}
if (error != NULL)
{
g_warning ("Error executing command query: %s\n%s",
- error->message, sql);
+ error->message != NULL ? error->message : "no details", sql);
return -1;
}
else
return nrecs;
}
+/**
+ * gdaex_batch_execute:
+ * @gdaex: a #GdaEx object.
+ * @...: a #NULL terminated list of sql texts.
+ *
+ */
+GSList
+*gdaex_batch_execute (GdaEx *gdaex, ...)
+{
+ GSList *ret;
+
+ va_list ap;
+
+ gchar *sql;
+ GdaStatement *stmt;
+ GError *error;
+
+ GdaDataModel *dm;
+ gint recs;
+
+ g_return_val_if_fail (IS_GDAEX (gdaex), NULL);
+
+ GdaExPrivate *priv = GDAEX_GET_PRIVATE (gdaex);
+
+ ret = NULL;
+
+ va_start (ap, gdaex);
+
+ while ((sql = va_arg (ap, gchar *)) != NULL)
+ {
+ error = NULL;
+ stmt = gda_sql_parser_parse_string (priv->gda_parser, sql, NULL, &error);
+ if (error != NULL)
+ {
+ g_warning ("Error parsing sql: %s\n%s\n",
+ error->message != NULL ? error->message : "no details", sql);
+ return NULL;
+ }
+
+ if (gda_statement_get_statement_type (stmt) == GDA_SQL_STATEMENT_SELECT)
+ {
+ dm = gdaex_query (gdaex, sql);
+ ret = g_slist_append (ret, dm);
+ }
+ else
+ {
+ recs = gdaex_execute (gdaex, sql);
+ ret = g_slist_append (ret, GINT_TO_POINTER (recs));
+ }
+ }
+
+ va_end (ap);
+
+ return ret;
+}
+
/**
* gdaex_commit:
* @gdaex: a #GdaEx object.