Re: [gnome-db] gda_connection_execute_command() result

On Sat, 2006-10-21 at 15:45 +0200, Vivien Malerba wrote:
> On 10/21/06, Murray Cumming <murrayc murrayc com> wrote:
> > The documentation for gda_connection_execute_command (pasted below) is
> > not clear to me, particularly
> >
> > "The return value is a GList of #GdaDataModel's, and #GdaParameterList".
> >
> > This seems to mean that the GList* contains some GdaDataModels and some
> > GdaParameterLists. If so, what's the sequence or way to identify each
> > element? And what would the GdaParameterList items tell me? Where is
> > this demonstrated in example code?
> You understood correctly. The returned list can hold pointers to
> GdaDataModel or GdaParameterList objects, in the same list.
> Identifying them is easily done using GObject's introspection features

OK. This needs to be mentioned in the documentation.

Also, is there ever >1 GdaDataModel or GdaParameterList in that GList?
Does it ever contain both? It would be nice to know what to expect, and

> A GdaDataModel is returned in the list whenever the SQL was a SELECT
> query (or a query returning a data set), and a GdaParameterList is
> returned whenever the query was something else.
> What the GdaParameterList contains is a list of named values which are
> described in gda_server_provider_execute_command(), the most usefull
> one (and only supported at the moment if I remember) being named
> "IMPACTED_ROWS" which contains the number of rows impacted by the
> query.
> Note that if you know that the command contains a SELECT query, then
> you'd better use gda_connection_execute_select_command() and if you
> know that the command is not as SELECT query, then you should use
> gda_connection_execute_non_select_command().
> These two functions are wrapper around the first one and make things
> easier to use.
> >
> > Please note also that, because it's so odd to have 2 types of element in
> > a GList, people are likely to interpret this text as just meaning that
> > the params parameter is an output parameter. That guess would be
> > reinforced by the missing const for that parameter.
> >
> I know it can seem a bit strange but is it worth creating overhead
> with a structure such as
> struct {
>       gboolean this_is_a_data_model;
>       union {
>              GdaDataModel *model;
>              GdaParameterList *plist;
>       } data;
> }
> and returning a list of these structures.

How about either 
- returning two GLists.
- Making this function private and just having a execute method for
select and an execute method for parameters?

Murray Cumming
murrayc murrayc com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]