You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Graham Leggett <mi...@sharp.fm> on 2003/12/01 22:36:08 UTC

Setting a field to NULL - how?

Hi all,

I have a table "note" with a row containing a Date. I would like to set 
the date to null, where previously it had a non null value.

I tried to do this:

note.setEffectiveDate(null);
note.save();

but the above code has no effect - the date remains set in the database 
to it's previous value.

Can anyone explain to me what I am doing wrong?

Regards,
Graham
--


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Setting a field to NULL - how?

Posted by Felipe Ramos <fr...@tissat.es>.
Note note = NoteManager.getInstance(x); ?

And what about  Note note = NotePeer.retrieveByPK(x);
or Note note = NotePeer.doSelectNoteBy(x) // you must create de 
doSelectNoteBy() method

I'm using MySQL and note.setEffectiveDate(null);   works.

Graham Leggett wrote:

> Scott Eade wrote:
>
>>> I have a table "note" with a row containing a Date. I would like to 
>>> set the date to null, where previously it had a non null value.
>>>
>>> I tried to do this:
>>>
>>> note.setEffectiveDate(null);
>>> note.save();
>>>
>>> but the above code has no effect - the date remains set in the 
>>> database to it's previous value.
>>>
>>> Can anyone explain to me what I am doing wrong?
>>
>>
>>
>> My guess is that you are using MySQL.  If I recall correctly MySQL 
>> initialises Date fields for you in an attempt to be helpful.  I don't 
>> think it does this for all of the date formats - you will need to 
>> check the MySQL documentation.
>
>
> Just to clarify - the row in "note" exists already, what I am trying 
> to do is update the row.
>
> The code is like this:
>
> Note note = NoteManager.getInstance(x);
> note.setEffectiveDate(null);
> note.save();
>
> Unfortunately my torque.log has stopped working for some reason, so I 
> cannot get access to the sql statement it is passing to postgresql.
>
> What I need to know in the meantime is whether this sort of thing is 
> possible - does torque support null objects in columns?
>
> Regards,
> Graham
> -- 
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org
>
>

-- 
------------------------
Felipe Ramos
Tissat SA
C/ Orense 34-9ยช
28020 Madrid
Tel: (+34) 91 4175913 
Fax: (+34) 91 4172914
Mail: framos@tissat.es
------------------------




---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Setting a field to NULL - how?

Posted by Graham Leggett <mi...@sharp.fm>.
Scott Eade wrote:

>> I have a table "note" with a row containing a Date. I would like to 
>> set the date to null, where previously it had a non null value.
>>
>> I tried to do this:
>>
>> note.setEffectiveDate(null);
>> note.save();
>>
>> but the above code has no effect - the date remains set in the 
>> database to it's previous value.
>>
>> Can anyone explain to me what I am doing wrong?
> 
> 
> My guess is that you are using MySQL.  If I recall correctly MySQL 
> initialises Date fields for you in an attempt to be helpful.  I don't 
> think it does this for all of the date formats - you will need to check 
> the MySQL documentation.

Just to clarify - the row in "note" exists already, what I am trying to 
do is update the row.

The code is like this:

Note note = NoteManager.getInstance(x);
note.setEffectiveDate(null);
note.save();

Unfortunately my torque.log has stopped working for some reason, so I 
cannot get access to the sql statement it is passing to postgresql.

What I need to know in the meantime is whether this sort of thing is 
possible - does torque support null objects in columns?

Regards,
Graham
--


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Setting a field to NULL - how?

Posted by Graham Leggett <mi...@sharp.fm>.
Scott Eade wrote:

>> I have a table "note" with a row containing a Date. I would like to 
>> set the date to null, where previously it had a non null value.
>>
>> I tried to do this:
>>
>> note.setEffectiveDate(null);
>> note.save();
>>
>> but the above code has no effect - the date remains set in the 
>> database to it's previous value.
>>
>> Can anyone explain to me what I am doing wrong?
> 
> 
> My guess is that you are using MySQL.  If I recall correctly MySQL 
> initialises Date fields for you in an attempt to be helpful.  I don't 
> think it does this for all of the date formats - you will need to check 
> the MySQL documentation.

I am using Postgresql.

Regards,
Graham
--


---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org


Re: Setting a field to NULL - how?

Posted by Scott Eade <se...@backstagetech.com.au>.
Graham Leggett wrote:

> I have a table "note" with a row containing a Date. I would like to 
> set the date to null, where previously it had a non null value.
>
> I tried to do this:
>
> note.setEffectiveDate(null);
> note.save();
>
> but the above code has no effect - the date remains set in the 
> database to it's previous value.
>
> Can anyone explain to me what I am doing wrong?

My guess is that you are using MySQL.  If I recall correctly MySQL 
initialises Date fields for you in an attempt to be helpful.  I don't 
think it does this for all of the date formats - you will need to check 
the MySQL documentation.

Scott

-- 
Scott Eade
Backstage Technologies Pty. Ltd.
http://www.backstagetech.com.au





---------------------------------------------------------------------
To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
For additional commands, e-mail: torque-user-help@db.apache.org