Page 1 of 1

PostgreSQL, UniQuery, FetchAll questions

Posted: Mon 12 Nov 2018 22:37
by FCS
Hello,

Describe please, how to proper use FetchAll option.
I have a big table (more then 2M complex records) and I want to scan it and use some information to insert or update other table.

Example:
UQ:=TUniQuery.Create(nil);
UQ.Connection:=DM_01.UniConnection1;
UQ.Options.DefaultValues:=true;
UQ.UniDirectional := true;
UQ.FetchRows := 10000;
UQ.SpecificOptions.Values['FetchAll'] := 'False';
UQ.SQL.Add('SELECT * FROM big_table;');
UQ.Open;
if UQ.RecordCount>0 then begin
....
end;
UQ.Close;
UQ.Free;

1. The first of all is the scope of FetchAll option. Is this value assigned only for the current query or to the entire connection ?

2. The UniDirectional property scope is only for the current query or to the entire connection??

Regards
Michal

Re: PostgreSQL, UniQuery, FetchAll questions

Posted: Tue 13 Nov 2018 08:00
by azyk
1. FetchAll is a dataset property:
https://www.devart.com/pgdac/docs/devar ... chall.htm . Therefore, it cannot influence the connection. FetchAll influences each dataset separately. For example, in such a code:

Code: Select all

UniQuery1.Connection := UniConnection1;
UniQuery2.Connection := UniConnection1;

UniQuery1.FetchAll := True;
UniQuery2.FetchAll := False;

UniQuery1.Open;
UniQuery2.Open;
You can be sure that UniQuery1 and UniQuery2 do not influence each other. They do not influence UniConnection1 either.

2. TUniQuery.UniDirectional influences only a dataset. TUniQuery.Connection and a database connection are not influenced either.

Re: PostgreSQL, UniQuery, FetchAll questions

Posted: Tue 13 Nov 2018 09:02
by FCS
Thank you.

What difference are between:

UQ:=TUniQuery.Create(nil);
UQ.Connection:=DM_01.UniConnection1;
UQ.UniDirectional := true;
UQ.FetchRows := 10000;

and

UQ:=TUniQuery.Create(nil);
UQ.Connection:=DM_01.UniConnection1;
UQ.FetchRows := 10000;
UQ.FetchAll := False;

In link you posted is written that FetchAll needs active transaction. Why ?

Regards
Michal

Re: PostgreSQL, UniQuery, FetchAll questions

Posted: Thu 15 Nov 2018 15:07
by azyk
UQ:=TUniQuery.Create(nil);
UQ.Connection:=DM_01.UniConnection1;
UQ.UniDirectional := true;
UQ.FetchRows := 10000;

It means that the dataset will be readonly and you will be able to scroll it only to the end. UniDAC will request PostgreSQL for FetchRows records per request.

UQ: = TUniQuery.Create (nil);
UQ.Connection: = DM_01.UniConnection1;
UQ.FetchRows: = 10,000;
UQ.FetchAll: = False;

It means that dataset can be edited and records can be scrolled in both directions.

PostgreSQL does not support multiple transactions within a single connection. Therefore, it is necessary to either fetch all records or close the dataset.

Re: PostgreSQL, UniQuery, FetchAll questions

Posted: Fri 16 Nov 2018 08:32
by FCS
Thank you.

Regards
Michal

Re: PostgreSQL, UniQuery, FetchAll questions

Posted: Fri 16 Nov 2018 11:37
by azyk
If any questions about our products come up , please contact us.