From: Andrea Zagli Date: Fri, 15 Nov 2013 08:22:44 +0000 (+0100) Subject: Use of GdaEx::get_new_id in GtkForm::get_sql. X-Git-Url: https://saetta.ns0.it/gitweb?a=commitdiff_plain;h=0749cfcf4816205c7707a7c7dd828af36c92f95b;p=libgtkform Use of GdaEx::get_new_id in GtkForm::get_sql. --- diff --git a/libgtkform/form.c b/libgtkform/form.c index 02bf80a..e35669d 100644 --- a/libgtkform/form.c +++ b/libgtkform/form.c @@ -2055,8 +2055,6 @@ gchar { if (gtk_form_field_is_auto_increment (field)) { - gchar *sql; - GdaDataModel *dm; gchar *field_name; guint new_val; @@ -2064,20 +2062,7 @@ gchar g_object_get (field, "field", &field_name, NULL); - new_val = 1; - sql = g_strdup_printf ("SELECT COALESCE (MAX (%s), 0) + 1 FROM %s", - field_name, - priv->table); - dm = gdaex_query (priv->gdaex, sql); - g_free (sql); - if (dm != NULL && gda_data_model_get_n_rows (dm) > 0) - { - new_val = gdaex_data_model_get_value_integer_at (dm, 0, 0); - } - if (dm != NULL) - { - g_object_unref (dm); - } + new_val = gdaex_get_new_id (priv->gdaex, priv->table, field_name, NULL); gtk_form_widget_set_value_stringify (gtk_form_field_get_form_widget (field), g_strdup_printf ("%d", new_val)); }