[libgdamm] SqlBuilder: Added select_set_dictinct() and select_sect_limit().



commit 32e856f60d8d41a80296c632cd55660fc249d2a4
Author: Murray Cumming <murrayc murrayc com>
Date:   Mon Mar 29 17:26:58 2010 +0200

    SqlBuilder: Added select_set_dictinct() and select_sect_limit().
    
    * libgda/src/libgda_methods.defs: Regenerated
    * libgda/src/sqlbuilder.[hg|ccg]: Added select_set_distinct(),
        select_set_limit(), set_limit_id(), and select_set_distinct().

 ChangeLog                      |    8 ++++++
 libgda/src/libgda_methods.defs |   54 ++++++++++++++++++++++++++++++++++++++++
 libgda/src/sqlbuilder.ccg      |   16 ++++++++++++
 libgda/src/sqlbuilder.hg       |   17 ++++++++++++
 4 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 0d7b770..afcb4bf 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2010-03-29  Murray Cumming  <murrayc murrayc com>
+
+    SqlBuilder: Added select_set_dictinct() and select_sect_limit().
+
+	* libgda/src/libgda_methods.defs: Regenerated
+	* libgda/src/sqlbuilder.[hg|ccg]: Added select_set_distinct(), 
+    select_set_limit(), set_limit_id(), and select_set_distinct().
+
 2010-03-23  Murray Cumming  <murrayc murrayc com>
 
   Fix the build with the latest libgdamm, which slightly broke API and ABI.
diff --git a/libgda/src/libgda_methods.defs b/libgda/src/libgda_methods.defs
index 0eb426c..4c01b65 100644
--- a/libgda/src/libgda_methods.defs
+++ b/libgda/src/libgda_methods.defs
@@ -279,6 +279,15 @@
 
 ;; Enumerations and flags ...
 
+(define-enum BatchError
+  (in-module "Gda")
+  (c-name "GdaBatchError")
+  (gtype-id "GDA_TYPE_BATCH_ERROR")
+  (values
+    '("error" "GDA_BATCH_CONFLICTING_PARAMETER_ERROR")
+  )
+)
+
 (define-enum ConfigError
   (in-module "Gda")
   (c-name "GdaConfigError")
@@ -420,6 +429,7 @@
     '("tables" "GDA_CONNECTION_META_TABLES")
     '("views" "GDA_CONNECTION_META_VIEWS")
     '("fields" "GDA_CONNECTION_META_FIELDS")
+    '("indexes" "GDA_CONNECTION_META_INDEXES")
   )
 )
 
@@ -545,6 +555,20 @@
   )
 )
 
+(define-enum DataSelectError
+  (in-module "Gda")
+  (c-name "GdaDataSelectError")
+  (gtype-id "GDA_TYPE_DATA_SELECT_ERROR")
+  (values
+    '("modification-statement-error" "GDA_DATA_SELECT_MODIFICATION_STATEMENT_ERROR")
+    '("missing-modification-statement-error" "GDA_DATA_SELECT_MISSING_MODIFICATION_STATEMENT_ERROR")
+    '("connection-error" "GDA_DATA_SELECT_CONNECTION_ERROR")
+    '("access-error" "GDA_DATA_SELECT_ACCESS_ERROR")
+    '("sql-error" "GDA_DATA_SELECT_SQL_ERROR")
+    '("safety-locked-error" "GDA_DATA_SELECT_SAFETY_LOCKED_ERROR")
+  )
+)
+
 (define-enum EasyError
   (in-module "Gda")
   (c-name "GdaEasyError")
@@ -3367,6 +3391,11 @@
 
 ;; From gda-enum-types.h
 
+(define-function gda_batch_error_get_type
+  (c-name "gda_batch_error_get_type")
+  (return-type "GType")
+)
+
 (define-function gda_config_error_get_type
   (c-name "gda_config_error_get_type")
   (return-type "GType")
@@ -3447,6 +3476,11 @@
   (return-type "GType")
 )
 
+(define-function gda_data_select_error_get_type
+  (c-name "gda_data_select_error_get_type")
+  (return-type "GType")
+)
+
 (define-function gda_easy_error_get_type
   (c-name "gda_easy_error_get_type")
   (return-type "GType")
@@ -5359,6 +5393,26 @@
   )
 )
 
