Page 1 of 2
fetchall to false and queryrecount to true for postgresql
Posted: Sat 25 Feb 2012 15:15
by lao
Hi,
I want to set fetchall to false QueryRecCount to true by default for postgresql, i have unidac src vers 4.1.4.
in witch files i have to change this?
i have to convert some code from bde and interbase to unidac postgresql.
Thanks
Posted: Mon 27 Feb 2012 10:14
by lao
i found for Fetchall. I change True to false in file
PostgreSQLUniProvider.pas line 281.
For QueryRecCount i change Default False to Default True in file DBAccess.pas line 1173, but i don't know where i will change when the query or table are create to set this option to True
Thanks
Posted: Mon 27 Feb 2012 14:34
by AlexP
Hello,
Property values are not automatically initialized to the default value. That is, the default directive controls only when property values are saved to the form file, but not the initial value of the property on a newly created instance. Therefore you should set this option to True in the class constructor too
Posted: Mon 27 Feb 2012 16:56
by lao
Hello AlexP,
thanks for you response.
I change the property QueryRecCount for unitable in file uni.pas
Constructor TUniTable.create(Owner: Tcomponent);
and work fine.
But i have probleme for TUniQUery
if i change the property in
Constructor TCustomUniDataSet.create(Owner: Tcomponent);
the program run in infinite loop.
Can you tell me where i can change this property?
Regards
Posted: Tue 28 Feb 2012 10:45
by AlexP
Hello,
The basic class for both TUniTable.Options and ТUniQuery.Options is the TDADataSetOptions class. The QueryRecCount property should be set to true in its constructor. In this case, the property will be set to True in all DataSets.
Code: Select all
constructor TDADataSetOptions.Create(Owner: TCustomDADataSet);
begin
inherited Create;
FOwner := Owner;
SetFieldsReadOnly := True;
RequiredFields := True;
StrictUpdate := True;
TrimFixedChar := True;
LongStrings := True;
FlatBuffers := False;
RemoveOnRefresh := True;
UpdateBatchSize := 1;
QueryRecCount := True;
end;
Posted: Wed 14 Mar 2012 16:26
by lao
Hi,
I do that in the constructor for queryreccount , and i don't know where i have to change for fetchall to set to false, i try many places, but everytime, the program enter in an infini loop.
can you help me please.
Can you explain me step by step what i have to change
for setting default QueryRecCount = true and fetchall= false for postgresql.
Thanks
sorry for my english...
Posted: Thu 15 Mar 2012 09:32
by AlexP
Hello,
- 1) Delete completely all the UniDAC components from the IDE (IDE Main Menu->Component->Install Packages...-> delete all the Devart packages);
2) QueryRecCount installation. Since this option is global for all packages, this change will affect all providers:
- 2.1) Open the dacXX.dpk package;
2.2) Open the DBAccess.pas file from this package;
2.3) In the DADataSetOptions class constructor, add the line QueryRecCount := True;
Code: Select all
constructor TDADataSetOptions.Create(Owner: TCustomDADataSet);
begin
inherited Create;
FOwner := Owner;
SetFieldsReadOnly := True;
RequiredFields := True;
StrictUpdate := True;
TrimFixedChar := True;
LongStrings := True;
FlatBuffers := False;
RemoveOnRefresh := True;
UpdateBatchSize := 1;
QueryRecCount := True;
end;
- 2.4) Save the DBAccess.pas and build the dacXX.dpk package;
3) Open and build the dacvclXX.dpk package;
4) Open and build the dcldacXX.dpk package;
5) Open and build the unidacXX.dpk package;
6) Open and build the unidacvclXX.dpk package;
7) Open, build, and install the dclunidacXX.dpk package;
8) The FetchAll option installation for the PostgreSQL provider:
- 8.1) Open the pgproviderXX.dpk package;
8.2) Open thePostgreSQLUniProvider.pas file from this package;
8.3) In the TPostgreSQLUniProvider.GetDataSetOptions method change True to False in the line with the FetchAll property setting:
Code: Select all
FDataSetOptions.Add(TBooleanOption.Create('FetchAll', prFetchAll, [TPgSQLRecordSet], FALSE));
- 8.4)Build and install the pgproviderXX.dpk package.
Posted: Thu 15 Mar 2012 16:55
by lao
Thank you very much Alex i will try tomorrw.
Posted: Fri 16 Mar 2012 16:05
by lao
Hello Alex,
I try exactly what you say.
I create a new project.
on the form i put 1 uniconnection, 1 uniquery, 1 postgresprovider,1 button,1 dbgrid and 1 datasource;
the code for the button is : Uniquery1.active := True;
i don't change any option.
when i run the program and click on the button, the program enter in an infini loop.
Regards
Posted: Mon 19 Mar 2012 13:28
by AlexP
Hello,
For resolving this problem, you should add the following code to the DBAccess.pas file into the TDADataSetUpdater.CheckUpdateQuery method:
Code: Select all
....................
TCustomDADataSet(FUpdateQuery).Options.SetEmptyStrToNull := FDataSet.Options.SetEmptyStrToNull;
TCustomDADataSet(FUpdateQuery).Options.FlatBuffers := True;
TCustomDADataSet(FUpdateQuery).Options.QueryRecCount := False; //<-add this line
Posted: Mon 19 Mar 2012 14:12
by lao
Thank you Alex it's working very well.

Posted: Mon 19 Mar 2012 14:19
by AlexP
Hello,
Glad to see that the problem was solved. If you have any other questions, feel free to contact us.
Re: fetchall to false and queryrecount to true for postgresq
Posted: Fri 04 May 2012 15:56
by lao
Hi,
is it possible to use fetchall with postgresql without transaction?
Thanks
Re: fetchall to false and queryrecount to true for postgresq
Posted: Tue 08 May 2012 10:15
by ROD
Hi, lao
Yes, if there is no active transaction, PgDAC itself opens an additional internal connection and starts transaction on this connection.
If don't like it, you can use the TPgDataSetOptions.CursorWithHold option to work without additional internal connection.
Set CursorWithHold to True (False by default). PgDAC will use the DECLARE CURSOR ... WITH HOLD statement to open the query. In this case no active transaction is required but this may take additional server resources.
Re: fetchall to false and queryrecount to true for postgresq
Posted: Wed 09 May 2012 11:14
by lao
Hi ROD,
thank you for your reply.
i have some problems after use tcrbatchmove:
provider postgresql.
i have 2 tables A and B.
i have 1 uniquery named QSource with options:queryreccount:=true and fetchall :=false
and sql = 'select * from A'
i have 1 other query named qtest with sames options and sql= 'select * from B'
i have 1 tunitable named tdest with same options;
i have 1 tcrbatchmove with source =qsources and destination = tdest.
if i do that:
create new table C with same fields than table A;
tdest.tablename = C
QTEST.ACTIVE :=True.(just opened)
tcrbatchmove.execute;
i close tdest.
i change the sql of qsource for deleting the table c 'drop table C'.
and the program frezze.
it's very strange because if the Qtest is not active everything is ok.
and some times i can't update other tables.it's look like a transaction is active and table are locked.
Can you try to reproduce the error?
sorry for my bad english
Thanks