Board index » cppbuilder » NULL value

NULL value


2006-06-28 09:04:25 PM
cppbuilder44
Hi,
i m trying to insert some null values and not null values into DB with code
segment below;
if( count < idsize)
{
TableQuery->Params->Items[1]->AsFloat = NULL;
count++;
}
else
{
temp = ListBox1->Items->Strings[count1];
pos = temp.Pos(' ');
TableQuery->Params->Items[1]->AsFloat = StrToFloat(temp.SubString(pos+1,7));
count1++;
}
There is no problem here, but when i wanna use this statement to select only
not NULL values ;
select [column1] from [table] where [column1] IS NOT NULL
it brings me the whole results with NULL values included! And NULL values
shows .0000 in DB. Would you please help?
 
 

Re:NULL value

"Cenk" < XXXX@XXXXX.COM >wrote:
Quote
i m trying to insert some null values and not null values into DB with code
segment below;

if( count < idsize)
{
TableQuery->Params->Items[1]->AsFloat = NULL;
That is NOT a DBF NULL value. That is NULL, which is different. If you
look at the actual definition of NULL in C++, you'll probably find that
the above statement is exactly equivalent to
TableQuery->Params->Items[1]->AsFloat = 0;
Quote
it brings me the whole results with NULL values included! And NULL values
shows .0000 in DB. Would you please help?
No, it isn't showing NULL values. It's showing the values equal to zero,
which is a very different matter indeed. Database NULL and C/C++ NULL
are totally different concepts, and should NOT be confused. A Database
NULL means there is no value, not that the value is zero.
There is presumably some method on the item to set it to NULL rather
than to a value. Use that method instead.
Alan Bellingham
--
Me <url:mailto: XXXX@XXXXX.COM ><url:www.doughnut.demon.co.uk/>
ACCU - C, C++ and Java programming <url:accu.org/>
The 2006 Discworld Convention <url:www.dwcon.org/>
 

Re:NULL value

Cenk wrote:
Quote

it brings me the whole results with NULL values included! And NULL values
shows .0000 in DB. Would you please help?

You should use Clear() method of TParam to set the value of parameter to
NULL.
TableQuery->Params->Items[1]->Clear();
According to Delphi help, NULL values can arise in the following ways:
1. Assigning the value of another, NULL, parameter.
2. Assigning the value of a blank field.
Muzaffar
 

{smallsort}

Re:NULL value

Thanks thats what i need