]> saetta.ns0.it Git - libgdaex/commitdiff
SqlBuilder: added ::query and ::execute (closes #932, #933).
authorAndrea Zagli <azagli@libero.it>
Wed, 22 Jul 2015 15:09:17 +0000 (17:09 +0200)
committerAndrea Zagli <azagli@libero.it>
Wed, 22 Jul 2015 15:09:17 +0000 (17:09 +0200)
src/sqlbuilder.c
src/sqlbuilder.h

index dc2476346d24a0b3b95a1722d295b7b7ae7257f7..fd216221da9048ac84d3d343b39df8bdc298f391 100644 (file)
@@ -577,7 +577,7 @@ GdaSqlBuilder
  *
  * Returns:
  */
-const gchar
+gchar
 *gdaex_sql_builder_get_sql (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params)
 {
        gchar *ret;
@@ -616,6 +616,46 @@ const gchar
        return ret;
 }
 
+/**
+ * gdaex_sql_builder_query:
+ * @sqlb:
+ * @gdaex:
+ *
+ * Returns: a #GdaDataModel.
+ */
+GdaDataModel
+*gdaex_sql_builder_query (GdaExSqlBuilder *sqlb, GdaEx *gdaex, GdaSet *params)
+{
+       gchar *sql;
+       GdaDataModel *dm;
+
+       g_return_val_if_fail (IS_GDAEX (gdaex), NULL);
+
+       sql = gdaex_sql_builder_get_sql (sqlb, (GdaConnection *)gdaex_get_gdaconnection (gdaex), params);
+
+       dm = gdaex_query (gdaex, sql);
+       g_free (sql);
+
+       return dm;
+}
+
+gint
+gdaex_sql_builder_execute  (GdaExSqlBuilder *sqlb, GdaEx *gdaex, GdaSet *params)
+{
+       gchar *sql;
+       GdaDataModel *dm;
+       gint ret;
+
+       g_return_val_if_fail (IS_GDAEX (gdaex), NULL);
+
+       sql = gdaex_sql_builder_get_sql (sqlb, (GdaConnection *)gdaex_get_gdaconnection (gdaex), params);
+
+       ret = gdaex_execute (gdaex, sql);
+       g_free (sql);
+
+       return ret;
+}
+
 /* PRIVATE */
 static void
 gdaex_sql_builder_set_property (GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
index 715b87a04da327fc6e9302b8cbfae2558af9a4c9..406b306b807cfe66c5258590ce5487d8189a723e 100644 (file)
@@ -73,7 +73,10 @@ GdaSqlBuilderId gdaex_sql_builder_where (GdaExSqlBuilder *sqln, GdaSqlOperatorTy
 void gdaex_sql_builder_order (GdaExSqlBuilder *sqlb, ...);
 
 GdaSqlBuilder *gdaex_sql_builder_get_gda_sql_builder (GdaExSqlBuilder *sqlb);
-const gchar *gdaex_sql_builder_get_sql (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
+gchar *gdaex_sql_builder_get_sql (GdaExSqlBuilder *sqlb, GdaConnection *cnc, GdaSet *params);
+
+GdaDataModel *gdaex_sql_builder_query (GdaExSqlBuilder *sqlb, GdaEx *gdaex, GdaSet *params);
+gint gdaex_sql_builder_execute  (GdaExSqlBuilder *sqlb, GdaEx *gdaex, GdaSet *params);
 
 
 G_END_DECLS