Basic Form
IBDatabase | Connect this to the database (*.fdb file) and the transaction |
IBTransaction | Verify that this is connected to the IBDatabase |
IBDataset | Right click - select Edit SQL
Right click - select Dataset Editor... (for Delphi 5, this requires an upgrade)
|
SQL
SelectSQL |
---|
select * from "Sphere_Port_Details_tbl" |
InsertSQL |
insert into "Sphere_Port_Details_tbl" ("Sphere_Port_Details_tbl"."Port_BC", "Sphere_Port_Details_tbl"."Sample_BC", "Sphere_Port_Details_tbl"."RH_Target", "Sphere_Port_Details_tbl"."Dry_Flow", "Sphere_Port_Details_tbl"."ModifiedDate") values (:"Port_BC", :"Sample_BC", :"RH_Target", :"Dry_Flow", :"ModifiedDate") |
ModifySQL |
update "Sphere_Port_Details_tbl" set "Sphere_Port_Details_tbl"."Sample_BC" = :"Sample_BC", "Sphere_Port_Details_tbl"."RH_Target" = :"RH_Target", "Sphere_Port_Details_tbl"."Dry_Flow" = :"Dry_Flow", "Sphere_Port_Details_tbl"."ModifiedDate" = :"ModifiedDate" where "Sphere_Port_Details_tbl"."Port_BC" = :"OLD_Port_BC" |
DeleteSQL |
delete from "Sphere_Port_Details_tbl" where "Sphere_Port_Details_tbl"."Port_BC" = :"OLD_Port_BC" |
RefreshSQL |
Select "Sphere_Port_Details_tbl"."Port_BC", "Sphere_Port_Details_tbl"."Sample_BC", "Sphere_Port_Details_tbl"."RH_Target", "Sphere_Port_Details_tbl"."Dry_Flow", "Sphere_Port_Details_tbl"."ModifiedDate" from "Sphere_Port_Details_tbl" where "Sphere_Port_Details_tbl"."Port_BC" = :"Port_BC" |
Read a Value
function TSphere_Status_DataModule.Get_Port_Configuration(Port_BC: string): string; var tbl : TIBDataSet; begin // This returns the associated *Parameters* field tbl := IBDataSet_Sphere_Port_Config_tbl ; if tbl.Transaction.Active then tbl.Transaction.Commit; if tbl.Active = false then tbl.Open else tbl.Refresh; // to get changes if tbl.Locate('Port_Barcode', VarArrayOf([Port_BC]), [loCaseInsensitive]) then begin result := tbl.FieldByName('Parameters').AsString; end else begin result := ''; end; end; // Get_Port_Configuration(Port_BC)
Insert/Update
function TSphere_Status_DataModule.Update_Port_Detail_Record( Port_BC, Sample_BC: string; ModifiedDate : TDateTime; RH_Target : Single; Dry_Flow : integer; ): boolean; var tbl : TIBDataSet; // This allows a shorter name to be used in the code begin tbl := IBDataSet_Sphere_Port_Details_tbl ; if tbl.Active = false then tbl.Open; if tbl.Locate('Port_BC', VarArrayOf([Port_BC]), [loCaseInsensitive]) then begin tbl.Edit end else begin tbl.Insert; tbl.FieldByName('Port_BC') .AsString := Port_BC; // not set for edit end; tbl.FieldByName('Sample_BC') .AsString := Sample_BC; tbl.FieldByName('ModifiedDate').AsDateTime := ModifiedDate; tbl.FieldByName('RH_Target') .AsFloat := RH_Target; tbl.FieldByName('Dry_Flow') .AsInteger := Dry_Flow; tbl.Post; tbl.Transaction.Commit; result := true; // if there is an error, this is never executed end; // Update_Port_Detail_RecordNote: I normally line up the dots and assignment operators as shown above ... I think that this makes the code easier to read.
Note: This table has only one record per key - the data is updated once every 6 minutes.
Notice that the Dataset Editor combo box used to select a table will not work until the SelectSQL property is set and a transaction is assigned. If you use mixed case, dialect 3 tablenames, don't forget to place them in double quotes.