+(define-method select_set_distinct
+  (of-object "GdaSqlBuilder")
+  (c-name "gda_sql_builder_select_set_distinct")
+  (return-type "none")
+  (parameters
+    '("gboolean" "distinct")
+    '("guint" "expr_id")
+  )
+)
+
+(define-method select_set_limit
+  (of-object "GdaSqlBuilder")
+  (c-name "gda_sql_builder_select_set_limit")
+  (return-type "none")
+  (parameters
+    '("guint" "limit_count_expr_id")
+    '("guint" "limit_offest_expr_id")
+  )
+)
+
 (define-method compound_set_type
   (of-object "GdaSqlBuilder")
   (c-name "gda_sql_builder_compound_set_type")
diff --git a/libgda/src/sqlbuilder.ccg b/libgda/src/sqlbuilder.ccg
index e942d74..c139c49 100644
--- a/libgda/src/sqlbuilder.ccg
+++ b/libgda/src/sqlbuilder.ccg
@@ -96,6 +96,22 @@ guint SqlBuilder::select_join_targets(guint left_target_id, guint right_target_i
   return gda_sql_builder_select_join_targets(gobj(), 0, left_target_id, right_target_id, (GdaSqlSelectJoinType) join_type, join_expr);
 }
 
+void SqlBuilder::select_set_distinct(bool distinct)
+{
+  gda_sql_builder_select_set_distinct(gobj(), distinct, 0);
+}
+
+void SqlBuilder::select_set_limit(guint limit_count, guint offset)
+{
+  const guint id_limit = add_expr(limit_count);
+ 
+  guint id_offset = 0;
+  if(offset != 0)
+    id_offset = add_expr(offset);
+
+  gda_sql_builder_select_set_limit(gobj(), id_limit, id_offset);
+}
+
 } /* namespace Gda */
 
 } /* namespace Gnome */
diff --git a/libgda/src/sqlbuilder.hg b/libgda/src/sqlbuilder.hg
index d9f0f56..8042efd 100644
--- a/libgda/src/sqlbuilder.hg
+++ b/libgda/src/sqlbuilder.hg
@@ -176,6 +176,23 @@ public:
   
   _WRAP_METHOD(void join_add_field(guint join_id, const Glib::ustring& field_name), gda_sql_builder_join_add_field)
   _WRAP_METHOD(void select_order_by(guint expr_id, bool asc = true, const Glib::ustring& collation_name = Glib::ustring()), gda_sql_builder_select_order_by)
+
+  /** Adds or removes a DISTINCT clause for a SELECT statement.
+   * @param distinct Whether a DISTINCT clause should be in the SELECT statement.
+   * @newin4p2
+   */
+  void select_set_distinct(bool distinct = true);
+
+  _WRAP_METHOD(void select_set_distinct(bool distinct, guint expr_id), gda_sql_builder_select_set_distinct)
+
+  /** Defines the maximum number of rows in the DataModel resulting from the execution of the built statement. 
+   * @param limit_count The number of rows that should be returned.
+   * @param The offset of the first row that should appear in the result. (note that
+   * this feature may not be supported by all the database providers.)
+  */
+  void select_set_limit(guint limit_count, guint offset = 0);
+
+  _WRAP_METHOD(void select_set_limit_id(guint limit_count_expr_id, guint limit_offest_expr_id = 0), gda_sql_builder_select_set_limit)
   
   // General Statement API
   _WRAP_METHOD(void set_table(const Glib::ustring& table_name), gda_sql_builder_set_table)



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]