- lbound – lower range bound.
- hbound – upper range bound.
- flags – range flags.
Note: Columns of range type are read-only. This sample updates them using SQL commands.
To get range column attributes, this sample uses the following code:
l := FDQuery1.FieldByName('<range column name>.<subfield>').AsXxxx;
You can find the Ranges project at:
- Start | Programs | Embarcadero RAD Studio Sydney | Samples and then navigate to:
Object PascalDatabaseFireDACSamplesDBMS SpecificPostgreSQLRanges
- Subversion Repository:
- You can find Delphi code samples in GitHub Repositories. Search by name into the samples repositories according to your RAD Studio version.
How to Use the Sample
- Navigate to the location given above and open
- Press F9 or choose Run > Run.
|File in Delphi||Contains|
|The project itself.|
|The main form.|
Before running the sample, the main components are configured at design time using the Object Inspector as follows:
- A TFDConnection object named FDConnection1. This is the FireDAC connection object that the sample uses to connect to a DBMS. The sample sets the ConnectionDefName property to
Note: You can change the ConnectionDefName property to connect to a different PostgreSQL server using a valid user name and password.
- A TFDQuery object named FDQuery1. This component implements a dataset capable of executing SQL queries. The sample sets:
SELECT int4range(null,2000, '(]') rng
SELECT int4range(3000,4000, '[)') rng
SELECT int4range(5000,6000, '') rng
SELECT int4range(7000,null, '()') rng
SELECT int4range(20,20, '()') rng
- The parentheses or brackets of the third argument indicate whether the lower and upper bounds are exclusive or inclusive. “
[” represents an inclusive lower bound while “
(” represents an exclusive lower bound. The same way, “
]” represents an inclusive upper bound while “
)” represents an exclusive upper bound.
- If you omit the lower bound of a range, it means that all points less than the upper bound are included in the range. Likewise, if you omit the upper bound of the range, then all points greater than the lower bound are included in the range. If both lower and upper bounds are omitted, all values of the element type are considered to be in the range.
- A TDataSource object named DataSource1. This component provides an interface between a dataset component and data-aware controls on a form. In this sample, it is used to provide communication between the dataset and the grid where the dataset is displayed. To this end, the sample sets the following properties:
- The DataSet property of DataSource is set to
- The DataSource property of DBGrid1 is set to
When you run the application, you see:
- A TDBGrid that is used to display the different data ranges defined on the SQL command.
- Three TDBEdit components that are used to display the lbound,lbound and flags fields of the range type.
- Two TLabel components that are used to display the type of the range bounds.
You can check the link below for more details about this sample: