---------- Forwarded message ----------
From: Daniel Espinosa <[email protected]>
Date: 2008/12/24
Subject: Re: [gnome-db] API Break Request for gda_insert_row_into_table
To: Vivien Malerba <[email protected]>




2008/12/23 Vivien Malerba <[email protected]>

>
>
> 2008/12/21 Daniel Espinosa <[email protected]>
>
>> Hi all
>>
>> I'm working in gda_insert_row_into_table but have some troubles:
>>
>> I'm creating the SQL usin GdaSqlStatement structs, with success but
>> strings are renderer with out quotes ("") can any help me to know how can I
>> do this to work.
>>
>> I'm adding a GdaSqlExpr to values GList in the GdaSqlStatementInsert, when
>> render the GdaSqlStatement I get:
>>
>>  INTO test (q, number, a) VALUES (NEW TEXT, 1000, NUEVO NOMBRE)
>>
>> it is an invalid SQL, how can I get quoted strings. This must be
>>
>>  INTO test (q, number, a) VALUES ('NEW TEXT', 1000, 'NUEVO NOMBRE')
>>
>> for a PostgreSQL database.
>
>
> It's up to you to add quotes where they are needed (because the
> GdaSqlStatement is just a tree representation of an SQL statement). Anyway,
> what you should do is use GdaSqlParamSpec (which are variables or
> parameters), this will have the following benefits:
> * avoid you the job of adding quotes when needed
> * avoid any SQL injection problems
>
>
>>
>>
>> Another point:
>>
>> I have the Idea to make this functions to use a GdaBatch object, in order
>> to allow any one to add more SQL commands to it (may be calling Gda Easy
>> functions multiple times) and then execute then at once.
>>
>> If all agree I can change this functions:
>>
>> gboolean gda_prepare_insert_row_into_table (Gda Connection *cnc, GdaBatch
>> *batch, const gchar *table, GdaSet *last_inserted_row, GError *error, ...);
>>
>> If batch is NULL this function execute the insert command, if not, add the
>> result of calculate the corresponding GdaStatement to GdaBatch without
>> execute it.
>
>
> I'd prefer 2 different functions to have easier to understant arguments.
>


Then you mean to have:

Direct execution:

gboolean gda_insert_row_into_table (Gda Connection *cnc, const gchar *table,
GdaSet *last_inserted_row, GError *error, ...);


Add the statement to a GdaBatch:

gboolean gda_prepare_insert_row_into_table (Gda Connection *cnc, GdaBatch
*batch, const gchar *table, GdaSet *last_inserted_row, GError *error, ...);




>
>
>>
>>
>> gboolean gda_execute_batch (GdaConnection *cnc, GdaBatch *batch, GError
>> *error);
>>
>> As a convenience function of the gda_connection_batch_execute.
>>
>
> Looks great!
>
>
>>
>>
>> This coul apply for the rest of Gda Easy functions to implement.
>>
>>
> You mean for update and delete ones?
>

Yes, then there will be one for direct execution and one to add new
statements to a GdaBatch object.

-- 
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates:
LIBRE)



-- 
Trabajar, la mejor arma para tu superación
"de grano en grano, se hace la arena" (R) (en trámite, pero para los cuates:
LIBRE)
_______________________________________________
gnome-db-list mailing list
[email protected]
http://mail.gnome.org/mailman/listinfo/gnome-db-list

Reply via email to