Re: [gnome-db] libgda cursor support
- From: "Vivien Malerba" <vmalerba gmail com>
- To: "Murray Cumming" <murrayc murrayc com>
- Cc: gnome-db-list <gnome-db-list gnome org>
- Subject: Re: [gnome-db] libgda cursor support
- Date: Wed, 26 Sep 2007 10:29:30 +0200
On 9/25/07, Murray Cumming <murrayc murrayc com> wrote:
> On Wed, 2007-09-19 at 14:10 +0200, Vivien Malerba wrote:
> > This means that the total number of rows of the returned data model is
> > not yet known, you need to iterate over it to reach the end, at which
> > time the total number of rows will be known and
> > gda_data_model_get_n_rows() will return something >= 0.
>
> That doesn't seem to be working. Am I missing something in the attached
> test code? It gives me this output:
>
> murrayc murrayc-desktop:~$ ./a.out
> row=0
> value=NULL
> row=1
> value=NULL
> row=2
> value=NULL
> row=3
> value=NULL
> gda_data_model_get_n_rows()=-1 after iterating.
You can't use gda_data_model_get_value_at () when you are using a
cursor, that API call is for random access (I should make that clear
in the doc), here is my small correction:
[...]
GdaDataModelIter *iter = gda_data_model_create_iter(model);
/* fetch the GdaParameter in iter for the first column */
GdaParameter *param = GDA_PARAMETER (GDA_PARAMETER_LIST
(iter)->parameters->data);
while(gda_data_model_iter_move_next(iter))
{
const int row = gda_data_model_iter_get_row(iter);
printf("row=%d\n", row);
/*const GValue *value = gda_data_model_get_value_at(model, 0, row);*/
const GValue *value = gda_parameter_get_value (param);
gchar *text = gda_value_stringify(value);
printf (" value=%s\n", text);
g_free(text);
}
[...]
About the number of rows, I was wrong, and this needs to be corrected;
in the meanwhile, you can just use gda_data_model_iter_get_row(iter)
and the last call will give you the number of rows (add 1 because row
numbers start at 0).
Vivien
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]