Re: [gnome-db] How to insert a NULL with V4



On Sun, May 18, 2008 at 2:19 AM, Phil Longstaff <plongstaff rogers com> wrote:
> I want to create a GdaSqlStatementInsert structure to insert a row into
> a table.  At least one of the values is NULL, which is a GValue with
> gtype == GDA_TYPE_NULL (== 0).  When I try to attach the GdaSqlStatement
> to a GdaStatement so it can be executed, I get some error messages
> related to the NULL values:
>
> * 19:39:34  WARN <GLib-GObject> gtype.c:3337: type id `0' is invalid
> * 19:39:34  WARN <GLib-GObject> can't peek value table for type
> `<invalid>' which is not currently referenced
> * 19:39:34  WARN <GLib-GObject> gvalue.c:96: cannot initialize GValue
> with type `(null)', this type has no GTypeValueTable implementation
> * 19:39:34  CRIT <GLib-GObject> g_value_copy: assertion `G_IS_VALUE
> (src_value)' failed
>
> This happens in gda_sql_expr_copy() when the value is being copied.
>
> I don't know the GValue system well enough to try to fix this.  Is there
> an alternative way to insert a NULL?

The GValue values in a GdaSqlStatement represent some text so you
should a string GValue:
g_value_set_string ((value = gda_value_new (G_TYPE_STRING), "NULL");
I'll correct that specific point to automatically convert the NULL GValue.

Otherwise, you can create a parameter (value holder) using a
GdaSqlParamSpec, and then bind that named parameter to NULL when
executing the statement.

Regards,

Vivien


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