On 2002-09-25 22:38:57, Rodrigo Moya wrote: > On Wed, 2002-09-25 at 06:17, Allan Wind wrote: > > libgda: 0.8.193 > > postgres: 7.2.1 > > > > I am trying to run a simple parameterized (is there even a word like that?) > > query and expected this to do the trick, however the GdaParameterList > > argument to gda_connection_execute_single_command seem to be ignored > > as model contains my full table after running this piece of code. Did I miss > > something here? > > > the parameters are not supported yet, so yes, they are ignored. > > > // initialize db > > // [...] > > > > int id = 1; > > > > GdaCommand *c = gda_command_new("select id, name from accounts", GDA_COMMAND_TYPE_SQL, GDA_COMMAND_OPTION_STOP_ON_ERRORS); > > GdaValue *v = gda_value_new_integer(id); > > > > GdaParameter *p = gda_parameter_new("id", GDA_VALUE_TYPE_INTEGER); > > gda_parameter_set_value(p, v); > > > that will (when implemented) be wrong. The idea is that you use: > > cmd = gda_command_new ("select id, name from accounts where id = :id", > ...); > p = gda_parameter_new ("id", GDA_VALUE_TYPE_INTEGER) > > so that the provider will replace :id with the value. > > Anyway, as I said, there's no implementation for this yet :-( Thanks, may I suggest an example like the above be added to the tutorial along with the work-around of using gda_value_string? It would also be good if the lack of support is documented under the execute command, or possible an assert if a non-value is used? > > Trial and error suggests that GdaParameterList takes ownership of GdaParameter > > upon gda_parameter_list_add_parameter(), that should probably be documented in > > libgda-gda-parameter.html. > > > yes, that's correct, the parameter list takes ownership of the > parameter. I wonder if we should document that or change its behaviour, > so that it just gets a copy. > > > It would also be nice if a paragraph on g_object_unref could be added to the > > tutorial, most other objects have a free function while model is an exception > > and use g_object_unref(). Perhaps a note could be added in the > > libgda-gdadatamodel.html as well? > > > no, what we should do is to add a _free function to each > class/structure, in most cases just being those a call to > g_object_unref. That's what we've got in the GNOME 1.4 version. Change of behavaior would be most consistent with the rest of the API, it looks like you are going that way with the model_free as well. Nice. /Allan -- Allan Wind P.O. Box 2022 Woburn, MA 01888-0022 USA
Attachment:
pgpszJlRmtJUz.pgp
Description: PGP signature