Re: [gnome-db] libgda cursor support
- From: Murray Cumming <murrayc murrayc com>
- To: Vivien Malerba <vmalerba gmail com>
- Cc: gnome-db-list <gnome-db-list gnome org>
- Subject: Re: [gnome-db] libgda cursor support
- Date: Mon, 17 Sep 2007 17:02:29 +0200
On Mon, 2007-09-17 at 16:31 +0200, Vivien Malerba wrote:
> On 9/17/07, Murray Cumming <murrayc murrayc com> wrote:
> >
> > On Mon, 2007-09-17 at 14:57 +0200, Vivien Malerba wrote:
> > > On 9/17/07, Murray Cumming <murrayc murrayc com> wrote:
> > > > I'm trying this now in Glom, but I get this strange error
> > > > "
> > > > DECLARE gda_1190032034_895812_0 SCROLL CURSOR WITH HOLD FOR SELECT
> > > > "artists"."artist_id", "artists"."name", "artists"."description",
> > > > "artists"."comments", "artists"."artist_id" FROM "artists" ORDER BY
> > > > "artists"."artist_id" ASC
> > > > (unknown number of rows)
> > > > "
> > >
> > > This is just a connection event of type GDA_CONNECTION_EVENT_NOTICE,
> > > you can ignore it (I think if you compile libgda withouth the debug
> > > flags, it will go away).
> >
> > Ah. I'll have to add some hacks in the bindings to stop them from
> > throwing exceptions for these. It is rather strange that you are setting
> > a GError that is not an error.
>
> It should not be set using a GError, it's a GdaConnectionEvent. Can
> you tell me where in the code it sets the error?
Sorry, you are right. It seems to be a rows count < 0 that is causing
Glom to read out the last connection events to explain the error. The
attached test case shows that the rows count is -1 when we use the
ITER_MODEL_ONLY parameter.
--
murrayc murrayc com
www.murrayc.com
www.openismus.com
#include <libgda/libgda.h>
int
main (int argc, char **argv)
{
gda_init ("test", "0.1", argc, argv);
GdaClient* client = gda_client_new();
GError* error = NULL;
GdaConnection* connection = gda_client_open_connection_from_string (client, "PostgreSQL", "HOST=localhost;DB_NAME=glom_musiccollection21", "murrayc" /* username */, "luftballons" /* password */, (GdaConnectionOptions)0, &error);
if(error)
{
printf("GError from gda_client_open_connection_from_string(): %s\n", error->message);
g_error_free(error);
return EXIT_FAILURE;
}
GdaCommand* command = gda_command_new("SELECT * FROM artists", GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS);
GdaParameterList *params = gda_parameter_list_new(NULL);
GValue value = { 0, };
g_value_init(&value, G_TYPE_BOOLEAN);
g_value_set_boolean(&value, TRUE);
gda_parameter_list_add_param_from_value (params, "ITER_MODEL_ONLY", &value);
GdaDataModel* model = gda_connection_execute_select_command(connection, command, params, &error);
if(error)
{
printf("GError from gda_connection_execute_select_command(): %s\n", error->message);
g_error_free(error);
return EXIT_FAILURE;
}
if(!model)
{
printf("gda_connection_execute_select_command(): returned NULL but did not set the GError.\n");
return EXIT_FAILURE;
}
gint count_rows = gda_data_model_get_n_rows(model);
if(count_rows < 0)
{
//This happens when we use the ITER_MODEL_ONLY parameter:
printf("gda_connection_execute_select_command(): returned a model, but gda_data_model_get_n_rows()=%d.\n", count_rows);
return EXIT_FAILURE;
}
printf ("Number of columns: %d, Number of rows=%d\n", gda_data_model_get_n_columns(model), count_rows);
gda_command_free (command);
g_object_unref (params);
g_object_unref (connection);
g_object_unref (client);
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]