Re: [gnome-db] Prepared Statements



On Sat, 2003-04-19 at 19:47, calvaris igalia com wrote:
> 	I was thinking about the API for prepared statements because when
> you create a new GdaParameter you have to specify the GdaValueType and I
> don'k understand why. 
>
because providers need to know what a parameter's type is, to be able to
know what to do with the associated value.

> It can be relationed with the GdaValue class,
> because you can create a GdaValue without a type, and then you'd need to
> pass the type to gda_parameter_new().
> 
a GdaValue without a type? How can you do that? There is no way to
create a GdaValue without a type, not in the API at least.

> 	I don't know if the provider would need the type of the value to
> set it to null.
>
what for? a null value would only be needed when the client really wants
to send a null value. In all other cases, it needs to pass a value of a
given type. If no type (GDA_VALUE_TYPE_UNKNOWN), the providers don't
know what to do it with use, and therefore can't use it.

>  If this doesn't happen everything is OK, but if does, I
> think that the GdaValue class must encapsulate the real type and not
> GDA_VALUE_TYPE_NULL because I think it's a bit ugly to pass the type to
>
GDA_VALUE_TYPE_NULL is for NULL values, not the default type.

> gda_parameter_new(), so my idea is that gda_paramenter_new() could get the
> real type calling gda_value_get_type(). 
> 
I think what you want is a gda_parameter_new_from_value, am I right? If
so, we can add it if you want.

Although, to create parameters, as with values, you should be using the
_new_string, new_gobject and the (missing) _new_integer, etc...

> 	 I don't know what happens when you, for instance, create a
> GdaValue with an int, and then you put it to null with set null, does it
> keep the real type?
>
no, it sets it to NULL. We decided long ago that it was better to have a
separate type for NULL values, to avoid the need to have different cases
for each type's real NULL value (for instance, how to specify a NULL in
an integer?)

>  If this happens everything would be easy, because to
> create a null GdaValue, only gda_value_new_null() would have to be changed
> to get the GdaValueType.
> 
I don't understand what you mean here, could you explain please?

cheers




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