Forum > Database

TBufDataset.Filter := 'FieldName Is Null' does not work.

(1/2) > >>

dmitryb:
Hi All

How to set Filter property in TBufDataset to show records where 'FieldName Is Null' 'FieldName Is Not Null'?
'FieldName Is Null' or 'FieldName = Null' does not work.

lucamar:
I'm no expert so excuse me if it's a daft question but ... is that valid SQL? And if it is and should work, did you remember to also set Filtered to True?

And finally, are you sure TBufDataset implements Filter? IIRC it doesn't implement any DB laguage so it seems probable it can't filter either.

dmitryb:
I tested   

BufDataset1.Filter := 'ART_PAK = 10';

This works correctly.

But how to filter out empty values is not clear.

balazsszekely:

--- Quote from: dmitryb on July 27, 2021, 03:22:17 am ---I tested   

BufDataset1.Filter := 'ART_PAK = 10';

This works correctly.

But how to filter out empty values is not clear.

--- End quote ---

Set Filtered property to true, then use the OnFilterRecord event:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---procedure TForm1.BufDataset1FilterRecord(DataSet: TDataSet; var Accept: Boolean);begin  Accept := not Dataset.FieldByName('ART_PAK').IsNull;end; 

wp:

--- Quote from: dmitryb on July 27, 2021, 02:38:19 am ---'FieldName Is Null' or 'FieldName = Null' does not work.

--- End quote ---
According to Delphi docs (http://docwiki.embarcadero.com/Libraries/Sydney/en/Data.DB.TDataSet.Filter) this should work. Therefore, we very probably have a bug here. Please file a bug report. Note that the old bugtracker has been switched off, and issues must be filed on the new gitlab page (link at sidebar, "BugTracker"). Maybe wait for a few days until everything is finished with the move to git.

Navigation

[0] Message Index

[#] Next page

Go to full version