Re: [gnome-db] GdaDataModelFilterSQL query
- From: "Vivien Malerba" <vmalerba gmail com>
- To: "Sumit Kumar Jain" <sumitskj_20 yahoo com>
- Cc: gnome-db-list gnome org
- Subject: Re: [gnome-db] GdaDataModelFilterSQL query
- Date: Sat, 1 Dec 2007 15:08:45 +0100
Hi!
The GdaDataModelFilterSQL does at the moment only support some very
simple SELECT statements, it needs to be reworked, but this is for the
next varsion which breaks the ABI as the implementation will rely on
the new virtual connection feature.
In the meanwhile, you can use that virtual connection feature directly
yourself, see the code in the "samples/Virtual" directory, and the
associated documentation
(http://library.gnome.org/devel/libgda-3.0/unstable/virtual_connection.html).
Tell me if you experience some problems.
Regards,
Vivien
On Nov 29, 2007 7:47 AM, Sumit Kumar Jain <sumitskj_20 yahoo com> wrote:
>
> Hi all,
> I have one query regarding the GdaDataModelFilterSQL class in libgda. I ran
> the below code and found out that the SQL query does not support the where
> clause. In the below code the gda_data_model_filter_sql_run() should have
> returned just one column. However when i dump the model i can see 2 columns.
> Debugging the code i found out that the where clause is not taken into
> consideration when generating results. I want to know if this is
> intentional. I looked up the API reference and could not find any thing that
> indicated to it. Please tell me if this is intentional and if i am using the
> GdaDataModelFilterSQL class correctly.
>
> ---------------- code snippet -----------------------
>
> #include <libgda/libgda.h>
> #include <stdio.h>
>
> #define NoError 0
> #define Error 1
>
> int main()
> {
> int retVal = NoError ;
> FILE *fp = NULL;
> GdaDataModelFilterSQL *filter = NULL;
> GList *list = NULL;
> GdaColumn *column1,*column2;
> GValue *value = NULL;
>
> gda_init ("TestGDA", NULL, 0, NULL);
>
> GdaDataModel *model =
> gda_data_model_array_new_with_g_types(2,G_TYPE_INT,G_TYPE_STRING);
>
> if(!model)
> {
> retVal = Error ;
> goto end;
> }
>
> if(!model || gda_data_model_get_n_columns(model) != 2)
> {
> retVal = Error ;
> goto end;
> }
>
>
> column1 = gda_data_model_describe_column(GDA_DATA_MODEL(model),0);
>
> if(!column1)
> {
> retVal = Error ;
> goto end;
> }
> gda_column_set_title(column1,"col1");
> gda_column_set_name(column1,"col1");
>
> column2 = gda_data_model_describe_column(GDA_DATA_MODEL(model),1);
>
> if(!column2)
> {
> retVal = Error ;
> goto end;
> }
>
> gda_column_set_title(column2,"col2");
> gda_column_set_name(column2,"col2");
>
> g_value_set_int(value = gda_value_new(G_TYPE_INT),10);
> list = g_list_append(list,value);
>
> g_value_set_string(value = gda_value_new(G_TYPE_STRING),"test");
> list = g_list_append(list,value);
>
> gda_data_model_append_values(GDA_DATA_MODEL(model),list,NULL);
>
> g_list_foreach(list,(GFunc)gda_value_free,NULL);
> g_list_free(list);
>
> g_value_set_int(value = gda_value_new(G_TYPE_INT),11);
> list = g_list_append(list,value);
>
> g_value_set_string(value = gda_value_new(G_TYPE_STRING),"test1");
> list = g_list_append(list,value);
>
> gda_data_model_append_values(GDA_DATA_MODEL(model),list,NULL);
>
> g_list_foreach(list,(GFunc)gda_value_free,NULL);
> g_list_free(list);
>
> filter = (GdaDataModelFilterSQL *)gda_data_model_filter_sql_new ();
> if(!filter)
> {
> retVal = Error ;
> goto end;
> }
>
> gda_data_model_filter_sql_add_source(filter,"test",model);
>
> gda_data_model_filter_sql_set_sql(filter,"select col1 from test where
> col1=10");
>
> if(!gda_data_model_filter_sql_run(filter))
> {
> retVal = Error ;
> goto end;
> }
>
> fp = fopen("test.txt","w");
>
> gda_data_model_dump(GDA_DATA_MODEL(filter),fp);
>
> fclose(fp);
>
>
> end:
>
> g_object_unref(G_OBJECT(model));
> return retVal;
> }
>
> ---------------- End code snippet -----------------------
>
>
>
> Regards,
>
> Sumit
>
>
>
> Sumit Kumar Jain
>
> Call me: +91-9880472974
>
>
> ________________________________
> Get the freedom to save as many mails as you wish. Click here to know how.
> _______________________________________________
> gnome-db-list mailing list
> gnome-db-list gnome org
> http://mail.gnome.org/mailman/listinfo/gnome-db-list
>
>
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]