[libgda] Corrected examples following GdaSqlBuilder API changes
- From: Vivien Malerba <vivien src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [libgda] Corrected examples following GdaSqlBuilder API changes
- Date: Thu, 20 May 2010 18:20:05 +0000 (UTC)
commit 8d247b46feb47c9792fcc88e369c56a37c14cdc2
Author: Vivien Malerba <malerba gnome-db org>
Date: Thu May 20 20:19:15 2010 +0200
Corrected examples following GdaSqlBuilder API changes
samples/SqlBuilder/example.c | 42 +++++++++++++++++++-------------------
samples/SqlBuilder/example_cnc.c | 2 +-
2 files changed, 22 insertions(+), 22 deletions(-)
---
diff --git a/samples/SqlBuilder/example.c b/samples/SqlBuilder/example.c
index 3fb5f0c..7740556 100644
--- a/samples/SqlBuilder/example.c
+++ b/samples/SqlBuilder/example.c
@@ -42,9 +42,9 @@ main (int argc, char *argv[])
/* reuse the same GdaSqlBuilder object to change the WHERE condition to: WHERE id = ##theid::int */
gda_sql_builder_set_where (b,
gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ,
- 1,
- gda_sql_builder_add_param (b, "theid", G_TYPE_INT, FALSE),
- 0));
+ id_field,
+ gda_sql_builder_add_param (b, "theid", G_TYPE_INT, FALSE),
+ 0));
render_as_sql (b);
g_object_unref (b);
@@ -248,15 +248,15 @@ main (int argc, char *argv[])
/* SELECT CASE WHEN price < 1.200000 THEN 2 ELSE 1 END FROM data */
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
- gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_LT,
- gda_sql_builder_add_id (b, "price"),
- gda_sql_builder_add_expr (b, NULL, G_TYPE_FLOAT, 1.2), 0);
+ id_cond = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_LT,
+ gda_sql_builder_add_id (b, "price"),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_FLOAT, 1.2), 0);
guint id_case = gda_sql_builder_add_case (b,
- 0,
- gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 1),
- 1, gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 2),
- 0);
+ 0,
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 1),
+ id_cond, gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 2),
+ 0);
gda_sql_builder_add_field_id (b, id_case, 0);
gda_sql_builder_select_add_target_id (b,
gda_sql_builder_add_id (b, "data"),
@@ -266,17 +266,17 @@ main (int argc, char *argv[])
/* SELECT CASE tag WHEN 'Alpha' THEN 1 WHEN 'Bravo' THEN 2 WHEN 'Charlie' THEN 3 ELSE 0 END FROM data */
b = gda_sql_builder_new (GDA_SQL_STATEMENT_SELECT);
- gda_sql_builder_add_case (b, 10,
- gda_sql_builder_add_id (b, "tag"),
- 0,
- gda_sql_builder_add_expr (b, NULL, G_TYPE_STRING, "Alpha"),
- gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 1),
- gda_sql_builder_add_expr (b, NULL, G_TYPE_STRING, "Bravo"),
- gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 2),
- gda_sql_builder_add_expr (b, NULL, G_TYPE_STRING, "Charlie"),
- gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 3),
- 0);
- gda_sql_builder_add_field_id (b, 10, 0);
+ id_case = gda_sql_builder_add_case (b,
+ gda_sql_builder_add_id (b, "tag"),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 0),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_STRING, "Alpha"),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 1),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_STRING, "Bravo"),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 2),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_STRING, "Charlie"),
+ gda_sql_builder_add_expr (b, NULL, G_TYPE_INT, 3),
+ 0);
+ gda_sql_builder_add_field_id (b, id_case, 0);
gda_sql_builder_select_add_target_id (b,
gda_sql_builder_add_id (b, "data"),
NULL);
diff --git a/samples/SqlBuilder/example_cnc.c b/samples/SqlBuilder/example_cnc.c
index 3cffadf..e6e4b00 100644
--- a/samples/SqlBuilder/example_cnc.c
+++ b/samples/SqlBuilder/example_cnc.c
@@ -56,7 +56,7 @@ main (int argc, char *argv[])
gda_sql_builder_set_table (b, "items");
id_field = gda_sql_builder_add_id (b, "id");
guint id_param = gda_sql_builder_add_param (b, "theid", G_TYPE_INT, FALSE);
- id_cond = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ, id_field, id_value, 0);
+ id_cond = gda_sql_builder_add_cond (b, GDA_SQL_OPERATOR_TYPE_EQ, id_field, id_param, 0);
gda_sql_builder_set_where (b, id_cond);
render_as_sql (b);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]