#1  
Old 1st October 2003, 06:08 AM
M. Said
 
Posts: n/a
Default Assigning NULL to a Prepared SQL DateTime Field

Hi I have the following Prepared SQL:

Insert into test (Date1) values(:?);

How do I assign NULL to Date1 ?

Regards,

M. Said


  #2  
Old 1st October 2003, 06:37 AM
Des O'Toole
 
Posts: n/a
Default Re: Assigning NULL to a Prepared SQL DateTime Field


"M. Said" <muneers@xmail.com> wrote in message news:3f79c4e4@wic040d....
> Hi I have the following Prepared SQL:
>
> Insert into test (Date1) values(:?);
>
> How do I assign NULL to Date1 ?
>
> Regards,
>
> M. Said



Try using the string "NULL"

Des



  #3  
Old 1st October 2003, 07:30 AM
M. Said
 
Posts: n/a
Default Re: Assigning NULL to a Prepared SQL DateTime Field

I tried the following:

Q.Params[0].AsString := 'NULL';
or
Q.Params[0].AsDateTime := NUL;

Does not work. Is this the correct syntax?


Also, I tried to use a TnxTable with the following:

TestTable.FieldByName('DATE1').AsString := 'NULL';
Does Not Work. Is this the correct syntax?

What I am trying to do is assign a NULL value to a DateTime Field while
importing some records from a text file.

Regards,

M. Said

"Des O'Toole" <des@t-and-h.demon.no-spam.co.uk> wrote in message
news:3f79cd69@wic040d....
>
> "M. Said" <muneers@xmail.com> wrote in message news:3f79c4e4@wic040d....
> > Hi I have the following Prepared SQL:
> >
> > Insert into test (Date1) values(:?);
> >
> > How do I assign NULL to Date1 ?
> >
> > Regards,
> >
> > M. Said

>
>
> Try using the string "NULL"
>
> Des
>
>
>



  #4  
Old 1st October 2003, 07:37 AM
Ole Willy Tuv
 
Posts: n/a
Default Re: Assigning NULL to a Prepared SQL DateTime Field

<< Q.Params[0].AsString := 'NULL';
or
Q.Params[0].AsDateTime := NUL;

Does not work. Is this the correct syntax? >>

Try:

Q.Params[0].Clear;

<< TestTable.FieldByName('DATE1').AsString := 'NULL';
Does Not Work. Is this the correct syntax? >>

TestTable.FieldByName('DATE1').Clear;

In SQL you'd assign NULL:

insert into TestTable (DATE1) values(null);

Ole Willy Tuv


  #5  
Old 1st October 2003, 08:16 AM
M. Said
 
Posts: n/a
Default Re: Assigning NULL to a Prepared SQL DateTime Field

Thanks for the timely response.

When I try:

Q.Params[0].Clear;

I get the following exception: Invalid date/time format [no error code]

Also, Where is NUL defined?

Regards,

M. Said



"Ole Willy Tuv" <owtuv@online.no> wrote in message news:3f79dba2@wic040d....
> << Q.Params[0].AsString := 'NULL';
> or
> Q.Params[0].AsDateTime := NUL;
>
> Does not work. Is this the correct syntax? >>
>
> Try:
>
> Q.Params[0].Clear;
>
> << TestTable.FieldByName('DATE1').AsString := 'NULL';
> Does Not Work. Is this the correct syntax? >>
>
> TestTable.FieldByName('DATE1').Clear;
>
> In SQL you'd assign NULL:
>
> insert into TestTable (DATE1) values(null);
>
> Ole Willy Tuv
>
>



  #6  
Old 1st October 2003, 08:26 AM
Ole Willy Tuv
 
Posts: n/a
Default Re: Assigning NULL to a Prepared SQL DateTime Field

<< When I try:

Q.Params[0].Clear;

I get the following exception: Invalid date/time format [no error code] >>

As a last shot, try:

Q.Params[0].Value := Null;

If you get the same error, I'm out of ideas ;-)

<< Also, Where is NUL defined? >>

NULL (not NUL) is defined in Variants.pas (D6/D7) or System.pas (D5).

Ole Willy Tuv


  #7  
Old 16th January 2025, 11:44 PM
JackT JackT is offline
Junior Member
 
Join Date: Jul 2023
Posts: 10
Default Do This

Param[0].Clear;
Param[0].Value := Null;
Param[0].DataType := TFieldType.ftDate;


This works when you want to set a date parameter to a null value in an UPDATE query


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I define a not null Charater (NullString) Field Matthew Balraj nexusdb.public.support.adoprovider 1 12th February 2010 02:05 AM
PreAnn: v3 being prepared Eivind Bakkestuen [NDD] nexusdb.public.announcements 0 29th May 2009 03:33 PM
SQL Statement for DateTime Field Carsten Groh nexusdb.public.support.php 2 28th April 2009 12:46 AM
Sum, Coalesce and Null fields Brenton Wildman nexusdb.public.support.adoprovider 1 19th January 2006 07:51 AM
Prepared/Unprepared queries Ole Willy Tuv nexusdb.public.support.adoprovider 3 18th February 2004 02:00 PM


All times are GMT +11. The time now is 08:40 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.