Re: [gnome-db] Documentation: excute_command and parameters



On 3/27/06, Allan Wind <allan_wind lifeintegrity com> wrote:
> It looks like the postgres provider in 1.2.1 does not support the
> parameters arguments.  Is that feature implemented in later releases?
> It would be nice if libgda-GdaClient.html and libgda-gda-parameter.html
> files could be updated with a note saying what version (if any) that
> feature is available.  It would also be great if libgda-gda-command.html
> could be updated with the syntax for named parameters (i.e. select *
> from example_table where example_field = :example_value).

Yes, documentation needs to be improved, using an howto approach.

However, named parameters are already featured in queries through the
GdaQuery object. Here is how it works:
-> create a new GdaQuery object using gda_query_new_from_sql(). If you
have a dictionary object and the query will relate to objects
referenced in that dictionary, then pass a pointer to it as first
argument, otherwise pass NULL. The SQL can be something like 'select *
from example_table where example_field = ## [:name="example_value
:type="string"]' (notice that the syntax for a parameter is a bit
different since a lot of information can be specified about the
parameter, see the current query documentation about the syntax).
-> get a list of parameters required to execute the query using 
gda_entity_get_param_list(query) which returns a GdaParameterList
object.
-> give the parameters in that object values using
gda_parameter_set_value(). Alternatively you can display a form widget
for the user to set the values using gnome_db_basic_form_new ()
-> get the actual SQL to execute using gda_renderer_render_as_sql ()
-> create a GdaCommand with that SQL and execute it through the
GdaConnection object.

It may sound a bit too much just for a single parametrized query but
please note that:
-> the API is undergoing useability improvements
-> you can do much more complex stuff than just a parametrized query
using the same concepts.

Regards,

Vivien



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