From: Andrea Zagli Date: Wed, 22 Jul 2015 15:09:17 +0000 (+0200) Subject: SqlBuilder: added ::query and ::execute (closes #932, #933). X-Git-Tag: v0.6.0~3 X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=75681c9aa8236c0b736c4bc61ba49766575afbae;p=libgdaex SqlBuilder: added ::query and ::execute (closes #932, #933). --- diff --git a/src/sqlbuilder.c b/src/sqlbuilder.c index dc24763..fd21622 100644 --- a/src/sqlbuilder.c +++ b/src/sqlbuilder.c @@ -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) diff --git a/src/sqlbuilder.h b/src/sqlbuilder.h index 715b87a..406b306 100644 --- a/src/sqlbuilder.h +++ b/src/sqlbuilder.h @@ -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