18 October 2010

Lazarus ZeosDBO Stored Procedure Call for PostgreSQL functions

This is main logic in some Lazarus database form, powered by ZeosDBO, to call stored procedure (postgresql function), who is placed in ZSQLReadOnly SQL property, like

SELECT * FROM Name_Of_Function()

Then In ZTable BeforePost event, you reopen that ZSQL to retrieve default value of primary key, like this code :

procedure T_f_main._ZTableBeforePost(DataSet: TDataSet);
begin
if _DataSource.State in [dsInsert] then
with _ZSQL_readonly_procedure do
begin
Open ;
_ZTableID.Value := Fields[0].asInteger;
Close ;
end;
end;
Post a Comment