Hello,
How should I specify 'paramters' in a Gda::Command ?
I've got the following (in Ruby)
@update_user = Gda::Command.new( "UPDATE GARGOYLE.GRGL_USERS SET LOGIN=$1, NAME=$2, EMAIL=$3"
, Gda::Command::TYPE_SQL
, Gda::Command::OPTION_STOP_ON_ERRORS )
And then, later, I would like to write something like
Dsn_connection.begin_transaction( toto = Gda::Transaction.new( 'toto' ) )
Dsn_connection.execute_single_command( @update_user,
Gda::ParameterList.new(
Gda::Parameter.new( '$1' , <value to substitute $1 into @update_user> ),
Gda::Parameter.new( '$2' , <value to substitute $2 into @update_user> ),
Gda::Parameter.new( '$3' , <value to substitute $3 into @update_user> ) ) )
Dsn_connection.commit_transaction( toto )
The GdaCommand does not accept parameters, it only accepts "raw" SQL. If you want to execute parametrized queries, then use the GdaQuery object like for example
query = gda_query_new_from_sql (dict, "UPDATE GARGOYLE.GRGL_USERS SET LOGIN=##[:name='login' :type='gchararray'], NAME=##[:name='name' :type='gchararray'], EMAIL=##[:name='email' :type='gchararray']", NULL);
to create a GdaQuery object with 3 parameters; note the syntax to specify parameters whic are named and with a defined type.
Then you can get a GdaParameterList object to specify the parameter values using:
Now you must actually pass the values to the 'params' object using
param = gda_parameter_list_find_param (params, "login");
gda_parameter_set_value_str (param, <the login value);
Once finished, call gda_query_execute (query, params).
Regards,
Vivien
_______________________________________________ gnome-db-list mailing list gnome-db-list@gnome.org http://mail.gnome.org/mailman/listinfo/gnome-db-list