return ret;
}
+const gchar
+*gdaex_query_editor_get_sql_select (GdaExQueryEditor *qe)
+{
+ gchar *ret;
+ const gchar *sql;
+
+ gchar *start;
+ gchar *end;
+
+ ret = NULL;
+
+ sql = gdaex_query_editor_get_sql (qe);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "SELECT");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ end = g_strstr_len (sql, -1, "FROM");
+ if (end == NULL)
+ {
+ return ret;
+ }
+
+ ret = g_strndup (start + 7, strlen (sql) - 8 - strlen (end));
+
+ return ret;
+}
+
+const gchar
+*gdaex_query_editor_get_sql_from (GdaExQueryEditor *qe)
+{
+ gchar *ret;
+ const gchar *sql;
+
+ gchar *start;
+ gchar *end;
+
+ ret = NULL;
+
+ sql = gdaex_query_editor_get_sql (qe);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "FROM");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ end = g_strstr_len (sql, -1, "WHERE");
+ if (end == NULL)
+ {
+ end = g_strstr_len (sql, -1, "ORDER BY");
+ }
+
+ ret = g_strndup (start + 5, strlen (start) - (end != NULL ? 6 : 5) - (end != NULL ? strlen (end) : 0));
+
+ return ret;
+}
+
+const gchar
+*gdaex_query_editor_get_sql_where (GdaExQueryEditor *qe)
+{
+ gchar *ret;
+ const gchar *sql;
+
+ gchar *start;
+ gchar *end;
+
+ ret = NULL;
+
+ sql = gdaex_query_editor_get_sql (qe);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "WHERE");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ end = g_strstr_len (sql, -1, "ORDER BY");
+
+ ret = g_strndup (start + 6, strlen (start) - (end != NULL ? 7 : 6) - (end != NULL ? strlen (end) : 0));
+
+ return ret;
+}
+
+const gchar
+*gdaex_query_editor_get_sql_order (GdaExQueryEditor *qe)
+{
+ gchar *ret;
+ const gchar *sql;
+
+ gchar *start;
+
+ ret = NULL;
+
+ sql = gdaex_query_editor_get_sql (qe);
+ if (sql == NULL)
+ {
+ return ret;
+ }
+
+ start = g_strstr_len (sql, -1, "ORDER BY");
+ if (start == NULL)
+ {
+ return ret;
+ }
+
+ ret = g_strndup (start + 9, strlen (start) - 9);
+
+ return ret;
+}
+
+
xmlNode
*gdaex_query_editor_get_sql_as_xml (GdaExQueryEditor *qe)
{
gint size;
+ /* SQL */
sql = (gchar *)gdaex_query_editor_get_sql ((GdaExQueryEditor *)user_data);
sql = g_strjoinv ("%%", g_strsplit (sql, "%", -1));
GtkWidget *dialog = gtk_message_dialog_new (GTK_WINDOW (w),
GTK_BUTTONS_OK,
sql);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);;
+ gtk_widget_destroy (dialog);
+
+ /* SQL SELECT */
+ sql = (gchar *)gdaex_query_editor_get_sql_select ((GdaExQueryEditor *)user_data);
+ sql = g_strjoinv ("%%", g_strsplit (sql, "%", -1));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ sql);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (sql);
+
+ /* SQL FROM */
+ sql = (gchar *)gdaex_query_editor_get_sql_from ((GdaExQueryEditor *)user_data);
+ sql = g_strjoinv ("%%", g_strsplit (sql, "%", -1));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ sql);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (sql);
+ /* SQL WHERE */
+ sql = (gchar *)gdaex_query_editor_get_sql_where ((GdaExQueryEditor *)user_data);
+ sql = g_strjoinv ("%%", g_strsplit (sql, "%", -1));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ sql);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (sql);
+
+ /* SQL ORDER */
+ sql = (gchar *)gdaex_query_editor_get_sql_order ((GdaExQueryEditor *)user_data);
+ sql = g_strjoinv ("%%", g_strsplit (sql, "%", -1));
+ dialog = gtk_message_dialog_new (GTK_WINDOW (w),
+ GTK_DIALOG_DESTROY_WITH_PARENT,
+ GTK_MESSAGE_INFO,
+ GTK_BUTTONS_OK,
+ sql);
+ gtk_dialog_run (GTK_DIALOG (dialog));
+ gtk_widget_destroy (dialog);
+ g_free (sql);
+
+ /* XML */
doc = xmlNewDoc ("1.0");
node = gdaex_query_editor_get_sql_as_xml ((GdaExQueryEditor *)user_data);
xmlDocSetRootElement (doc, node);
GTK_BUTTONS_OK,
buf);
gtk_dialog_run (GTK_DIALOG (dialog));
- gtk_widget_destroy (dialog);;
+ gtk_widget_destroy (dialog);
}
int
field->type = GDAEX_QE_FIELD_TYPE_TEXT;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->available_where_type = GDAEX_QE_WHERE_TYPE_STARTS
| GDAEX_QE_WHERE_TYPE_CONTAINS
| GDAEX_QE_WHERE_TYPE_ENDS
field->type = GDAEX_QE_FIELD_TYPE_TEXT;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->available_where_type = GDAEX_QE_WHERE_TYPE_STRING
| GDAEX_QE_WHERE_TYPE_IS_NULL;
gdaex_query_editor_table_add_field (qe, "clients", *field);
field->type = GDAEX_QE_FIELD_TYPE_DATE;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->available_where_type = GDAEX_QE_WHERE_TYPE_DATETIME
| GDAEX_QE_WHERE_TYPE_IS_NULL;
gdaex_query_editor_table_add_field (qe, "clients", *field);
field->type = GDAEX_QE_FIELD_TYPE_INTEGER;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->available_where_type = GDAEX_QE_WHERE_TYPE_NUMBER;
gdaex_query_editor_table_add_field (qe, "clients", *field);
g_free (field);
field->type = GDAEX_QE_FIELD_TYPE_DATETIME;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->available_where_type = GDAEX_QE_WHERE_TYPE_DATETIME
| GDAEX_QE_WHERE_TYPE_IS_NULL;
gdaex_query_editor_table_add_field (qe, "clients", *field);
field->type = GDAEX_QE_FIELD_TYPE_INTEGER;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->decode_table2 = g_strdup ("cities");
field->decode_join_type = GDAEX_QE_JOIN_TYPE_LEFT;
/*field->decode_fields1 = g_slist_append (field->decode_fields1, "id_cities");
field->type = GDAEX_QE_FIELD_TYPE_DOUBLE;
field->for_show = TRUE;
field->for_where = TRUE;
+ field->for_order = TRUE;
field->available_where_type = GDAEX_QE_WHERE_TYPE_NUMBER;
gdaex_query_editor_table_add_field (qe, "orders", *field);
g_free (field);