Gossamer Forum
Home : Products : Gossamer Links : Discussions :

add NULL value

Quote Reply
add NULL value
Hi,

I am trying to add a NULL value with

Code:
my $added = $DB->table('Links')->add($add);

And I donīt get it with:

Code:
$add->{Value} = undef;

there is '' in the Database

with

Code:
if ($value) {
$add->{Value} = $value;
}

there is '' in the Database

putting \NULL or NULL in the def file as default makes the DB value text 'NULL' or '\NULL'. I remember an issue with the condition and NULL but I could find nothing in the forum. Would be grateful for any hint.

Cheers

n||i||k||o

UPDATE:

O.K.: Post something and the solution comes.
right before the add statement I put:
Code:
$add->{Value} = \'NULL' unless $add->{Value};
I would have expected undef to work but it does not.

Last edited by:

el noe: May 23, 2014, 3:48 AM
Quote Reply
Re: [el noe] add NULL value In reply to
Yeah, doing \"NULL" or \'NULL' will do the trick Cool

The escape basically tells GT::SQL to run it as a "proper" command... same as if you do:

Code:
Foo => \"Foo + 10"

,..which would get interpreted as:

Code:
Foo = Foo +10

Cheers

Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!