[libgdamm] Added example for new SqlBuilder function API
- From: Johannes Schmid <jhs src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [libgdamm] Added example for new SqlBuilder function API
- Date: Wed, 30 Sep 2009 20:43:24 +0000 (UTC)
commit 5ecf88711e1d55bde34afdf8d96df609362c6636
Author: Johannes Schmid <jhs gnome org>
Date: Wed Sep 30 22:43:06 2009 +0200
Added example for new SqlBuilder function API
ChangeLog | 10 +++++++++-
examples/sqlbuilder/main.cc | 29 +++++++++++++++++++++++++++++
libgda/src/row.hg | 3 +++
libgda/src/statement.hg | 2 +-
4 files changed, 42 insertions(+), 2 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 646e26b..437203f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,6 +1,14 @@
+2009-09-30 Johannes Schmid <jschmid openismis com>
+
+ * libgda/src/row.hg:
+ * libgda/src/statement.hg:
+ Added _IGNORES for provider-only methods
+ * examples/sqlbuilder:
+ Added example for new function API
+
2009-09-30 Johannes Schmid <jschmid openismus com>
- * libgda/src/libgda_methods.defs:
+ * libgda/src/libgda_methods.defs:
* libgda/src/sqlbuilder.hg/ccg:
Added wrapper for new function API (allow things like MAX() in sql statements)
* configure.ac: Require libgda-4.0 >= 3.1.3 (this is master)
diff --git a/examples/sqlbuilder/main.cc b/examples/sqlbuilder/main.cc
index c5e6b46..5444b18 100644
--- a/examples/sqlbuilder/main.cc
+++ b/examples/sqlbuilder/main.cc
@@ -65,6 +65,35 @@ int main()
sel_builder->join_add_field (5, "id");
render_as_sql(sel_builder);
+ // SELECT myfunc (a, 5, 'Joe') FROM mytable
+ Glib::RefPtr<Gnome::Gda::SqlBuilder> func_builder =
+ Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
+
+ func_builder->select_add_target(0, func_builder->ident(0, "mytable"));
+
+ std::vector<guint> args;
+ args.push_back(func_builder->ident(0, "a"));
+ args.push_back(func_builder->expr(0, Gnome::Gda::Value(5)));
+ args.push_back(func_builder->expr(0, Gnome::Gda::Value("Joe")));
+ func_builder->add_function(1, "myfunc",
+ args);
+ func_builder->add_field (1, 0);
+ render_as_sql (func_builder);
+
+ /* reuse the same GdaSqlBuilder object to have:
+ * SELECT myfunc (a, 5, 'Joe'), MAX (myfunc (a, 5, 'Joe'), b, 10) FROM mytable */
+ std::vector<guint> args2;
+ args2.push_back(1);
+ args2.push_back(3);
+ args2.push_back(4);
+ func_builder->ident(3, "b");
+ func_builder->expr (4, Gnome::Gda::Value(10));
+
+ func_builder->add_function (5, "MAX", args2);
+ func_builder->add_field (5, 0);
+
+ render_as_sql (func_builder);
+
return 0;
}
diff --git a/libgda/src/row.hg b/libgda/src/row.hg
index f910387..e84bfad 100644
--- a/libgda/src/row.hg
+++ b/libgda/src/row.hg
@@ -51,6 +51,9 @@ protected:
_WRAP_CTOR(Row(int count), gda_row_new)
public:
+ // Docs say this is mainly for providers
+ _IGNORE(gda_row_invalidate_value, gda_row_value_is_valid)
+
_WRAP_CREATE(int count)
_WRAP_METHOD(Value get_value(int num), gda_row_get_value)
diff --git a/libgda/src/statement.hg b/libgda/src/statement.hg
index 6a73beb..52b5fd9 100644
--- a/libgda/src/statement.hg
+++ b/libgda/src/statement.hg
@@ -95,7 +95,7 @@ public:
#else
Glib::ustring to_sql(const Glib::RefPtr<Set>& params, std::auto_ptr<Glib::Error>& error) const;
#endif //GLIBMM_EXCEPTIONS_ENABLED
- _IGNORE(gda_statement_to_sql)
+ _IGNORE(gda_statement_to_sql, gda_statement_to_sql_real)
typedef Glib::ListHandle< const Glib::RefPtr<Holder> > HolderSList;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]