Please note that all visual database components work with fields, not with parameters. You can bind TDBText to show any field value of the current record using the code similar to the following:
Code: Select all
IBCQuery1.Options.RequiredFields := False;
IBCQuery1.Options.ReturnParams := True;
IBCQuery1.SQL.Text := 'select * from dept';
IBCQuery1.SQLInsert.Text := 'insert into dept(dname, loc) values(:dname, :loc) returning deptno';
IBCDataSource1.DataSet := IBCQuery1;
DBText1.DataSource := IBCDataSource1;
DBText1.DataField := 'deptno';
IBCQuery1.Open;
You can use the TIBCSQL component to execute the 'SELECT MAX' and 'SELECT SUM' statements, but not directly. These statements must be put to stored procedures, for example like this:
Code: Select all
SET TERM ^ ;
create or alter procedure SELMAXDEPTNO
returns (
MAXDEPTNO integer)
as
begin
select max(deptno) from dept into :maxdeptno;
end^
SET TERM ; ^
And here is a code example that uses this stored procedure in TIBCSQL:
Code: Select all
IBCSQL1.CreateProcCall('SELMAXDEPTNO');
IBCSQL1.Execute;
ShowMessage(IntToStr(IBCSQL1.ParamByName('maxdeptno').AsInteger));
It is easier to execute the 'SELECT MAX' and 'SELECT SUM' statements in the TIBCQuery component, like this:
Code: Select all
IBCQuery1.SQL.Text := 'select max(deptno) from dept';
IBCQuery1.Open;
ShowMessage(IntToStr(IBCQuery1.Fields[0].AsInteger));