PgDAC PDF
PgDAC PDF
Table of Contents
Part I What's New 1
© 2018 Devart
II PostgreSQL Data Access Components
11 Macros
................................................................................................................................... 92
12 DataSet
...................................................................................................................................
Manager 93
13 TPgLoader
...................................................................................................................................
Component 98
14 Large...................................................................................................................................
Objects 99
15 REFCURSOR
...................................................................................................................................
Data Type 101
16 National
...................................................................................................................................
and Unicode Characters 102
17 Connection
...................................................................................................................................
Pooling 103
18 DBMonitor
................................................................................................................................... 104
19 Writing
...................................................................................................................................
GUI Applications with PgDAC 105
20 Compatibility
...................................................................................................................................
with Previous Versions 105
21 64-bit...................................................................................................................................
Development with Embarcadero RAD Studio XE2 106
22 Database
...................................................................................................................................
Specific Aspects of 64-bit Development 111
© 2018 Devart
Contents III
.........................................................................................................................................................
TCRBatchMode Enumeration 130
.........................................................................................................................................................
TCRFieldMappingMode Enumeration 130
3 CREncryption
................................................................................................................................... 131
Classes .......................................................................................................................................................... 131
.........................................................................................................................................................
TCREncryptor Class 132
Members ......................................................................................................................................... 132
Properties ......................................................................................................................................... 132
DataHeader Property ................................................................................................................................... 133
...................................................................................................................................
EncryptionAlgorithm Property 133
HashAlgorithm Property ................................................................................................................................... 134
...................................................................................................................................
InvalidHashAction Property 134
Passw ord Property ................................................................................................................................... 135
Methods ......................................................................................................................................... 135
SetKey Method ................................................................................................................................... 136
..........................................................................................................................................................
Enum erations 136
.........................................................................................................................................................
TCREncDataHeader Enumeration 137
.........................................................................................................................................................
TCREncryptionAlgorithm Enumeration 137
.........................................................................................................................................................
TCRHashAlgorithm Enumeration 138
.........................................................................................................................................................
TCRInvalidHashAction Enumeration 138
4 DAAlerter
................................................................................................................................... 138
Classes .......................................................................................................................................................... 139
.........................................................................................................................................................
TDAAlerter Class 139
Members ......................................................................................................................................... 140
Properties ......................................................................................................................................... 140
Active Property................................................................................................................................... 141
AutoRegister Property ................................................................................................................................... 141
Connection Property ................................................................................................................................... 142
Methods ......................................................................................................................................... 142
SendEvent Method ................................................................................................................................... 143
Start Method ................................................................................................................................... 143
Stop Method ................................................................................................................................... 144
Events ......................................................................................................................................... 144
OnError Event ................................................................................................................................... 144
Types .......................................................................................................................................................... 145
.........................................................................................................................................................
TAlerterErrorEvent Procedure Reference 145
5 DADump
................................................................................................................................... 145
Classes .......................................................................................................................................................... 146
TDADump.........................................................................................................................................................
Class 146
Members ......................................................................................................................................... 147
Properties ......................................................................................................................................... 148
Connection Property ................................................................................................................................... 149
Debug Property................................................................................................................................... 149
Options Property ................................................................................................................................... 150
SQL Property ................................................................................................................................... 151
TableNames Property ................................................................................................................................... 151
Methods ......................................................................................................................................... 152
Backup Method................................................................................................................................... 152
BackupQuery Method ................................................................................................................................... 153
BackupToFile Method ................................................................................................................................... 153
BackupToStream ...................................................................................................................................
Method 154
Restore Method ................................................................................................................................... 155
RestoreFromFile ...................................................................................................................................
Method 155
RestoreFromStream ...................................................................................................................................
Method 156
© 2018 Devart
IV PostgreSQL Data Access Components
© 2018 Devart
Contents V
© 2018 Devart
VI PostgreSQL Data Access Components
.........................................................................................................................................................
TCustomDASQLMonitor Class 208
Members ......................................................................................................................................... 208
Properties ......................................................................................................................................... 209
Active Property................................................................................................................................... 209
DBMonitorOptions ...................................................................................................................................
Property 210
Options Property ................................................................................................................................... 210
TraceFlags Property ................................................................................................................................... 211
Events ......................................................................................................................................... 211
OnSQL Event ................................................................................................................................... 211
.........................................................................................................................................................
TDBMonitorOptions Class 212
Members ......................................................................................................................................... 212
Properties ......................................................................................................................................... 213
Host Property ................................................................................................................................... 213
Port Property ................................................................................................................................... 214
ReconnectTimeout ...................................................................................................................................
Property 214
SendTimeout Property ................................................................................................................................... 214
Types .......................................................................................................................................................... 215
.........................................................................................................................................................
TDATraceFlags Set 215
.........................................................................................................................................................
TMonitorOptions Set 215
.........................................................................................................................................................
TOnSQLEvent Procedure Reference 216
.......................................................................................................................................................... 216
Enum erations
.........................................................................................................................................................
TDATraceFlag Enumeration 216
.........................................................................................................................................................
TMonitorOption Enumeration 217
9 DBAccess
................................................................................................................................... 218
Classes .......................................................................................................................................................... 220
EDAError.........................................................................................................................................................
Class 222
Members ......................................................................................................................................... 222
Properties ......................................................................................................................................... 223
Component Property ................................................................................................................................... 223
ErrorCode Property ................................................................................................................................... 223
.........................................................................................................................................................
TCRDataSource Class 224
Members ......................................................................................................................................... 224
.........................................................................................................................................................
TCustomConnectDialog Class 224
Members ......................................................................................................................................... 225
Properties ......................................................................................................................................... 226
CancelButton Property ................................................................................................................................... 227
Caption Property ................................................................................................................................... 227
ConnectButton Property ................................................................................................................................... 227
DialogClass Property ................................................................................................................................... 228
LabelSet Property ................................................................................................................................... 228
Passw ordLabel Property................................................................................................................................... 229
Retries Property ................................................................................................................................... 229
SavePassw ord Property ................................................................................................................................... 229
ServerLabel Property ................................................................................................................................... 230
StoreLogInfo Property ................................................................................................................................... 230
UsernameLabel Property ................................................................................................................................... 230
Methods ......................................................................................................................................... 231
Execute Method ................................................................................................................................... 231
GetServerList Method ................................................................................................................................... 232
.........................................................................................................................................................
TCustomDAConnection Class 232
Members ......................................................................................................................................... 233
Properties ......................................................................................................................................... 235
ConnectDialog Property ................................................................................................................................... 236
ConnectString Property ................................................................................................................................... 236
© 2018 Devart
Contents VII
© 2018 Devart
VIII PostgreSQL Data Access Components
© 2018 Devart
Contents IX
© 2018 Devart
X PostgreSQL Data Access Components
© 2018 Devart
Contents XI
© 2018 Devart
XII PostgreSQL Data Access Components
© 2018 Devart
Contents XIII
© 2018 Devart
XIV PostgreSQL Data Access Components
© 2018 Devart
Contents XV
CancelUpdates...................................................................................................................................
Method 486
CommitUpdates...................................................................................................................................
Method 487
DeferredPost Method ................................................................................................................................... 487
EditRangeEnd Method ................................................................................................................................... 488
EditRangeStart...................................................................................................................................
Method 488
GetBlob Method ................................................................................................................................... 489
GetBlob Method ................................................................................................................................... 489
GetBlob Method ................................................................................................................................... 490
Locate Method................................................................................................................................... 490
Locate Method................................................................................................................................... 491
Locate Method................................................................................................................................... 491
LocateEx Method ................................................................................................................................... 492
LocateEx Method ................................................................................................................................... 493
LocateEx Method ................................................................................................................................... 493
Prepare Method ................................................................................................................................... 494
RestoreUpdates ...................................................................................................................................
Method 495
RevertRecord ...................................................................................................................................
Method 495
SaveToXML Method ................................................................................................................................... 496
SaveToXML Method ................................................................................................................................... 496
SaveToXML Method ................................................................................................................................... 497
SetRange Method ................................................................................................................................... 497
SetRangeEnd Method ................................................................................................................................... 498
SetRangeStart...................................................................................................................................
Method 499
UnPrepare Method ................................................................................................................................... 500
UpdateResult Method ................................................................................................................................... 500
UpdateStatus Method ................................................................................................................................... 501
Events ......................................................................................................................................... 501
OnUpdateError...................................................................................................................................
Event 502
OnUpdateRecord ...................................................................................................................................
Event 502
Variables .......................................................................................................................................................... 503
.........................................................................................................................................................
DoNotRaiseExcetionOnUaFail Variable 503
.........................................................................................................................................................
SendDataSetChangeEventAfterOpen Variable 504
12 PgAccess
................................................................................................................................... 504
Classes .......................................................................................................................................................... 507
.........................................................................................................................................................
TCustomPgDataSet Class 508
Members ......................................................................................................................................... 509
Properties ......................................................................................................................................... 519
Cursor Property ................................................................................................................................... 523
DMLRefresh Property ................................................................................................................................... 524
FetchAll Property ................................................................................................................................... 524
KeySequence Property ................................................................................................................................... 525
LastInsertOID Property ................................................................................................................................... 525
Options Property ................................................................................................................................... 526
Params Property ................................................................................................................................... 527
SequenceMode Property ................................................................................................................................... 527
UpdateObject Property ................................................................................................................................... 528
Methods ......................................................................................................................................... 528
CreateProcCall Method ................................................................................................................................... 533
FindParam Method ................................................................................................................................... 534
GetPgCursor Method ................................................................................................................................... 535
GetPgDate Method ................................................................................................................................... 535
GetPgInterval Method ................................................................................................................................... 536
GetPgLargeObject Method................................................................................................................................... 536
GetPgRow Method ................................................................................................................................... 537
© 2018 Devart
XVI PostgreSQL Data Access Components
© 2018 Devart
Contents XVII
.........................................................................................................................................................
TPgConnectionOptions Class 604
Members ......................................................................................................................................... 605
Properties ......................................................................................................................................... 606
ApplicationName ...................................................................................................................................
Property 608
Charset Property ................................................................................................................................... 608
EnableBCD Property ................................................................................................................................... 609
EnableComposites ...................................................................................................................................
Property 609
EnableDomains...................................................................................................................................
Property 610
EnableFMTBCD...................................................................................................................................
Property 610
EnableGeometrics ...................................................................................................................................
Property 610
EnablePgTimeStamps ...................................................................................................................................
Property 611
ImmediateNotices ...................................................................................................................................
Property 611
IPVersion Property ................................................................................................................................... 612
MessagesCharset ...................................................................................................................................
Property 612
UseUnicode Property ................................................................................................................................... 612
.........................................................................................................................................................
TPgConnectionSSLOptions Class 613
Members ......................................................................................................................................... 613
Properties ......................................................................................................................................... 614
CACert Property ................................................................................................................................... 614
Cert Property ................................................................................................................................... 615
CipherList Property ................................................................................................................................... 615
Key Property ................................................................................................................................... 615
Mode Property................................................................................................................................... 616
.........................................................................................................................................................
TPgCursorField Class 616
Members ......................................................................................................................................... 616
Properties ......................................................................................................................................... 617
AsCursor Property ................................................................................................................................... 617
.........................................................................................................................................................
TPgDataSetOptions Class 617
Members ......................................................................................................................................... 618
Properties ......................................................................................................................................... 621
AutoDeleteBlob...................................................................................................................................
Property 624
CacheBlobs Property ................................................................................................................................... 625
CursorWithHold ...................................................................................................................................
Property 625
DeferredBlobRead ...................................................................................................................................
Property 626
DistinctParams...................................................................................................................................
Property 626
EnableBCD Property ................................................................................................................................... 626
EnableFMTBCD...................................................................................................................................
Property 626
ExtendedFieldsInfo ...................................................................................................................................
Property 627
FullRefresh Property ................................................................................................................................... 627
OIDAsInt Property ................................................................................................................................... 628
PrepareUpdateSQL ...................................................................................................................................
Property 628
SetEmptyStrToNull ...................................................................................................................................
Property 629
Unknow nAsString ...................................................................................................................................
Property 629
UnpreparedExecute ...................................................................................................................................
Property 629
UseParamTypes ...................................................................................................................................
Property 630
.........................................................................................................................................................
TPgDataSource Class 630
Members ......................................................................................................................................... 631
.........................................................................................................................................................
TPgDateField Class 631
Members ......................................................................................................................................... 631
Properties ......................................................................................................................................... 632
AsPgDate Property ................................................................................................................................... 632
.........................................................................................................................................................
TPgEncryptor Class 633
Members ......................................................................................................................................... 633
.........................................................................................................................................................
TPgGeometricField Class 634
© 2018 Devart
XVIII PostgreSQL Data Access Components
© 2018 Devart
Contents XIX
© 2018 Devart
XX PostgreSQL Data Access Components
.........................................................................................................................................................
TPgConnectDialog Class 741
Members ......................................................................................................................................... 742
Properties ......................................................................................................................................... 744
Connection Property ................................................................................................................................... 745
DatabaseLabel...................................................................................................................................
Property 746
PortLabel Property ................................................................................................................................... 746
Show Database ...................................................................................................................................
Property 747
Show Port Property ................................................................................................................................... 747
17 PgDump
................................................................................................................................... 748
Classes .......................................................................................................................................................... 748
TPgDump.........................................................................................................................................................
Class 749
Members ......................................................................................................................................... 749
Properties ......................................................................................................................................... 751
Mode Property ................................................................................................................................... 752
ObjectTypes Property ................................................................................................................................... 752
Options Property ................................................................................................................................... 753
SchemaNames Property ................................................................................................................................... 753
.........................................................................................................................................................
TPgDumpOptions Class 754
Members ......................................................................................................................................... 754
Properties ......................................................................................................................................... 755
...................................................................................................................................
CreateConstraints Property 755
Types .......................................................................................................................................................... 756
.........................................................................................................................................................
TPgDumpObjects Set 756
..........................................................................................................................................................
Enum erations 756
.........................................................................................................................................................
TPgDumpMode Enumeration 756
.........................................................................................................................................................
TPgDumpObject Enumeration 757
18 PgError
................................................................................................................................... 758
Classes .......................................................................................................................................................... 758
EPgError .........................................................................................................................................................
Class 758
Members ......................................................................................................................................... 759
Properties ......................................................................................................................................... 759
CallStack Property ................................................................................................................................... 760
DetailMsg Property ................................................................................................................................... 761
ErrorCode Property ................................................................................................................................... 761
FileName Property ................................................................................................................................... 761
Hint Property ................................................................................................................................... 762
LineNumber Property ................................................................................................................................... 762
Position Property ................................................................................................................................... 762
ProcedureName ...................................................................................................................................
Property 763
Severity Property ................................................................................................................................... 763
.......................................................................................................................................................... 763
Enum erations
.........................................................................................................................................................
TPgSeverity Enumeration 764
19 PgLoader
................................................................................................................................... 764
Classes .......................................................................................................................................................... 765
.........................................................................................................................................................
TPgLoader Class 765
Members ......................................................................................................................................... 765
Properties ......................................................................................................................................... 767
BufferSize Property ................................................................................................................................... 768
Connection Property ................................................................................................................................... 768
TextMode Property ................................................................................................................................... 768
.........................................................................................................................................................
TPgLoaderColumn Class 769
Members ......................................................................................................................................... 769
Properties ......................................................................................................................................... 770
© 2018 Devart
Contents XXI
Row TypeName...................................................................................................................................
Property 770
20 PgObjects
................................................................................................................................... 771
Classes .......................................................................................................................................................... 772
.........................................................................................................................................................
TCustomPgTimeStamp Class 773
Members ......................................................................................................................................... 774
Properties ......................................................................................................................................... 775
AsDateTime Property ................................................................................................................................... 776
AsSQLTimeStamp Property................................................................................................................................... 777
AsString Property ................................................................................................................................... 777
Days Property ................................................................................................................................... 777
HasTimeZone Property ................................................................................................................................... 778
IsInfinity Property ................................................................................................................................... 778
IsNegInfinity Property ................................................................................................................................... 778
IsPosInfinity Property ................................................................................................................................... 779
Ticks Property ................................................................................................................................... 779
TimeZoneOffset Property................................................................................................................................... 779
Methods ......................................................................................................................................... 780
Assign Method ................................................................................................................................... 781
Compare Method ................................................................................................................................... 781
DecodeDate Method ................................................................................................................................... 782
DecodeDateTime Method ................................................................................................................................... 782
DecodeTime Method ................................................................................................................................... 783
EncodeDate Method ................................................................................................................................... 784
EncodeDateTime Method ................................................................................................................................... 784
EncodeTime Method ................................................................................................................................... 785
.........................................................................................................................................................
TPgAttribute Class 786
Members ......................................................................................................................................... 786
.........................................................................................................................................................
TPgBox Class 787
Members ......................................................................................................................................... 788
Properties ......................................................................................................................................... 788
Low erLeft Property ................................................................................................................................... 789
UpperRight Property ................................................................................................................................... 789
.........................................................................................................................................................
TPgCircle Class 790
Members ......................................................................................................................................... 790
Properties ......................................................................................................................................... 791
Center Property ................................................................................................................................... 792
Radius Property ................................................................................................................................... 792
.........................................................................................................................................................
TPgDate Class 792
Members ......................................................................................................................................... 793
.........................................................................................................................................................
TPgGeometric Class 795
Members ......................................................................................................................................... 795
Properties ......................................................................................................................................... 796
AsString Property ................................................................................................................................... 797
Methods ......................................................................................................................................... 797
Assign Method ................................................................................................................................... 797
.........................................................................................................................................................
TPgInterval Class 798
Members ......................................................................................................................................... 798
Properties ......................................................................................................................................... 799
AsString Property ................................................................................................................................... 800
Days Property ................................................................................................................................... 800
MonthsFull Property ................................................................................................................................... 801
SecondsFull Property ................................................................................................................................... 801
Methods ......................................................................................................................................... 801
Assign Method ................................................................................................................................... 802
© 2018 Devart
XXII PostgreSQL Data Access Components
© 2018 Devart
Contents XXIII
.........................................................................................................................................................
TPgRow Type Class 832
Members ......................................................................................................................................... 832
Methods ......................................................................................................................................... 833
Describe Method ................................................................................................................................... 833
Describe Method ................................................................................................................................... 833
Describe Method ................................................................................................................................... 833
.........................................................................................................................................................
TPgSQLLargeObject Class 834
Members ......................................................................................................................................... 834
Properties ......................................................................................................................................... 836
Cached Property ................................................................................................................................... 837
Connection Property ................................................................................................................................... 838
OID Property ................................................................................................................................... 838
Methods ......................................................................................................................................... 839
CloseObject Method ................................................................................................................................... 840
CreateObject Method ................................................................................................................................... 841
OpenObject Method ................................................................................................................................... 841
ReadBlob Method ................................................................................................................................... 841
UnlinkObject Method ................................................................................................................................... 842
WriteBlob Method ................................................................................................................................... 842
......................................................................................................................................................... 842
TPgTime Class
Members ......................................................................................................................................... 843
Properties ......................................................................................................................................... 845
TimeZoneOffset ...................................................................................................................................
Property 846
.........................................................................................................................................................
TPgTimeStamp Class 847
Members ......................................................................................................................................... 847
21 PgScript
................................................................................................................................... 849
Classes .......................................................................................................................................................... 850
TPgScript.........................................................................................................................................................
Class 850
Members ......................................................................................................................................... 850
22 PgSQLMonitor
................................................................................................................................... 853
Classes .......................................................................................................................................................... 853
.........................................................................................................................................................
TPgSQLMonitor Class 853
Members ......................................................................................................................................... 854
23 VirtualDataSet
................................................................................................................................... 855
Classes .......................................................................................................................................................... 855
.........................................................................................................................................................
TCustomVirtualDataSet Class 855
Members ......................................................................................................................................... 855
.........................................................................................................................................................
TVirtualDataSet Class 859
Members ......................................................................................................................................... 859
Types .......................................................................................................................................................... 862
.........................................................................................................................................................
TOnDeleteRecordEvent Procedure Reference 863
.........................................................................................................................................................
TOnGetFieldValueEvent Procedure Reference 863
.........................................................................................................................................................
TOnGetRecordCountEvent Procedure Reference 864
.........................................................................................................................................................
TOnModifyRecordEvent Procedure Reference 864
24 VirtualTable
................................................................................................................................... 865
Classes .......................................................................................................................................................... 865
.........................................................................................................................................................
TVirtualTable Class 865
Members ......................................................................................................................................... 865
© 2018 Devart
1 PostgreSQL Data Access Components
1 What's New
© 2018 Devart
What's New 2
© 2018 Devart
3 PostgreSQL Data Access Components
© 2018 Devart
What's New 4
© 2018 Devart
5 PostgreSQL Data Access Components
© 2018 Devart
General Information 6
2 General Information
This section contains general information about PostgreSQL Server Data Access
Components
Overview
Features
Requirements
Compatibility
Using Several DAC Products in One IDE
Component List
Hierarchy Chart
Editions
Licensing and Subscriptions
Getting Support
2.1 Overview
PostgreSQL Data Access Components (PgDAC) is a library of components that provides
direct access to PostgreSQL database servers from Delphi, C++Builder and Lazarus (Free
Pascal). PgDAC is designed to help programmers develop really lightweight, faster and
cleaner PostgreSQL database applications without deploying any additional libraries.
PgDAC is a complete replacement for standard PostgreSQL connectivity solutions and
presents an efficient alternative to the Borland Database Engine for access to PostgreSQL.
The PgDAC library is actively developed and supported by the Devart Team. If you have
questions about PgDAC, email the developers at [email protected] or visit PgDAC online
at https://www.devart.com/pgdac/.
© 2018 Devart
7 PostgreSQL Data Access Components
Optimized Code
The goal of PgDAC is to enable developers to write efficient and flexible database
applications. The PgDAC library is implemented using advanced data access algorithms and
optimization techniques. Classes and components undergo comprehensive performance
tests and are designed to help you write high-performance, lightweight data access layers.
Key Features
The following list describes the main features of PostgreSQL Data Access Components.
Direct access to server data without using client library. Does not require installation of
other data provider layers (such as BDE and ODBC)
Full support of the latest versions of PostgreSQL Server
Support for all PostgreSQL Server data types
Disconnected Model with automatic connection control for working with data offline
Local Failover for detecting connection loss and implicitly reexecuting certain operations
All types of local sorting and filtering, including by calculated and lookup fields
© 2018 Devart
General Information 8
The full list of PgDAC features are available in the Features topic.
© 2018 Devart
9 PostgreSQL Data Access Components
General usability:
Direct access to server data. Does not require installation of other data provider layers
(such as BDE and ODBC)
Interface compatible with standard data access methods, such as BDE and ADO
VCL, LCL and FMX versions of library available
Separated run-time and GUI specific parts allow you to create pure console applications
such as CGI
Unicode and national charset support
© 2018 Devart
General Information 10
Compatibility:
Full support of the latest versions of PostgreSQL
Support for all PostgreSQL data types
Compatible with all IDE versions starting with Delphi 6, C++Builder 6, Free Pascal
Includes provider for UniDAC Express Edition
Wide reporting component support, including support for InfoPower, ReportBuilder,
FastReport
Support of all standard and third-party visual data-aware controls
Allows you to use Professional Edition of Delphi and C++Builder to develop client/server
applications
PostgreSQL DataTypes:
Support for PostgreSQL Protocol 2 and Protocol 3
PostgreSQL Composite types support
PostgreSQL domain types support
Full support of the DATE , TIME , TIMESTAMP , and INTERVAL data types
Advanced LARGE OBJECT support
Advanced support of the REFCURSOR type
Wrapper classes for geometic types support
Performance:
High overall performance
Fast controlled fetch of large data blocks
Optimized string data storing
Advanced connection pooling
High performance of applying cached updates with batches
Caching of calculated and lookup fields
© 2018 Devart
11 PostgreSQL Data Access Components
Data exchange:
Transferring data between all types of TDataSet descendants with TCRBatchMove
component
Data export and M:Devart.Dac.TVirtualTable.LoadFromFile(System.String,System.Boolean)
to/from XML (ADO format)
© 2018 Devart
General Information 12
Script execution:
Advanced script execution features with the TPgScript component
Support for executing individual statements in scripts
Support for executing huge scripts stored in files with dynamic loading
Ability to break long-running query execution
Visual extensions:
Includes source code of enhanced TCRDBGrid data-aware grid control
Customizable connection dialog
Cursor changes during non-blocking execution
Design-time enhancements:
DataSet Manager tool to control DataSet instances in the project
Advanced design-time component and property editors
Automatic design-time component linking
More convenient data source setup with the TPgDataSource component
Syntax highlighting in design-time editors
Product clarity:
Complete documentation sets
Printable documentation in PDF format
A large amount of helpful demo projects
© 2018 Devart
13 PostgreSQL Data Access Components
2.3 Requirements
PgDAC works directly through TCP/IP protocol and does not use the PostgreSQL client
library.
2.4 Compatibility
PostgreSQL Compatibility
PgDAC supports PostgreSQL server versions since 8.0 up to 11.
IDE Compatibility
PgDAC is compatible with the following IDEs:
Embarcadero RAD Studio 10.3 Rio
o Embarcadero Delphi 10.3 Rio for Windows 32-bit & 64-bit
o Embarcadero Delphi 10.3 Rio for macOS
o Embarcadero Delphi 10.3 Rio for Linux 64-bit
o Embarcadero Delphi 10.3 Rio for iOS 32-bit & 64-bit
o Embarcadero Delphi 10.3 Rio for Android
o Embarcadero C++Builder 10.3 Rio for Windows 32-bit & 64-bit
o Embarcadero C++Builder 10.3 Rio for macOS
o Embarcadero C++Builder 10.3 Rio for iOS 32-bit & 64-bit
o Embarcadero C++Builder 10.3 Rio for Android
Embarcadero RAD Studio 10.2 Tokyo
o Embarcadero Delphi 10.2 Tokyo for Windows 32-bit & 64-bit
o Embarcadero Delphi 10.2 Tokyo for macOS
o Embarcadero Delphi 10.2 Tokyo for Linux 64-bit
o Embarcadero Delphi 10.2 Tokyo for iOS 32-bit & 64-bit
o Embarcadero Delphi 10.2 Tokyo for Android
© 2018 Devart
General Information 14
© 2018 Devart
15 PostgreSQL Data Access Components
© 2018 Devart
General Information 16
All the existing Delphi and C++Builder editions are supported: Architect, Enterprise,
Professional, Community, and Starter.
Lazarus and Free Pascal are supported only in Trial Edition and Professional Edition with
source code.
Note that support for 64-bit Windows and macOS was introduced in RAD Studio XE2, and is
not available in older versions of RAD Studio. Support for iOS is available since RAD Studio
© 2018 Devart
17 PostgreSQL Data Access Components
XE4, but support for iOS 64-bit is available since RAD Studio XE8. Support for Android is
available since RAD Studio XE5. Support for Linux 64-bit is available since RAD Studio 10.2
Tokyo.
Note that product compatibility is provided for the current build only. In other words, if you
upgrade one of the installed products, it may conflict with older builds of other products. In
order to continue using the products simultaneously, you should upgrade all of them at the
same time.
© 2018 Devart
General Information 18
TPgUpdateSQL Lets you tune update operations for the DataSet component.
TPgLoader Provides quick loading of external data into the server database.
© 2018 Devart
19 PostgreSQL Data Access Components
See Also
Hierarchy chart
TObject
|—TPersistent
|—TComponent
| |—TCustomConnection
| | |—TCustomDAConnection
| | |—TPgConnection
| |—TDataSet
| | |—TMemDataSet
| | |—TCustomDADataSet
| | | |—TCustomPgDataSet
| | | |—TPgQuery
| | | |—TCustomPgTable
| | | | |—TPgTable
| | | |—TCustomPgStoredProc
| | | |—TPgStoredProc
| | |—TDAMetaData
| | |—TPgMetaData
| | |—TVirtualTable
| |—TDataSource
| | |—TCRDataSource
| | |—TPgDataSource
| |—DADataAdapter
| | |—PgDataAdapter
| |—TCRBatchMove
| |—TCustomConnectDialog
© 2018 Devart
General Information 20
| | |—TPgConnectDialog
| |—TCustomDASQL
| | |—TPgSQL
| |—TCustomDASQLMonitor
| | |—TPgSQLMonitor
| |—TDALoader
| | |—TPgLoader
| |—TDAScript
| | |—TPgScript
| |—TDADump
| | |—TPgDump
| |—TDATransaction
| | |TPgTransaction
| |—TDAAlerter
| |TPgAlerter
| |—TCREncryptor
| | |TPgEncryptor
|—TSharedObject
|—TBlob
| |—TCompressedBlob
| |—TPgSQLLargeObject
| |—TPgLargeObject
|—TObjectType
| |—TPgRowType
|—TDBObject
| |—TPgRow
|—TCRCursor
| |—TPgCursor
| |—TPgRefCursor
|—TCustomPgTimeStamp
| |—TPgTimeStamp
| |—TPgDate
| |—TPgTime
|—TPgInterval
|—TPgGeometric
|—TPgPoint
|—TPgCircle
© 2018 Devart
21 PostgreSQL Data Access Components
|—PgPointsArray
|—TPgLSeg
|—TPgBox
|—TPgPath
|—TPgPolygon
2.8 Editions
PostgreSQL Data Access Components comes in three editions: PgDAC Standard Edition,
PgDAC Professional Edition, and PgDAC Trial Edition.
PgDAC Standard Edition includes the PgDAC basic connectivity components. PgDAC
Standard Edition is a cost-effective solution for database application developers who are
looking for overall high performance connectivity to PostgreSQL.
PgDAC Professional Edition shows off the full power of PgDAC, enhancing PgDAC
Standard Edition with support for PostgreSQL-specific functionality and advanced dataset
management features.
PgDAC Trial Edition is the evaluation version of PgDAC. It includes all the functionality of
PgDAC Professional Edition with a trial limitation of 60 days. C++Builder has additional trial
limitations.
You can get Source Access to the PgDAC Standard and PgDAC Professional Editions by
purchasing the special PgDAC Standard Edition with Source Code or PgDAC Professional
Edition with Source Code. The Standard and Professional editions include the source code
for all component classes. The source code of DataSet Manager is not distributed.
FreePascal support is available in Editions with Source Code and Trial Edition.
Windows
macOS
© 2018 Devart
General Information 22
Linux
iOS
Android
Base Components:
TPgConnection
TPgQuery
TPgSQL
TPgTable
TPgStoredProc
TPgUpdateSQL
TPgDataSource
Script executing
TPgScript
Fast data loading into the server
TPgLoader
PostgreSQL Specific Components
© 2018 Devart
23 PostgreSQL Data Access Components
DataSet Manager
2.9 Licensing
PLEASE READ THIS LICENSE AGREEMENT CAREFULLY. BY INSTALLING OR USING
THIS SOFTWARE, YOU INDICATE ACCEPTANCE OF AND AGREE TO BECOME BOUND
BY THE TERMS AND CONDITIONS OF THIS LICENSE. IF YOU DO NOT AGREE TO THE
TERMS OF THIS LICENSE, DO NOT INSTALL OR USE THIS SOFTWARE AND
PROMPTLY RETURN IT TO DEVART.
INTRODUCTION
This Devart end-user license agreement ("Agreement") is a legal agreement between you
(either an individual person or a single legal entity) and Devart, for the use of PgDAC software
application, source code, demos, intermediate files, printed materials, and online or electronic
documentation contained in this installation file. For the purpose of this Agreement, the
software program(s) and supporting documentation will be referred to as the "Software".
LICENSE
© 2018 Devart
General Information 24
1. GRANT OF LICENSE
The enclosed Software is licensed, not sold. You have the following rights and privileges,
subject to all limitations, restrictions, and policies specified in this Agreement.
1.1. If you are a legally licensed user, depending on the license type specified in the
registration letter you have received from Devart upon purchase of the Software, you are
entitled to either:
install and use the Software on one or more computers, provided it is used by 1 (one) for
the sole purposes of developing, testing, and deploying applications in accordance with this
Agreement (the "Single Developer License"); or
install and use the Software on one or more computers, provided it is used by up to 4 (four)
developers within a single company at one physical address for the sole purposes of
developing, testing, and deploying applications in accordance with this Agreement (the
"Team Developer License"); or
install and use the Software on one or more computers, provided it is used by developers in
a single company at one physical address for the sole purposes of developing, testing, and
deploying applications in accordance with this Agreement (the "Site License").
1.2. If you are a legally licensed user of the Software, you are also entitled to:
make one copy of the Software for archival purposes only, or copy the Software onto the
hard disk of your computer and retain the original for archival purposes;
develop and test applications with the Software, subject to the Limitations below;
create libraries, components, and frameworks derived from the Software for personal use
only;
deploy and register run-time libraries and packages of the Software, subject to the
Redistribution policy defined below.
1.3. You are allowed to use evaluation versions of the Software as specified in the Evaluation
section.
No other rights or privileges are granted in this Agreement.
2. LIMITATIONS
Only legally registered users are licensed to use the Software, subject to all of the conditions
of this Agreement. Usage of the Software is subject to the following restrictions.
2.1. You may not reverse engineer, decompile, or disassemble the Software.
2.2. You may not build any other components through inheritance for public distribution or
commercial sale.
2.3. You may not use any part of the source code of the Software (original or modified) to
© 2018 Devart
25 PostgreSQL Data Access Components
3. REDISTRIBUTION
The license grants you a non-exclusive right to compile, reproduce, and distribute any new
software programs created using PgDAC. You can distribute PgDAC only in compiled
Executable Programs or Dynamic-Link Libraries with required run-time libraries and
packages.
All Devart's units, source code, and other files remain Devart's exclusive property.
4. TRANSFER
You may not transfer the Software to any individual or entity without express written
permission from Devart. In particular, you may not share copies of the Software under “Single
Developer License” and “Team License” with other co-developers without obtaining proper
license of these copies for each individual.
5. TERMINATION
Devart may immediately terminate this Agreement without notice or judicial resolution in the
event of any failure to comply with any provision of this Agreement. Upon such termination
you must destroy the Software, all accompanying written materials, and all copies.
6. EVALUATION
Devart may provide evaluation ("Trial") versions of the Software. You may transfer or
distribute Trial versions of the Software as an original installation package only. If the Software
you have obtained is marked as a "Trial" version, you may install and use the Software for a
period of up to 60 calendar days from the date of installation (the "Trial Period"), subject to the
additional restriction that it is used solely for evaluation of the Software and not in conjunction
with the development or deployment of any application in production. You may not use
© 2018 Devart
General Information 26
applications developed using Trial versions of the Software for any commercial purposes.
Upon expiration of the Trial Period, the Software must be uninstalled, all its copies and all
accompanying written materials must be destroyed.
7. WARRANTY
The Software and documentation are provided "AS IS" without warranty of any kind. Devart
makes no warranties, expressed or implied, including, but not limited to, the implied
warranties of merchantability and fitness for a particular purpose or use.
9. COPYRIGHT
The Software is confidential and proprietary copyrighted work of Devart and is protected by
international copyright laws and treaty provisions. You may not remove the copyright notice
from any copy of the Software or any copy of the written materials, accompanying the
Software.
This Agreement contains the total agreement between the two parties and supersedes any
other agreements, written, oral, expressed, or implied.
Support Options
There are a number of resources for finding help on installing and using PgDAC.
You can find out more about PgDAC installation or licensing by consulting the Licensing
section.
© 2018 Devart
27 PostgreSQL Data Access Components
You can get community assistance and technical support on the PgDAC Community
Forum.
You can get advanced technical assistance by PgDAC developers through the PgDAC
Priority Support program.
If you have a question about ordering PgDAC or any other Devart product, please contact
[email protected].
2.11 FAQ
This page contains a list of Frequently Asked Questions for PostgreSQL Data Access
Components.
If you have encounter a question with using PgDAC, please browse through this list first. If
this page does not answer your question, refer to the Getting Support topic in PgDAC help.
You may be having a compatibility issue that shows up in one or more of the following forms:
o Get a "Setup has detected already installed DAC packages which are incompatible with
current version" message during PgDAC installation.
o Get a "Procedure entry point ... not found in ... " message when starting IDE.
© 2018 Devart
General Information 28
o Get a "Unit ... was compiled with a different version of ..." message on compilation.
You can have such problems if you installed incompatible PgDAC, SDAC, ODAC or IBDAC
versions. All these products use common base packages. The easiest way to avoid the
problem is to uninstall all installed DAC products and then download from our site and install
the last builds.
Usually, you do not need any additional files. The only exceptions to this rule are listed below:
o If you are connecting in Client mode, (TPgConnection.Options.Direct = False), you need
PostgreSQL client library.
o If you are using SSL (TPgConnection.Options.Protocol = mpSSL), you need the
OpenSSL library files - ssleay32.dll and libeay32.dll.
3. When I try to connect to the server, I get an error "PostgreSQL client library
couldn't be loaded."
You are using TPgConnection.Options.Direct := False mode and the client library is not
available for your application.
Windows: You should copy client file PostgreSQL client library to a folder available to the
executable unit of your program. For example, to the folder containing the executable or to the
Windows system folder. For more details, see the description of LoadLibrary and the PATH
environment variable.
Linux: You should copy the client file libPostgreSQLclient.so.X to the folder available to the
executable unit of your program. For more details, see the description of the dlopen function
and the LD_LIBRARY_PATH environment variable.
If you have purchased a full version of PgDAC, you are entitled to distribute pre-compiled
programs created with its use. You are not entitled to propagate any components inherited
from PgDAC or using PgDAC source code. For more information see the License.rtf file in
your PgDAC installation directory.
You can create your own components that are inherited from PgDAC or that use the PgDAC
source code. You are entitled to sell and distribute compiled application executables that use
© 2018 Devart
29 PostgreSQL Data Access Components
such components, but not their source code and not the components themselves.
All upgrades to future versions are free to users with an active PgDAC Subscription.
The PgDAC Subscription Program is an annual maintenance and support service for
PgDAC users.
Priority Support is an advanced product support program which offers you expedited
individual assistance with PgDAC-related questions from the PgDAC developers themselves.
Priority Support is carried out over email and has a two business day response policy.
You can renew your PgDAC Subscription on the PgDAC Ordering Page. For more
information, please contact [email protected].
7. How do I upgrade?
To upgrade to new PgDAC versions, you can get a Version Update from the PgDAC Ordering
Page. For more information, please contact [email protected].
Performance
1. How productive is PgDAC?
PgDAC uses a low-level protocol to access the database server. This allows PgDAC to
© 2018 Devart
General Information 30
achieve high performance. From time to time we compare PgDAC with other products, and
PgDAC always takes first place.
2. Why does the Locate function work so slowly the first time I use it?
Locate is performed on the client. So if you had set FetchAll to False when opening your
dataset, cached only some of the rows on the client, and then invoked Locate, PgDAC will
have to fetch all the remaining rows from the server before performing the operation. On
subsequent calls, Locate should work much faster.
If the Locate method keeps working slowly on subsequent calls or you are working with
FetchAll=True, try the following. Perform local sorting by a field that is used in the Locate
method. Just assign corresponding field name to the IndexFieldNames property.
How To
1. How can I quickly convert a project from BDE to PgDAC?
To quickly migrate your project from BDE you can use the BDE Migration Wizard. To start it,
open your project and choose BDE Migration Wizard from the PgDAC menu of your IDE.
3. How can I stop the cursor from changing to an hour glass during query execution?
Just set the DBAccess.ChangeCursor variable to False anywhere in your program. The
cursor will stop changing after this command is executed.
The values of these properties are templates for query statements, and they cannot be
manually executed. Usually there is no need to fill these properties because the text of the
query is generated automatically.
In special cases, you can set these properties to perform more complicated processing
during a query. These properties are automatically processed by PgDAC during the execution
of the Post, Delete, or RefreshRecord methods, and are used to construct the query to the
© 2018 Devart
31 PostgreSQL Data Access Components
server. Their values can contain parameters with names of fields in the underlying data
source, which will be later replaced by appropriate data values.
For example, you can use the SQLInsert template to insert a row into a query instance as
follows.
o Fill the SQLInsert property with the parameterized query template you want to use.
o Call Insert.
o Initialize field values of the row to insert.
o Call Post.
The value of the SQLInsert property will then be used by PgDAC to perform the last step.
Setting these properties is optional and allows you to automatically execute additional SQL
statements, add calls to stored procedures and functions, check input parameters, and/or
store comments during query execution. If these properties are not set, the PgDAC dataset
object will generate the query itself using the appropriate insert, update, delete, or refresh
record syntax.
o While executing a query, the screen cursor does not change to an hour-glass.
o Even if I have LoginPromp set to True, the connect dialog does not appear.
To fix this, you should add the PgDACVcl (for Windows) or PgDACClx (for Linux) unit to the
uses clause of your project.
General Questions
1. I would like to develop an application that works with PostgreSQL Server. Should I
use PgDAC or DbxMda?
DbxMda is our dbExpress driver for PostgreSQL. dbExpress technology serves for providing
a more or less uniform way to access different servers (SQL Server, PostgreSQL, Oracle
and so on). It is based on drivers that include server-specific features. Like any universal tool,
© 2018 Devart
General Information 32
in many specialized cases dbExpress providers lose some functionality. For example, the
dbExpress design-time is quite poor and cannot be expanded.
PgDAC is a specialized set of components for PostgreSQL, which has advanced server-
specific design-time and a component interface similar to that of BDE.
PgDAC and DbxMda use the same kernel and thus have similar performance. In some cases
dbExpress is slower because data undergoes additional conversion to correspond to
dbExpress standards.
Yes, PgDAC is thread-safe but there is a restriction. The same TPgConnection object cannot
be used in several threads. So if you have a multithreaded application, you should have a
TPgConnection object for each thread that uses PgDAC.
We always try to keep PgDAC compatible with previous versions, but sometimes we have to
change behaviour of PgDAC in order to enhance its functionality, or avoid bugs. If either of
changes is undesirable for your application, and you want to save the old behaviour, please
refer to the "Compatibility with previous versions" topic in PgDAC help. This topic describes
such changes, and how to revert to the old PgDAC behaviour.
4. When editing a DataSet, I get an exception with the message 'Update failed. Found
%d records.' or 'Refresh failed. Found %d records.'
This error occurs when the database server is unable to determine which record to modify or
delete. In other words, there are either more than one record or no records that suit the
UPDATE criteria. Such situation can happen when you omit the unique field in a SELECT
statement (TCustomDADataSet.SQL) or when another user modifies the table
simultaneously. This exception can be suppressed. Refer to
TCustomPgDataSet.Options.StrictUpdate topic in PgDAC help for more information.
© 2018 Devart
33 PostgreSQL Data Access Components
5. I have problems using BIGINT and INT UNSIGNED fields as key fields in master/
detail relationships, and accessing values of such fields through the Field.Value
property.
Fields of this type are represented in Delphi by TLargeIntField objects. In some versions of
Delphi, you cannot access these fields through the Value property (for more information see
the SetVarValue protected method of TLargeintField in the DB unit). To avoid this problem,
you can change the field type to INT, which is usually sufficient for key fields. Alternatively, you
can avoid using Value.
For master/detail relationships the problem can be avoided only by changing type of the key
field to INT, as Delphi's master/detail mechanism works through Field.Value.
First of all, you should find out what causes the problem. The list of most frequent reasons for
this error to occur is below.
o Client side: The value of TPgConnection.ConnectionTimeout or
TCustomPgDataSet.CommandTimeout is too small. To check this hypothesis, try
setting TCustomPgDataSet.CommandTimeout to 0 (infinitive) and
TPgConnection.ConnectionTimeout to 300.
o Server side: PostgreSQL server has closed the connection. Almost always it is because
the value of wait_timeout variable is too small. Try increasing it. If this solution is not
possible (for example, because you don't have enough rights), you should invoke
PgConnection.Ping with an interval less than wait_timeout. Use TTimer in
TPgConnection thread to accomplish this task.
o Unstable connection (GPRS etc). In case of unstable connection you can adapt PgDAC
to work in such conditions by changing some of its settings. For more information please
see the "Working in Unstable Networks" article in the PgDAC help documentation.
If the connection is lost, PgDAC tries to reconnect to server. However, your last command will
probably not be executed, and you should repeat it again. PgDAC does not try to reconnect if
a transaction has started or if at least one of statements is prepared.
© 2018 Devart
General Information 34
Usage of FetchAll=False mode has many advantages; however, it also has some restrictions
since it requires an additional connection to server for data fetching to be created. The
additional connection is created to prevent the main connection from blocking.
These problems can be avoided by setting the FetchAll property. Please see description of
the FetchAll propery and the CreateConnection option in PgDAC help for more information.
8. I get an error when opening a Stored Procedure that returns a result set.
Probably this is a bug of the PostgreSQL Server protocol with prepared stored procedures
that return record sets. It occurs in the following cases:
o After a call to the Prepare method of PgStoredProc, if the latter had already prepared and
opened. The following piece of code demonstrates the problem:
PgStoredProc.Prepare;
PgStoredProc.Open;
PgStoredProc.UnPrepare;
PgStoredProc.Prepare;
o After a call to the PgStoredProc.Execute method, if the stored procedure returns more
than one record set.
3 Getting Started
This page contains a quick introduction to setting up and using the PostgreSQL Data Access
Components library. It gives a walkthrough for each part of the PgDAC usage process and
points out the most relevant related topics in the documentation.
What is PgDAC?
Installing PgDAC.
Working with the PgDAC demo projects.
Compiling and deploying your PgDAC project.
Using the PgDAC documentation.
How to get help with PgDAC.
What is PgDAC?
PostgreSQL Data Access Components (PgDAC) is a component library which provides
direct connectivity to PostgreSQL for Delphi, C++Builder and Lazarus (FPC), and helps you
develop fast PostgreSQL-based database applications with these environments.
© 2018 Devart
35 PostgreSQL Data Access Components
Many PgDAC classes are based on VCL, LCL and FMX classes and interfaces. PgDAC is a
replacement for the Borland Database Engine, it provides native database connectivity, and is
specifically designed as an interface to the PostgreSQL database.
An introduction to PgDAC is provided in the Overview section.
A list of the PgDAC features you may find useful is listed in the Features section.
An overview of the PgDAC component classes is provided in the Components List section.
Installing PgDAC
To install PgDAC, complete the following steps.
1. Choose and download the version of the PgDAC installation program that is compatible
with your IDE. For instance, if you are installing PgDAC 1.00, you should use the following
files:
For BDS 2006 and Turbo - pgdac100d10*.exe
For Delphi 7 - pgdac1100d7*.exe
By default, the PgDAC installation program should install compiled PgDAC libraries
automatically on all IDEs.
To check if PgDAC has been installed properly, launch your IDE and make sure that the
PgDAC page has been added to the Component palette and that a PgDAC menu was added
to the Menu bar.
If you have bought PgDAC Professional Edition with Source Code with Source Code, you will
be able to download both the compiled version of PgDAC and the PgDAC source code. The
installation process for the compiled version is standard, as described above.The PgDAC
source code must be compiled and installed manually. Consult the supplied ReadmeSrc.html
file for more details.
To find out what gets installed with PgDAC or to troubleshoot your PgDAC installation, visit
the Installation topic.
© 2018 Devart
Getting Started 36
project, PgDacDemo, from your IDE. This demo project is a collection of demos that show
how PgDAC can be used. The project creates a form which contains an explorer panel for
browsing the included demos and a view panel for launching and viewing the selected demo.
PgDACDemo Walkthrough
1. Launch your IDE.
2. Choose File | Open Project from the menu bar
3. Find the PgDAC directory and open the PgDacDemo project. This project should be
located in the Demos\PgDacDemo folder.
For example, if you are using Borland Developer Studio 2006, the demo project may be found at
4. Select Run | Run or press F9 to compile and launch the demo project. PgDacDemo should
start, and a full-screen PgDAC Demo window with a toolbar, an explorer panel, and a view
panel will open. The explorer panel will contain the list of all demo sub-projects included in
PgDACDemo, and the view panel will contain an overview of each included demo.
At this point, you will be able to browse through the available demos, read their descriptions,
view their source code, and see the functionality provided by each demo for interacting with
PostgreSQL. However, you will not be able to actually retrieve data from PostgreSQL or execute
commands until you connect to the database.
5. Click on the "Connect" button on the PgDacDemo toolbar. A Connect dialog box will open.
Enter the connection parameters you use to connect to your PostgreSQL server and click
"Connect" in the dialog box.
Now you have a fully functional interface to your PostgreSQL server. You will be able to go
through the different demos, to browse tables, create and drop objects, and execute SQL
commands.
Warning! All changes you make to the database you are connected to, including creating
and dropping objects used by the demo, will be permanent. Make sure you specify a test
database in the connection step.
6. Click on the "Create" button to create all objects that will be used by PgDacDemo. If some
of these objects already exist in the database you have connected to, the following error
message will appear.
An error has occurred:
#42S01Table 'dept' already exists
You can manually create objects required for demo by using the following file: %PgDAC%
© 2018 Devart
37 PostgreSQL Data Access Components
\Demos\InstallDemoObjects.sql
%PgDAC% is the PgDAC installation path on your computer.
Ignore this exception?
This is a standard warning from the object execution script. Click "Yes to All" to ignore this
message. PgDacDemo will create the PgDacDemo objects on the server you have connected
to.
7. Choose a demo that demonstrates an aspect of working with PostgreSQL that you are
interested in, and play with the demo frame in the view window on the right. For example, to
find out more about how to work with PostgreSQL tables, select the Table demo from the
"Working with Components" folder. A simple PostgreSQL table browser will open in the
view panel which will let you open a table in your database by specifying its name and
clicking on the Open button.
8. Click on the "Demo source" button in the PgDacDemo toolbar to find out how the demo you
selected was implemented. The source code behind the demo project will appear in the
view panel. Try to find the places where PgDAC components are used to connect to the
database.
9. Click on the "Form as text" button in the PgDacDemo toolbar to view the code behind the
interface to the demo. Try to find the places where PgDAC components are created on the
demo form.
10.Repeat these steps for other demos listed in the explorer window. The available demos
are organized in three folders.
Working with components
A collection of projects that show how to work with basic PgDAC components.
General demos
A collection of projects that show off the PgDAC technology and demonstrate some ways of
working with data.
PostgreSQL-specific demos
A collection of projects that demonstrate how to incorporate PostgreSQL features in
database applications.
11.When you are finished working with the project, click on the "Drop" button in the
PgDacDemo toolbar to remove all schema objects added in Step 6.
© 2018 Devart
Getting Started 38
If you are evaluating deploying projects with PgDAC Trial Edition, you will also need to deploy
some additional bpl files with your application even if you are compiling without runtime
packages. As another trial limitation for C++Builder, applications written with PgDAC Trial
Edition for C++Builder will only work if the C++Builder IDE is launched. More information
about PgDAC Trial Edition limitations is provided here.
A list of the files which may need to be deployed with PgDAC-based applications is included
in the Deployment topic.
© 2018 Devart
39 PostgreSQL Data Access Components
3.1 Installation
This topic contains the environment changes made by the PgDAC installer. If you are having
problems using PgDAC or compiling PgDAC-based products, check this list to make sure
your system is properly configured.
Compiled versions of PgDAC are installed automatically by PgDAC Installer for all supported
IDEs except for Lazarus. Version of PgDAC with Source Code must be installed manually.
Installation of PgDAC from sources is described in the supplied ReadmeSrc.html file.
Note: You can avoid performing PgDAC uninstallation manually when upgrading to a new
version by directing the PgDAC installation program to overwrite previous versions. To do
© 2018 Devart
Getting Started 40
this, execute the installation program from the command line with a / f or ce parameter
(Start | Run and type pgdacXX. exe / f or ce, specifying the full path to the appropriate
version of the installation program) .
Installed packages
Note: %PgDAC%denotes the path to your PgDAC installation directory.
Environment Changes
To compile PgDAC-based applications, your environment must be configured to have access
to the PgDAC libraries. Environment changes are IDE-dependent.
For all instructions, replace %PgDAC%with the path to your PgDAC installation directory
Delphi
%PgDAC%\ Li b should be included in the Library Path accessible from Tools | Enviroment
options | Library.
© 2018 Devart
41 PostgreSQL Data Access Components
The PgDAC Installer performs Delphi environment changes automatically for compiled
versions of PgDAC.
C++Builder
C++Builder 6:
$( BCB) \ PgDAC\ Li b should be included in the Library Path of the Default Project Options
accessible from Project | Options | Directories/Conditionals.
$( BCB) \ PgDAC\ I ncl ude should be included in the Include Path of the Default Project
Options accessible from Project | Options | Directories/Conditionals.
The PgDAC Installer performs C++Builder environment changes automatically for compiled
versions of PgDAC.
Lazarus
The PgDAC installation program only copies PgDAC files. You need to install PgDAC
packages to the Lazarus IDE manually. Open %PgDAC%\Source\Lazarus1\dclpgdac10.lpk
(for Trial version %PgDAC%\Packages\dclpgdac10.lpk) file in Lazarus and press the Install
button. After that Lazarus IDE will be rebuilded with PgDAC packages.
Do not press the the Compile button for the package. Compiling will fail because there are no
PgDAC sources.
To check that your environment has been properly configured, try to compile one of the demo
projects included with PgDAC. The PgDAC demo projects are located in %PgDAC%/Demos.
DBMonitor
DBMonitor is an easy-to-use tool to provide visual monitoring of your database applications. It
is provided as an alternative to Borland SQL Monitor which is also supported by PgDAC.
DBMonitor is intended to hamper application being monitored as little as possible. For more
information, visit the DBMonitor page online.
© 2018 Devart
Getting Started 42
Requirements
In order to connect to PostgreSQL, you need the server itself running, PgDAC installed, and
IDE running. Also, you need to know the server name (if the server is run on the remote
computer), the port that the server listens to (if you use not the 5432 standard port), and the
database name.
General information
To establish connection to the server, you have to provide some connection parameters to
PgDAC. This information is used by the TPgConnection component to establish connection
to the server. The parameters are represented by the properties of the TPgConnection
component (Server, Port, Username, Password, Database, Schema).
Note: All these options can be specified at once using the ConnectString property.
Creating Connection
© 2018 Devart
43 PostgreSQL Data Access Components
2. Double-click on the component. Note that the new object appears on the form. If this is the
first time you create TPgConnection in this application, it is named PgConnection1.
After you have done these steps, you should set up the newly created PgConnection1
component. You can do as follows:
© 2018 Devart
Getting Started 44
con.Username := 'postgres';
con.Password := 'password';
con.Database := 'postgres';
con.Schema :='public';
con.LoginPrompt := False; // to prevent showing of the connection dialog
con.Open;
finally
con.Free;
end;
end;
Note: To run this code, you have to add the PgAccess unit to the USES clause of your unit.
[C++Builder]
{
TPgConnection* con = new TPgConnection(NULL);
try
{
con->Server = "localhost";
con->Port = 5432;
con->Username = "postgres";
con->Password = "password";
con->Database = "postgres";
con->Schema = "public";
con->LoginPrompt = False; // to prevent showing of the connection dialog
con->Open();
}
__finally
{
con->Free();
}
}
Note: To run this code, you have to include the PgAccess.hpp header file to your unit.
[Delphi]
var
con: TPgConnection;
begin
con := TPgConnection.Create(nil);
try
con.ConnectString := 'Data Source=localhost;Port=5432;Database=postgres;
con.LoginPrompt := False; // to prevent showing of the connection dialog
con.Open;
finally
con.Free;
end;
end;
© 2018 Devart
45 PostgreSQL Data Access Components
Note: To run this code, you have to add the PgAccess units to the USES clause of your unit.
[C++ Builder]
{
TPgConnection* con = new TPgConnection(NULL);
try
{
con->ConnectString = "Data Source=localhost;Port=5432;Database=postgres;
con->LoginPrompt = False; // to prevent showing of the connection dialog
con->Open();
}
__finally
{
con->Free();
}
}
Note: To run this code, you have to include the PgAccess.hpp header file to your unit.
Opening connection
As you can see above, opening a connection at run-time is as simple as calling of the Open
method:
[Delphi]
con.Open;
[C++ Builder]
con->Open();
Another way to open a connection at run-time is to set the Connected property to True:
[Delphi]
con.Connected := True;
[C++ Builder]
con->Connected = True;
This way can be used at design-time as well. Of course, PgConnection1 must have valid
connection options assigned earlier. When you call Open, PgDAC tries to find the host and
connect to the server. If any problem occurs, it raises an exception with brief explanation on
what is wrong. If no problem is encountered, PgDAC tries to establish connection. Finally,
when connection is established, the Open method returns and the Connected property is
changed to True.
Closing connection
© 2018 Devart
Getting Started 46
To close a connection, call its Close method, or set its Connected property to False:
[Delphi]
con.Close;
[C++ Builder]
con.Close();
or:
[Delphi]
con.Connected := False;
[C++ Builder]
con.Connected = False;
Modifying connection
You can modify connection by changing properties of the TPgConnection object. Keep in
mind that while some of the properties can be altered freely, most of them close connection
when the a value is assigned. For example, if you change Server property, it is closed
immediately, and you have to reopen it manually.
Additional information
PgDAC has a wide set of features you can take advantage of. The following list enumerates
some of them, so you can explore the advanced techniques to achieve better performance,
balance network load or enable additional capabilities:
Connection Pooling
Disconnected Mode
Data Type Mapping
Notice
See Also
TPgConnection
Server
Port
Database
Username
Password
Schema
LoginPrompt
© 2018 Devart
47 PostgreSQL Data Access Components
Requirements
In order to create database objects you have to connect to PostgreSQL. This process is
described in details in the tutorial "Connecting To PostgreSQL".
General information
Database objects are created using Data Definition Language (DDL), which is a part of SQL.
The DDL statements can be executed on server by an account that has the necessary
privileges. There are two ways to create database objects. You can build DDL statements
manually and execute them using a component like TPgSQL. Another way is to use visual
database tools like pgAdmin. This topic covers the first way - using components.
There are two ways to execute DDL statements in components like TPgSQL: in design-time
and in run-time. Both these ways are described below.
Note: The following assumes that you have the IDE running, you are currently focused on the
form designer, and you have already set up the TPgConnection component on the form.
Creating tables
To create tables, the TPgSQL component is used here.
Design-time creation
Open the Tool Palette and find the TPgSQL component in the PgDAC category.
Double-click on the component. Note that a new object appears on the form. If this is the
first time you create TPgSQL in this application, it is named PgSQL1. Note that the
© 2018 Devart
Getting Started 48
Run-time creation
Same operations performed in runtime look as follows:
[Delphi]
var
sql: TPgSQL;
begin
sql := TPgSQL.Create(nil);
try
sql.Connection := con; // con is TPgConnection already set up
sql.SQL.Clear;
sql.SQL.Add('CREATE TABLE dept (');
sql.SQL.Add(' deptno serial not null,');
sql.SQL.Add(' dname varchar(14),');
sql.SQL.Add(' loc varchar(13),');
sql.SQL.Add(' primary key (deptno)');
sql.SQL.Add(');');
sql.SQL.Add('CREATE TABLE emp (');
sql.SQL.Add(' empno serial not null,');
sql.SQL.Add(' ename varchar(10),');
sql.SQL.Add(' job varchar(9),');
sql.SQL.Add(' mgr integer,');
sql.SQL.Add(' hiredate timestamp,');
sql.SQL.Add(' sal real,');
sql.SQL.Add(' comm real,');
© 2018 Devart
49 PostgreSQL Data Access Components
Design-time creation
Open the Tool Palette and find the TPgScript component in the PgDAC category.
Double-click on the component. Note that a new object appears on the form. If this is the
first time you create TPgScript in this application, it is named PgScript1. Note that the
PgScript1.Connection property is already set to existent (on the form) connection.
Double-click on the PgScript1 object.
© 2018 Devart
Getting Started 50
Run-time creation
The same operations performed in runtime look as follows:
[Delphi]
var
script: TPgScript;
begin
script := TPgScript.Create(nil);
try
script.Connection := con; // con is TPgConnection already set up
script.SQL.Clear;
script.SQL.Add('CREATE FUNCTION "Ten Most High-Paid Employees"()');
script.SQL.Add('RETURNS SETOF Emp AS $$');
script.SQL.Add(' SELECT * FROM emp ORDER BY emp.sal DESC LIMIT 10');
script.SQL.Add('$$ LANGUAGE ''sql'';');
script.SQL.Add('');
script.SQL.Add('CREATE FUNCTION "GetEmpNumberInDept"(');
script.SQL.Add(' IN pdeptno integer,');
script.SQL.Add(' OUT pempnumb integer)');
script.SQL.Add('RETURNS integer AS');
script.SQL.Add('$BODY$');
script.SQL.Add('BEGIN');
script.SQL.Add(' pempnumb := (SELECT count(*) FROM emp WHERE deptno = p
script.SQL.Add('END;');
script.SQL.Add('$BODY$');
script.SQL.Add(' LANGUAGE plpgsql VOLATILE');
script.Execute;
finally
script.Free;
end;
end;
© 2018 Devart
51 PostgreSQL Data Access Components
Note: To run this code, you have to add the PgScript unit to the USES clause of your unit.
[C++Builder]
{
TPgSQL* sql = new TPgSQL(NULL);
try
{
sql->Connection = con; // con is TPgConnection already set up
sql->SQL->Clear();
sql->SQL->Add("CREATE TABLE dept (");
sql->SQL->Add(" deptno serial not null,");
sql->SQL->Add(" dname varchar(14),");
sql->SQL->Add(" loc varchar(13),");
sql->SQL->Add(" primary key (deptno)");
sql->SQL->Add(");");
sql->SQL->Add("CREATE TABLE emp (");
sql->SQL->Add(" empno serial not null,");
sql->SQL->Add(" ename varchar(10),");
sql->SQL->Add(" job varchar(9),");
sql->SQL->Add(" mgr integer,");
sql->SQL->Add(" hiredate timestamp,");
sql->SQL->Add(" sal real,");
sql->SQL->Add(" comm real,");
sql->SQL->Add(" deptno int references dept,");
sql->SQL->Add(" primary key (empno)");
sql->SQL->Add(");");
sql->Execute();
}
__finally
{
sql->Free();
}
}
Note: To run this code, you have to include the PgScript.hpp header file to your unit.
Additional information
Actually, there are lots of ways to create database objects on server. Any tool or component
that is capable of running an SQL query, can be used to manage database objects. For
example, TPgSQL suits fine for creating objects one by one, while TPgScript is designed for
executing series of DDL/DML statements. For information on DDL statements syntax refer to
the PostgreSQL documentation.
© 2018 Devart
Getting Started 52
1. Requirements
2. General information
3. Using DataSet Functionality
4. Building DML Statements Manually
o 4.1 DML Statements With Parameters
o 4.2 DML Statements As Plain Text
5. Additional Information
Requirements
This walkthrough supposes that you know how to connect to server (tutorial "Connecting To
PostgreSQL", how to create necessary objects on the server (tutorial "Creating Database
Objects"), and how to insert data to created tables (tutorial "Inserting Data Into Tables").
General information
Data on server can be deleted using Data Manipulation Language (DML), which is a part of
SQL. DML statements can be executed on server by an account that has necessary
privileges. There are two ways to manipulate a database. You can build DML statements
manually and run them within some component like TPgQuery. Another way is to use the
dataset functionality (the Delete method) of the TPgQuery and TPgTable components. We
will discuss both ways. The goal of this tutorial is to delete a record in the table dept.
© 2018 Devart
53 PostgreSQL Data Access Components
[C++Builder]
{
TPgQuery* q = new TPgQuery(NULL);
try
{
// con is either TPgConnection already set up
q->Connection = con;
// retrieve data
q->SQL->Text = "SELECT * FROM dept";
q->Open();
// delete the current record
q->Delete();
}
__finally
{
q->Free();
}
}
© 2018 Devart
Getting Started 54
q->Connection = con;
// set SQL query for delete record
q->SQL->Clear();
q->SQL->Add("DELETE FROM dept WHERE deptno = :deptno;");
// set parameters
q->ParamByName("deptno")->AsInteger = 10;
// execute query
q->Execute();
}
__finally
{
q->Free();
}
}
© 2018 Devart
55 PostgreSQL Data Access Components
Additional Information
It is also possible to use stored procedures for deleting data. In this case, all data
manipulation logic is defined on the server.
Requirements
This walkthrough supposes that you know how to connect to server (tutorial "Connecting To
PostgreSQL") and that necessary objects are already created on the server (tutorial "Creating
Database Objects").
General information
Data on server can be inserted using Data Manipulation Language (DML), which is a part of
SQL. DML statements can be executed on server by an account that has necessary
privileges. There are two ways to manipulate a database. You can build DML statements
manually and run them within some component like TPgQuery. Another way is to use the
dataset functionality (the Insert, Append, and Post methods) of the TPgQuery and TPgTable
components. We will discuss both ways.
The goal of this tutorial is to insert the following data into tables dept and emp:
Table dept
© 2018 Devart
Getting Started 56
Table emp
Design time
Open the Tool palette and find the TPgQuery component in the PgDAC category.
Double-click on the component. Note that a new object appears on the form. If this is the
first time you create TPgQuery in this application, it is named PgQuery1. Note that the
PgQuery1.Connection property is already set to an existent (on the form) connection.
Double-click on the PgQuery1 object.
Type the following lines:
© 2018 Devart
57 PostgreSQL Data Access Components
Run time
© 2018 Devart
Getting Started 58
q->Free();
}
}
© 2018 Devart
59 PostgreSQL Data Access Components
q: TPgQuery;
begin
q := TPgQuery.Create(nil);
try
q.Connection := con; // con is TPgConnection already set up
q.SQL.Clear;
q.SQL.Add('INSERT INTO dept(deptno, dname, loc) VALUES (10,''ACCOUNTING'
q.Execute;
finally
q.Free;
end;
end;
[C++Builder]
{
TPgQuery* q = new TPgQuery(NULL);
try
{
q->Connection = con; // con is TPgConnection already set up
q->SQL->Clear();
q->SQL->Add("INSERT INTO dept(deptno, dname, loc) VALUES (10,'ACCOUNTING
q->Execute();
}
__finally
{
q->Free();
}
}
Additional Information
Actually, there are lots of ways to insert data into tables. Any tool or component capable of
running a SQL query can be used to manage data. Some components are better for
performing certain tasks. For example, TPgLoader is the fastest way to insert data, TPgScript
is designed for executing series of statements one by one.
It is also possible to use stored procedures for inserting data. In this case, all data
manipulation logic is defined on the server. You can find more about using stored procedures
in the tutorial "Stored Procedures".
Requirements
© 2018 Devart
Getting Started 60
This walkthrough supposes that you know how to connect to server (tutorial "Connecting To
SQL Server"), how to create necessary objects on the server (tutorial "Creating Database
Objects"), and how to insert data to created tables (tutorial "Inserting Data Into Tables").
General information
As we know, an original function of any database application is establishing connection to a
data source and working with data contained in it. PgDAC provides several components that
can be used for data retrieving, such as TPgQuery and TPgTable. We will discuss data
retrieving using these components.
The goal of this tutorial is to retrieve data from a table dept.
TPgQuery
The following code demonstrates retrieving of data from the dept table using the TPgQuery
component:
[Delphi]
var
q: TPgQuery;
begin
q := TPgQuery.Create(nil);
try
// con is TPgConnection already set up
q.Connection := con;
// retrieve data
q.SQL.Text := 'SELECT * FROM dept';
q.Open;
// shows the number of records obtained from the server
ShowMessage(IntToStr(q.RecordCount));
finally
q.Free;
end;
end;
[C++Builder]
{
TPgQuery* q = new TPgQuery(NULL);
try
{
// con is TPgConnection already set up
q->Connection = con;
// retrieve data
q->SQL->Text = "SELECT * FROM dept";
q->Open();
// shows the number of records obtained from the server
ShowMessage(IntToStr(q->RecordCount));
}
__finally
{
© 2018 Devart
61 PostgreSQL Data Access Components
q->Free();
}
}
TPgTable
The following code demonstrates retrieving of data from the dept table using the TPgTable
component:
[Delphi]
var
tbl: TPgTable;
begin
tbl := TPgTable.Create(nil);
try
// con is TPgConnection already set up
tbl.Connection := con;
// retrieve data
tbl.TableName := 'dept';
tbl.Open;
// shows the number of records obtained from the server
ShowMessage(IntToStr(tbl.RecordCount));
finally
tbl.Free;
end;
end;
[C++Builder]
{
TPgTable* tbl = new TPgTable(NULL);
try
{
// con is TPgConnection already set up
tbl->Connection = con;
// retrieve data
tbl->TableName = "dept";
tbl->Open();
// shows the number of records obtained from the server
ShowMessage(IntToStr(tbl->RecordCount));
}
__finally
{
tbl->Free();
}
}
Additional Information
It is also possible to use stored procedures for data retrieving. In this case, all data
manipulation logic is defined on the server.
© 2018 Devart
Getting Started 62
Requirements
This walkthrough supposes that you know how to connect to server (tutorial "Connecting To
PostgreSQL"), how to create necessary objects on the server (tutorial "Creating Database
Objects"), and how to insert data to created tables (tutorial "Inserting Data Into Tables").
General information
Data on server can be modified using Data Manipulation Language (DML), which is a part of
SQL. DML statements can be executed on server by an account that has necessary
privileges. There are two ways to manipulate a database. You can build DML statements
manually and run them within some component like TPgQuery. Another way is to use the
dataset functionality (the Edit and Post methods) of the TPgQuery and TPgTable
components. We will discuss both ways. The goal of this tutorial is to modify the following
record of the table dept:
10 ACCOUNTING NEW YORK
to make it look as follows:
10 RESEARCH LOS ANGELES
© 2018 Devart
63 PostgreSQL Data Access Components
© 2018 Devart
Getting Started 64
try
// con is TPgConnection already set up
q.Connection := con;
// set SQL query for update record
q.SQL.Clear;
q.SQL.Add('UPDATE dept SET dname = :dname, loc = :loc WHERE deptno = :de
// set parameters
q.ParamByName('deptno').AsInteger := 10;
q.ParamByName('dname').AsString := 'RESEARCH';
q.ParamByName('loc').AsString := 'LOS ANGELES';
// execute query
q.Execute;
finally
q.Free;
end;
end;
[C++Builder]
{
TPgQuery* q = new TPgQuery(NULL);
try
{
// con is TPgConnection already set up
q->Connection = con;
// set SQL query for update record
q->SQL->Clear();
q->SQL->Add("UPDATE dept SET dname = :dname, loc = :loc WHERE deptno = :
// set parameters
q->ParamByName("deptno")->AsInteger = 10;
q->ParamByName("dname")->AsString = "RESEARCH";
q->ParamByName("loc")->AsString = "LOS ANGELES";
// execute query
q->Execute();
}
__finally
{
q->Free();
}
}
© 2018 Devart
65 PostgreSQL Data Access Components
finally
q.Free;
end;
end;
[C++Builder]
{
TPgQuery* q = new TPgQuery(NULL);
try
{
// con is TPgConnection already set up
q->Connection = con;
// set SQL query for update record
q->SQL->Clear();
q->SQL->Add("UPDATE dept SET dname = 'RESEARCH', loc = 'LOS ANGELES' WHE
// execute query
q->Execute();
}
__finally
{
q->Free();
}
}
Additional Information
It is also possible to use stored procedures for modifying data. In this case, all data
manipulation logic is defined on the server.
© 2018 Devart
Getting Started 66
The structure of the demo project directory depends on the IDE version you are using.
For most new IDEs the structure will be as follows.
Demos
|—PgDacDemo [The main PgDAC demo project]
|—TechnologySpecific
| |— SecureBridge [A component and a demo for integration with
the SecureBridge library]
|—ThirdParty
| |— [A collection of demo projects on integration with third-
party components]
|—Miscellaneous
|— [Some other demo projects on design technologies]
PgDacDemo is the main demo project that shows off all the PgDAC functionality. The other
directories contain a number of supplementary demo projects that describe special use
cases. A list of all the samples in the PgDAC demo project and a description for the
supplementary projects is provided in the following section.
Note: This documentation describes ALL the PgDAC demo projects. The actual demo
projects you will have installed on your computer depends on your PgDAC version, PgDAC
edition, and the IDE version you are using. The integration demos may require installation of
third-party components to compile and work properly.
The included sample applications are fully functional. To use the demos, you have to first set
up a connection to PostgreSQL. You can do so by clicking on the "Connect" button.
Many demos may also use some database objects. If so, they will have two object
manipulation buttons, "Create" and "Drop". If your demo requires additional objects, click
"Create" to create the necessary database objects. When you are done with a demo, click
"Drop" to remove all the objects used for the demo from your database.
© 2018 Devart
67 PostgreSQL Data Access Components
Note: The PgDAC demo directory includes two sample SQL scripts for creating and dropping
all the test schema objects used in the PgDAC demos. You can modify and execute this
script manually, if you would like. This will not change the behavior of the demos.
You can find a complete walkthrough for the main PgDAC demo project in the Getting Started
topic. The other PgDAC demo projects include a ReadMe.txt file with individual building and
launching instructions.
© 2018 Devart
Getting Started 68
General Demos
Name Description
Demonstrates how to perform the most important tasks of working
CachedUpdate with data in CachedUpdates mode, including highlighting
s uncommitted changes, managing transactions, and committing
changes in a batch.
Demonstrates PgDAC's local storage functionality. This sample
FilterAndIndex shows how to perform local filtering, sorting and locating by multiple
fields, including by calculated and lookup fields.
Uses PgDAC functionality to work with master/detail relationships.
MasterDetail This sample shows how to use local master/detail functionality.
Demonstrates different kinds of master/detail linking, including linking
by SQL, by simple fields, and by calculated fields.
© 2018 Devart
69 PostgreSQL Data Access Components
PostgreSQL-specific Demos
Name Description
Uses PgDAC functionality to work with graphics. The sample
Pictures demonstrates how to retrieve binary data from PgSQL server
database and display it on visual components. Sample also shows
how to load and save pictures to files and to the database.
Uses PgDAC functionality to work with text. The sample demonstrates
Text how to retrieve text data from SQL Server database and display it on
visual components. Sample also shows how to load and save text to
files and to the database.
© 2018 Devart
Getting Started 70
3.9 Deployment
PgDAC applications can be built and deployed with or without run-time libraries. Using run-
time libraries is managed with the "Build with runtime packages" check box in the Project
Options dialog box.
dacXX.bpl always
pgdacXX.bpl always
© 2018 Devart
71 PostgreSQL Data Access Components
and their dependencies (required IDE BPL files) with your application, even if it is built without
run-time packages:
rtlXX.bpl always
dbrtlXX.bpl always
vcldbXXX.bpl always
dacXX.bpl always
pgdacXX.bpl always
dacvclXX.bpl if your application uses the PgDacVcl unit
pgdacvclXX.bpl if your application uses the PgDacVcl unit
crcontrolsXX.bpl if your application uses the CRDBGrid component
4 Using PgDAC
This section describes basics of using PostgreSQL Data Access Components
Updating Data with PgDAC Dataset Components
Master/Detail Relationships
Automatic Key Field Value Generation
Data Type Mapping
Data Encryption
Working in an Unstable Network
Secure Connections
Disconnected Mode
Increasing Performance
Macros
DataSet Manager
TPgLoader Component
Large Objects
REFCURSOR Data Type
© 2018 Devart
Using PgDAC 72
See Also
TPgQuery
TPgStoredProc
TPgTable
TPgUpdateSQL
© 2018 Devart
73 PostgreSQL Data Access Components
© 2018 Devart
Using PgDAC 74
MasterSource: TDataSource;
begin
// create master dataset
Master := TPgQuery.Create(Self);
Master.SQL.Text := 'SELECT * FROM Department';
// create detail dataset
Detail := TPgQuery.Create(Self);
Detail.SQL.Text := 'SELECT * FROM Employee';
// setup MD
Detail.MasterFields := 'Dept_No'; // primary key in Department
Detail.DetailFields := 'DepLink'; // foreign key in Employee
// connect detail dataset with master via TDataSource component
MasterSource := TDataSource.Create(Self);
MasterSource.DataSet := Master;
Detail.MasterSource := MasterSource;
// open master dataset and only then detail dataset
Master.Open;
Detail.Open;
end;
In this code example MD relationship is set up using MasterFields and DetailFields properties.
Also note that there are no WHERE clause in detail dataset SQL.
To defer refreshing of detail dataset while master dataset navigation you can use DetailDelay
option.
Such MD relationship can be local and remote, depending on the
TCustomDADataSet.Options.LocalMasterDetail option. If this option is set to True, dataset
uses local filtering for establishing master-detail relationship and does not refer to the server.
Otherwise detail dataset performs query each time when record is selected in master
dataset. Using local MD relationship can reduce server calls number and save server
resources. It can be useful for slow connection. CachedUpdates mode can be used for detail
dataset only for local MD relationship. Using local MD relationship is not recommended when
detail table contains too many rows, because in remote MD relationship only records that
correspond to the current record in master dataset are fetched. So, this can decrease
network traffic in some cases.
See Also
TCustomDADataSet.Options
TMemDataSet.CachedUpdates
© 2018 Devart
75 PostgreSQL Data Access Components
See Also
KeySequence
Overview
Data Type Mapping is a flexible and easily customizable gear, which allows mapping
between DB types and Delphi field types.
In this article there are several examples, which can be used when working with all supported
DBs. In order to clearly display the universality of the Data Type Mapping gear, a separate DB
will be used for each example.
© 2018 Devart
Using PgDAC 76
correspondence between the DB data types and Delphi field types. In versions with Data
Type Mapping support the correspondence between the DB data types and Delphi field types
can be set manually.
Here is the example with the numeric type in the following table of a PostgreSQL database:
CREATE TABLE numeric_types
(
id integer NOT NULL,
value1 numeric(5,2),
value2 numeric(10,4),
value3 numeric(15,6),
CONSTRAINT pk_numeric_types PRIMARY KEY (id)
)
And Data Type Mapping should be used so that:
the numeric fields with Scale=0 in Delphi would be mapped to one of the field types:
TSmallintField, TIntegerField or TlargeintField, depending on Precision
to save precision, the numeric fields with Precision>=10 and Scalе<= 4 would be mapped
to TBCDField
and the numeric fields with Scalе>= 5 would be mapped to TFMTBCDField.
To specify that numeric fields with Precision <= 4 and Scale = 0 must be mapped to
ftSmallint, such a rule should be set:
var
DBType: Word;
MinPrecision: Integer;
MaxPrecision: Integer;
MinScale: Integer;
MaxScale: Integer;
FieldType: TfieldType;
begin
DBType := pgNumeric;
MinPrecision := 0;
MaxPrecision := 4;
MinScale := 0;
© 2018 Devart
77 PostgreSQL Data Access Components
MaxScale := 0;
FieldType := ftSmallint;
PgConnection.DataTypeMap.AddDBTypeRule(DBType, MinPrecision, MaxPrecision,
end;
This is an example of the detailed rule setting, and it is made for maximum
visualization.Usually, rules are set much shorter, e.g. as follows:
// clear existing rules
PgConnection.DataTypeMap.Clear;
// rule for numeric(4,0)
PgConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 0, 4, 0, 0, ftSma
// rule for numeric(10,0)
PgConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 5, 10, 0, 0, ftInt
// rule for numeric(15,0)
PgConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 11, rlAny, 0, 0, ftLar
// rule for numeric(5,2)
PgConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 0, 9, 1, rlAny, ftFlo
// rule for numeric(10,4)
PgConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 10, rlAny, 1, 4, ftBCD
// rule for numeric(15,6)
PgConnection.DataTypeMap.AddDBTypeRule(pgNumeric, 10, rlAny, 5, rlAny, ftFMT
Rules order
When setting rules, there can occur a situation when two or more rules that contradict to
each other are set for one type in the database. In this case, only one rule will be applied —
the one, which was set first.
PostgreSQL data type Default Delphi field type Destination field type
NUMBER(5,2) ftFloat ftFloat
NUMBER(10,4) ftFloat ftBCD
NUMBER(15,6) ftFloat ftFMTBCD
© 2018 Devart
Using PgDAC 78
When using Data Type Mapping, first matching rule is searched for each type, and it is used
for mapping. In the second example, the first set rule appears to be the first matching rule for
all three types, and therefore the ftFMTBCD type will be used for all fields in Delphi.
If to go back to the first example, the first matching rule for the NUMBER(5,2) type is the first
rule, for NUMBER(10,4) - the second rule, and for NUMBER(15,6) - the third rule. So in the
first example, the expected result was obtained.
So it should be remembered that if rules for Data Type Mapping are set so that two or more
rules that contradict to each other are set for one type in the database, the rules will be
applied in the specifed order.
© 2018 Devart
79 PostgreSQL Data Access Components
Data Type Mapping allows setting rules for the whole connection as well as for each DataSet
in the application.
The point is that the priority of the rules set for the DataSet is higher than the priority of the
rules set for the whole connection. This allows both flexible and convenient setting of Data
Type Mapping for the whole application. There is no need to set the same rules for each
DataSet, all the general rules can be set once for the whole connection. And if a DataSet with
an individual Data Type Mapping is necessary, individual rules can be set for it.
© 2018 Devart
Using PgDAC 80
For example:
But when setting rules for Data Type Mapping, there is a possibility to ignore data conversion
errors:
© 2018 Devart
81 PostgreSQL Data Access Components
Destination field
Database value Result Result description
type
0 will be returned if
'text value' ftInteger 0 the text cannot be
converted to number
32767 is the max
value that can be
1000000 ftSmallint 32767
assigned to the
Smallint data type
15,1 was truncated to
15,1 ftInteger 15
an integer value
Therefore ignoring of conversion errors should be used only if the conversion results are
expected.
© 2018 Devart
Using PgDAC 82
GUID, which is necessary for specifying that the value in the record is encrypted and it must
be decrypted when reading data. This allows you to avoid confusion and keep in the same
column both the encrypted and decrypted data, which is particularly important when using an
existing table. Also, when doing in this way, a random initializing vector is generated before
the data encryption, which is used for encryption. This allows you to receive different results
for the same initial data, which significantly increases security.
The most preferable way is to store the hash data along with the GUID and encrypted
information to determine the validity of the data and verify its integrity. In this way, if there was
an attempt to falsify the data at any stage of the transmission or data storage, when
decrypting the data, there will be a corresponding error generated. For calculating the hash
the SHA1 or MD5 algorithms can be used (the HashAlgorithm property).
The disadvantage of the latter two methods - additional memory is required for storage of the
auxiliary information.
As the encryption algorithms work with a certain size of the buffer, and when storing the
additional information it is necessary to use additional memory, TCREncryptor supports
encryption of string or binary fields only (ftString, ftWideString, ftBytes, ftVarBytes, ftBlob,
ftMemo, ftWideMemo). If encryption of string fields is used, firstly, the data is encrypted, and
then the obtained binary data is converted into hexadecimal format. In this case, data storage
requires two times more space (one byte = 2 characters in hexadecimal).
Therefore, to have the possibility to encrypt other data types (such as date, number, etc.), it is
necessary to create a field of the binary or BLOB type in the table, and then convert it into the
desired type on the client side with the help of data mapping.
It should be noted that the search and sorting by encrypted fields become impossible on the
server side. Data search for these fields can be performed only on the client after decryption
of data using the Locate and LocateEx methods. Sorting is performed by setting the
TMemDataSet.IndexFieldNames property.
Example.
Let's say there is an employee list of an enterprise stored in the table with the following data:
full name, date of employment, salary, and photo. We want all these data to be stored in the
encrypted form. Write a script for creating the table:
CREATE TABLE emp (
empno integer,
ename character(2000),
hiredate character(200),
sal character(200),
foto bytea,
CONSTRAINT pk_emp PRIMARY KEY (empno)
);
As we can see, the fields for storage of the textual information, date, and floating-point
number are created with the VARBINARY type. This is for the ability to store encrypted
© 2018 Devart
83 PostgreSQL Data Access Components
information, and in the case of the text field - to improve performance. Write the code to
process this information on the client.
PgQuery.SQL.Text := 'SELECT * FROM emp';
PgQuery.Encryption.Encryptor := PgEncryptor;
PgQuery.Encryption.Fields := 'ename, hiredate, sal, foto';
PgEncryptor.Password := '11111';
PgQuery.DataTypeMap.AddFieldNameRule ('ename', ftString);
PgQuery.DataTypeMap.AddFieldNameRule ('hiredate', ftDateTime);
PgQuery.DataTypeMap.AddFieldNameRule ('sal', ftFloat);
PgQuery.Open;
If the user does not refuse suggested RetryMode parameter value (or does not use the
OnConnectionLost event handler), PgDAC can implicitly perform the following operations:
Connect;
© 2018 Devart
Using PgDAC 84
DataSet.ApplyUpdates;
DataSet.Open;
I.e. when the connection breaks, implicit reconnect is performed and the corresponding
operation is reexecuted. We recommend to wrap other operations in transactions and fulfill
their reexecuting yourself.
The using of Pooling in Disconnected Mode allows to speed up most of the operations
because of connecting duration reducing.
See Also
FailOver demo
Working with Disconnected Mode
TCustomDAConnection.Options
TCustomDAConnection.Pooling
© 2018 Devart
85 PostgreSQL Data Access Components
Note: For using SSL protocol ssleay32.dll and libeay32.dll files are needed.
The detailed description of SSL connection you can find in PostgreSQL Documentation:
Server settings: "Secure TCP/IP Connections with SSL"
Client settings: "SSL Support"
© 2018 Devart
Using PgDAC 86
setup TScSSHClient (assign host name, SSH server port, user name, password) to
connect to the SSH server and check the connection;
place the TCRSSHIOHandler component onto your form. This component is included into
PgDAC as a demo project;
place the TPgConnection component onto your form, and link to its IOHandler property the
instance of TCRSSHIOHandler added on the previous step;
setup TPgConnection to connect to PostgreSQL server and check the connection.
Now you have an encrypted connection between PostgreSQL server and your application.
© 2018 Devart
87 PostgreSQL Data Access Components
If the query was prepared explicitly, connection does not close until the query is unprepared or
its SQL text is changed.
See Also
TCustomDAConnection.Options
FetchAll
Devart.PgDac.TPgQuery.LockMode
TCustomDAConnection.Pooling
TCustomDAConnection.Connect
TCustomDAConnection.Disonnect
Working in unstable network
© 2018 Devart
Using PgDAC 88
To insert records into the BATCH_TEST table, we use the following SQL query:
INSERT INTO BATCH_TEST VALUES (:ID, :F_INTEGER, :F_FLOAT, :F_STRING, :F_DAT
When a simple insertion operation is used, the query parameter values look as follows:
Parameters
:ID :F_INTEGER :F_FLOAT :F_STRING :F_DATE
1 100 2.5 ‘String Value 1' 01.09.2015
After the query execution, one record will be inserted into the BATCH_TEST table.
When using Batch operations, the query and its parameters remain unchanged. However,
parameter values will be enclosed in an array:
Parameters
:ID :F_INTEGER :F_FLOAT :F_STRING :F_DATE
1 100 2.5 ‘String Value 1' 01.09.2015
2 200 3.15 ‘String Value 2' 01.01.2000
3 300 5.08 ‘String Value 3' 09.09.2010
4 400 7.5343 ‘String Value 4' 10.10.2015
5 500 0.4555 ‘String Value 5' 01.09.2015
Now, 5 records are inserted into the table at a time on query execution.
How to implement a Batch operation in the code?
© 2018 Devart
89 PostgreSQL Data Access Components
PgQuery1.Params[4][i].AsDateTime := Now;
end;
// insert 1000 rows into the BATCH_TEST table
PgQuery1.Execute(1000);
end;
This command will insert 1000 rows to the table with one SQL query using the prepared array
of parameter values. The number of inserted rows is defined in the Iters parameter of the
Execute(Iters: integer; Offset: integer = 0) method. In addition, you can pass another
parameter – Offset (0 by default) – to the method. The Offset parameter points the array
element, which the Batch operation starts from.
We can insert 1000 records into the BATCH_TEST table in 2 ways.
All 1000 rows at a time:
PgQuery1.Execute(1000);
2×500 rows:
// insert first 500 rows
PgQuery1.Execute(500, 0);
// insert next 500 rows
PgQuery1.Execute(500, 500);
500 rows, then 300, and finally 200:
// insert 500 rows
PgQuery1.Execute(500, 0);
// insert next 300 rows starting from 500
PgQuery1.Execute(300, 500);
// insert next 200 rows starting from 800
PgQuery1.Execute(200, 800);
© 2018 Devart
Using PgDAC 90
PgQuery1.Params[3][i].AsDateTime := Now;
PgQuery1.Params[4][i].AsInteger := i + 1;
end;
// update 1000 rows in the BATCH_TEST table
PgQuery1.Execute(1000);
end;
Performance comparison
The example with BATCH_TEST table allows to analyze execution speed of normal
operations with a database and Batch operations:
25 000 records
Operation Type Standard Operation
Batch Operation (sec.)
(sec.)
Insert 346.7 1.69
Update 334.4 4.59
Delete 373.7 2.05
The less, the better.
It should be noted, that the retrieved results may differ when modifying the same table on
different database servers. This is due to the fact that operations execution speed may differ
depending on the settings of a particular server, its current workload, throughput, network
connection, etc.
© 2018 Devart
91 PostgreSQL Data Access Components
Connect
If your application performs Connect/Disconnect operations frequently, additional
performance can be gained using pooling mode (TCustomDAConnection.Pooling = True). It
reduces connection reopening time greatly (hundreds times). Such situation usually occurs in
web applications.
Execute
If your application executes the same query several times, you can use the
TCustomDADataSet.Prepare method or set the TDADataSetOptions.AutoPrepare property to
increase performance. For example, it can be enabled for Detail dataset in Master/Detail
relationship or for update objects in TDAUpdateSQL. The performance gain achieved this way
can be anywhere from several percent to several times, depending on the situation.
To execute SQL statements a TPgSQL component is more preferable than TPgQuery. It can
give several additional percents performance gain.
If the TCustomDADataSet.Options.StrictUpdate option is set to False, the RowsAffected
property is not calculated and becomes equal zero. This can improve performance of query
executing, so if you need to execute many data updating statements at once and you don't
mind affected rows count, set this option to False.
Fetch
In some situations you can increase performance a bit by using
TCustomDADataSet.Options.CompressBlobMode.
You can also tweak your application performance by using the following properties of
TCustomDADataSet descendants:
© 2018 Devart
Using PgDAC 92
FetchRows
Options.FlatBuffers
Options.LongStrings
UniDirectional
See the descriptions of these properties for more details and recommendations.
Navigate
The Locate function works faster when dataset is locally sorted on KeyFields fields. Local
dataset sorting can be set with the IndexFieldNames property. Performance gain can be large
if the dataset contains a large number of rows.
Lookup fields work faster when lookup dataset is locally sorted on lookup Keys.
Setting the TDADataSetOptions.CacheCalcFields property can improve performance when
locally sorting and locating on calculated and lookup fields. It can be also useful when
calculated field expressions contain complicated calculations.
Setting the TDADataSetOptions.LocalMasterDetail option can improve performance greatly
by avoiding server requests on detail refreshes. Setting the TDADataSetOptions.DetailDelay
option can be useful for avoiding detail refreshes when switching master DataSet records
frequently.
Update
If your application updates datasets in the CachedUpdates mode, then setting the
TCustomDADataSet.Options.UpdateBatchSize option to more than 1 can improve
performance several hundred times more by reducing the number of requests to the server.
You can also increase the data sending performance a bit (several percents) by using
Dataset.UpdateObject.ModifyObject, Dataset.UpdateObject, etc. Little additional performance
improvement can be reached by setting the AutoPrepare property for these objects.
Insert
If you are about to insert a large number of records into a table, you should use the
T:Devart.PgDac.TPgLoader component instead of Insert/Post methods, or execution of the
INSERT commands multiple times in a cycle. Sometimes usage of
T:Devart.PgDac.TPgLoader improves performance several times.
4.11 Macros
Macros help you to change SQL statements dynamically. They allow partial replacement of
the query statement by user-defined text. Macros are identified by their names which are then
© 2018 Devart
93 PostgreSQL Data Access Components
referred from SQL statement to replace their occurrences for associated values.
First step is to assign macros with their names and values to a dataset object.
Then modify SQL statement to include macro names into desired insertion points. Prefix
each name with & ("at") sign to let PgDAC discriminate them at parse time. Resolved SQL
statement will hold macro values instead of their names but at the right places of their
occurrences. For example, having the following statement with the TableName macro name:
SELECT * FROM &TableName
You may later assign any actual table name to the macro value property leaving your SQL
statement intact.
Query1.SQL.Text := 'SELECT * FROM &TableName';
Query1.MacroByName('TableName').Value := 'Dept';
Query1.Open;
PgDAC replaces all macro names with their values and sends SQL statement to the server
when SQL execution is requested.
Note that there is a difference between using TMacro AsString and Value properties. If you set
macro with the AsString property, it will be quoted. For example, the following statements will
result in the same result Query1.SQL property value.
Query1.MacroByName('StringMacro').Value := '''A string''';
Query1.MacroByName('StringMacro').AsString := 'A string';
Macros can be especially useful in scripts that perform similar operations on different objects.
You can use macros that will be replaced with an object name. It allows you to have the same
script text and to change only macro values.
You may also consider using macros to construct adaptable conditions in WHERE clauses of
your statements.
See Also
TMacro
TCustomDADataSet.MacroByName
TCustomDADataSet.Macros
© 2018 Devart
Using PgDAC 94
Customize the list of controls available for each data type in the DataSet Manager window.
Choose which control should be created when dragging an item onto a form in your
Windows application.
© 2018 Devart
95 PostgreSQL Data Access Components
DataSets from all forms in the project. To use this, click Extract DataSets from all forms in
project button. This settings is remembered. Note, that using this mode can slow down
opening of the large projects with plenty of forms and DataSets. Opening of such projects can
be very slow in Borland Delphi 2005 and Borland Developer Studio 2006 and can take up to
several tens of minutes.
DataSets can be grouped by form or connection. To change DataSet grouping click the
Grouping mode button or click a down. You can also change grouping mode by selecting
required mode from the DataSet Manager window popup menu.
© 2018 Devart
Using PgDAC 96
To use Details layout choose Details from the DataSet node drop-down control list in the
DataSet Manager window. Then select required controls in the drop-down control list for each
DataSet field. DataSet fields must be created. After setting required options you can drag the
DataSet to the form from the DataSet wizard. DataSet Manager will create TDataSource
component, and a component and a label for each field.
© 2018 Devart
97 PostgreSQL Data Access Components
The default configuration can easily be restored by pressing Reset button in the DataSet
Manager - Options dialog.
© 2018 Devart
Using PgDAC 98
manually, DataSet fields corresponding to data fields will not be generated automatically when
you drag the DataSet on the form, and you can not drag such fields on the form. To add all
available fields right-click the Fields node and select Add all fields from the popup menu.
To create new field right-click the Fields node and select New Field from the popup menu or
press <Ctrl+Insert>. The New Field dialog box will appear. Enter required values and press
OK button.
To delete fields select these fields in the DataSet Manager window and press <Delete>.
DataSet Manager allows you to change view of the fields displayed in the main window. Open
the Customize controls dialog, and jump to the Options page.
You can chose what information will be added to names of the Field and Data Field objects in
the main window of DataSet Manager. Below you can see the example.
© 2018 Devart
99 PostgreSQL Data Access Components
The COPY command has two modes: text and binary. TPgAlerter supports both these
modes. By default the binary mode is used for a connection with 3.0 protocol. In the binary
mode TPgLoader works a little faster but some data types are not supported in this mode. Set
the TextMode property to True to force text mode. In the text mode you can load data to
columns with any PostgreSQL data type.
Note: COPY stops operation at the first error. But the target table will already have received
earlier rows in a COPY FROM. These rows will not be visible or accessible, but they will still
occupy disk space. This might amount to a considerable amount of wasted disk space if the
failure happened well into a large copy operation. You may wish to invoke VACUUM to clean
the wasted space.
See Also
TPgLoader
TPgLoaderColumn
© 2018 Devart
Using PgDAC 100
LargeObject := TPgLargeObject.Create(PgConnection);
try
LargeObject.CreateObject;
LargeObject.Write(0, 10, &AData);
LargeObject.WriteBlob;
LargeObject.CloseObject;
finally
LargeObject.Free;
end;
PgConnection.Commit;
Reading an existent object:
...
LargeObject := TPgLargeObject.Create(PgConnection);
try
LargeObject.OID := 12345;
LargeObject.OpenObject;
LargeObject.Read(0, 10, &AData);
LargeObject.CloseObject;
finally
LargeObject.Free;
end;
...
Note that manipulations with large objects require a transaction. So StartTransaction is called
in the example.
By default TPgLargeObject instance uses a memory buffer to hold a value of large object. On
the first call to the Read method the TPgLargeObject reads the whole object value and stores
it in the buffer. You can also call the ReadBlob method to read a value to the buffer.
When you write data using the Write method, the data are stored in memory buffer. You
should call the WriteBlob method to pass the data to the database.
When working with very large objects, you can set the Cached property to False. In this case
the memory buffer is not used, and the Read and Write methods work directly with a value in
the database.
If you open a table with a column of the OID data type, TCustomPgDataSet descendant
components assume that values in this column are large objects OIDs, and automatically
read data from the corresponding large objects.
If OIDs are not large objects OIDs, set the OIDAsInt option of TCustomPgDataSet to True. In
this case OID columns are read as simple integer columns.
You can use the DefferedBlobRead and CacheBlobs options to optimize performance and
memory usage. If you set the DefferedBlobRead option to True, the dataset does not read
large object data when it fetches records. When you access a value of a large object field, the
data for the corresponding large object have been read.
If you set the CacheBlobs option to False, all large objects in the dataset do not cache their
values. In this case the DefferedBlobRead value has no sense.
© 2018 Devart
101 PostgreSQL Data Access Components
© 2018 Devart
Using PgDAC 102
PgConnection.StartTransaction;
PgStoredProc.StoredProcName := 'cursor_func';
PgStoredProc.Open;
repeat
while not PgStoredProc.Eof do begin
Value := PgStoredProc.Fields[0].AsInteger;
...
PgStoredProc.Next;
end;
until not PgStoredProc.OpenNext;
PgStoredProc.Close;
PgConnection.Commit;
You can open both cursors at the same time by assigning a TPgRefCursor instance to the
Cursor property of a dataset:
var
Cursor: TPgRefCursor;
PgQuery: TPgQuery;
...
PgConnection.StartTransaction;
PgStoredProc.StoredProcName := 'cursor_func';
PgStoredProc.Open;
Cursor := PgStoredProc.ParamByName('C2').AsCursor;
PgQuery.Cursor := Cursor;
PgQuery.Open; // open the second cursor
Value1 := PgStoredProc.Fields[0].AsInteger;
Value2 := PgQuery.Fields[0].AsInteger;
...
PgStoredProc.Close;
PgQuery.Close;
PgConnection.Commit;
© 2018 Devart
103 PostgreSQL Data Access Components
behaviour is suitable, for example, when creating a database of books in the library, when
next to the title of a book you should also store its title in the original language.
See Also
TPgConnection.Options
© 2018 Devart
Using PgDAC 104
intended to save resources when the count of connections in the pool exceeds the count that
is needed by application. If you set the PoolingOptions.MinPoolSize property to a non-zero
value, this prevents the pool from freeing all pooled connections. When connection count in
the pool decreases to MinPoolSize value, remaining connection will not be freed except if they
are broken.
The PoolingOptions.MaxPoolSize property limits the count of connections that can be active
at the same time. If maximum count of connections is active and some
TCustomDAConnection component tries to connect, it will have to wait until any of
TCustomDAConnection components disconnect. Maximum wait time is 30 seconds. If active
connections' count does not decrease during 30 seconds, the TCustomDAConnection
component will not connect and an exception will be raised.
You can limit the time of connection's existence by setting the
PoolingOptions.ConnectionLifeTime property. When the TCustomDAConnection component
disconnects, its internal connection will be freed instead of placing to the pool if this
connection is active during the time longer than the value of the
PoolingOptions.ConnectionLifeTime property. This property is designed to make load
balancing work with the connection pool.
To force freeing of a connection when the TCustomDAConnection component disconnects,
the RemoveFromPool method of TCustomDAConnection can be used. You can also free all
connection in the pool by using the class procedures Clear or AsyncClear of
TPgConnectionPoolManager. These procedures can be useful when you know that all
connections will be broken for some reason.
It is recommended to use connection pooling with the DisconnectMode option of the
TCustomDAConnection component set to True. In this case internal connections can be
shared between TCustomDAConnection components. When some operation is performed
on the TCustomDAConnection component (for example, an execution of SQL statement) this
component will connect using pooled connection and after performing operation it will
disconnect. When an operation is performed on another TCustomDAConnection component
it can use the same connection from the pool.
See Also
TCustomDAConnection.Pooling
TCustomDAConnection.PoolingOptions
Working with Disconnected Mode
4.18 DBMonitor
To extend monitoring capabilities of PgDAC applications there is an additional tool called
DBMonitor. It is provided as an alternative to Borland SQL Monitor which is also supported by
© 2018 Devart
105 PostgreSQL Data Access Components
PgDAC.
DBMonitor is an easy-to-use tool to provide visual monitoring of your database applications.
DBMonitor has the following features:
multiple client processes tracing;
SQL event filtering (by sender objects);
SQL parameter and error tracing.
DBAccess.BaseSQLOldBehavior:
The BaseSQL property is similar to the SQL property, but it does not store changes made by
AddWhere, DeleteWhere, and SetOrderBy methods. After assigning an SQL text and
modifying it by one of these methods, all subsequent changes of the SQL property will not be
reflected in the BaseSQL property. This behavior was changed in PgDAC . To restore old
© 2018 Devart
Using PgDAC 106
DBAccess.SQLGeneratorCompatibility:
If the manually assigned RefreshSQL property contains only "WHERE" clause, PgDAC uses
the value of the BaseSQL property to complete the refresh SQL statement. In this situation all
modifications applied to the SELECT query by functions AddWhere, DeleteWhere are not
taken into account. This behavior was changed in PgDAC . To restore the old behavior, set
the BaseSQLOldBehavior variable to True.
MemDS.SendDataSetChangeEventAfterOpen:
Starting with PgDAC , the DataSetChange event is sent after the dataset gets open. It was
necessary to fix a problem with disappeared vertical scrollbar in some types of DB-aware
grids. This problem appears only under Windows XP when visual styles are enabled.
To disable sending this event, change the value of this variable to False.
MemDS.DoNotRaiseExcetionOnUaFail:
Starting with PgDAC , if the OnUpdateRecord event handler sets the UpdateAction parameter
to uaFail, an exception is raised. The default value of UpdateAction is uaFail. So, the
exception will be raised when the value of this parameter is left unchanged.
To restore the old behaviour, set DoNotRaiseExcetionOnUaFail to True.
For more information about RAD Studio XE2, please refer to World Tour.
© 2018 Devart
107 PostgreSQL Data Access Components
The following two additional types are introduced to ensure compatibility in the process of
developing 32- and 64-bit applications:
Extended80 – whose size in 32-bit application is 10 bytes; however, this type provides the
same precision as its 8-byte equivalent in 64-bit applications.
Extended80Rec – can be used to perform low-level operations on an extended precision
floating-point value. For example, the sign, the exponent, and the mantissa can be changed
separately. It enables you to perform memory-related operations with 10-bit floating-point
variables, but not extended-precision arithmetic operations.
Pointer and Integers
© 2018 Devart
Using PgDAC 108
The major difference between 32- and 64-bit platforms is the volume of the used memory
and, correspondingly, the size of the pointer that is used to address large memory volumes.
At the same time, the size of the Integer type remains the same for both platforms:
That is why, the following code will work incorrectly on the 64-bit platform:
Ptr := Pointer(Integer(Ptr) + Offset);
While this code will correctly on the 64-bit platform and incorrectly on the 32-bit platform:
Ptr := Pointer(Int64(Ptr) + Offset);
For this purpose, the following platform-dependent integer type is introduced:
This type helps ensure that pointers work correctly both for the 32- and 64-bit platforms:
Ptr := Pointer(NativeInt(Ptr) + Offset);
However, you need to be extra-careful when developing applications for several versions of
Delphi, in which case you should remember that in the previous versions of Delphi the
NativeInt type had different sizes:
Delphi
TYPE Size
Version
NativeInt D5 N/A
NativeInt D6 N/A
NativeInt D7 8 bytes
NativeInt D2005 8 bytes
NativeInt D2006 8 bytes
NativeInt D2007 8 bytes
NativeInt D2009 4 bytes
NativeInt D2010 4 bytes
NativeInt Delphi XE 4 bytes
NativeInt Delphi XE2 4 or 8 bytes
© 2018 Devart
109 PostgreSQL Data Access Components
Out parameters
Some WinAPIs have OUT parameters of the SIZE_T type, which is equivalent to NativeInt in
Delphi XE2. The problem is that if you are developing only a 32-bit application, you won't be
able to pass Integer to OUT, while in a 64-bit application, you will not be able to pass Int64; in
both cases you will have to pass NativeInt.
For example:
procedure MyProc(out Value: NativeInt);
begin
Value := 12345;
end;
var
Value1: NativeInt;
{$IFDEF WIN32}
Value2: Integer;
{$ENDIF}
{$IFDEF WIN64}
Value2: Int64;
{$ENDIF}
begin
MyProc(Value1); // will be compiled;
MyProc(Value2); // will not be compiled !!!
end;
Win API
If you pass pointers to SendMessage/PostMessage/TControl.Perform, the wParam and
lParam parameters should be type-casted to the WPARAM/LPARAM type and not to Integer/
Longint.
Correct:
SendMessage(hWnd, WM_SETTEXT, 0, LPARAM(@MyCharArray));
Wrong:
SendMessage(hWnd, WM_SETTEXT, 0, Integer(@MyCharArray));
Replace SetWindowLong/GetWindowLog with SetWindowLongPtr/GetWindowLongPtr for
GWLP_HINSTANCE, GWLP_ID, GWLP_USERDATA, GWLP_HWNDPARENT and
GWLP_WNDPROC as they return pointers and handles. Pointers that are passed to
SetWindowLongPtr should be type-casted to LONG_PTR and not to Integer/Longint.
Correct:
SetWindowLongPtr(hWnd, GWLP_WNDPROC, LONG_PTR(@MyWindowProc));
Wrong:
SetWindowLong(hWnd, GWL_WNDPROC, Longint(@MyWindowProc));
Pointers that are assigned to the TMessage.Result field should use a type-cast to LRESULT
instead of Integer/Longint.
Correct:
© 2018 Devart
Using PgDAC 110
Message.Result := LRESULT(Self);
Wrong:
Message.Result := Integer(Self);
All TWM...-records for the windows message handlers must use the correct Windows types
for the fields:
Msg: UINT; wParam: WPARAM; lParam: LPARAM; Result: LRESULT)
Assembler
In order to make your application (that uses assembly code) work, you will have to make
several changes to it:
rewrite your code that mixes Pascal code and assembly code. Mixing them is not supported
in 64-bit applications;
rewrite assembly code that doesn't consider architecture and processor specifics.
You can use conditional defines to make your application work with different architectures.
You can learn more about Assembly code here: http://docwiki.embarcadero.com/RADStudio/
en/Using_Inline_Assembly_Code You can also look at the following article that will help you to
make your application support the 64-bit platform: http://docwiki.embarcadero.com/
RADStudio/en/Converting_32-bit_Delphi_Applications_to_64-bit_Windows
Exception handling
The biggest difference in exception handling between Delphi 32 and 64-bit is that in Delphi
XE2 64-bit you will gain more performance because of different internal exception
mechanism. For 32-bit applications, the Delphi compiler (dcc32.exe) generates additional
code that is executed any way and that causes performance loss. The 64-bit compiler
(dcc64.exe) doesn't generate such code, it generates metadata and stores it in the PDATA
section of an executable file instead.
But in Delphi XE2 64-bit it's impossible to have more than 16 levels of nested exceptions.
Having more than 16 levels of nested exceptions will cause a Run Time error.
Debugging
Debugging of 64-bit applications in RAD Studio XE2 is remote. It is caused by the same
reason: RAD Studio XE2 IDE is a 32 application, but your application is 64-bit. If you are trying
to debug your application and you cannot do it, you should check that the Include remote
debug symbols project option is enabled.
To enable it, perform the following steps:
1. Open Project Options (in the main menu Project->Options).
2. In the Target combobox, select Debug configuration - 64-bit Windows platform. If there
is no such option in the combobox, right click "Target Platforms" in Project Manager and
select Add platform. After adding the 64-bit Windows platform, the Debug configuration -
© 2018 Devart
111 PostgreSQL Data Access Components
After that, you can run and debug your 64-bit application.
To enable remote debugging, perform the following steps:
1. Install Platform Assistant Server (PAServer) on a remote computer. You can find PAServer
in the %RAD_Studio_XE2_Install_Directory%\PAServer directory. The setup_paserver.exe
file is an installation file for Windows, and the setup_paserver.zip file is an istallation file for
MacOS.
2. Run the PAServer.exe file on a remote computer and set the password that will be used to
connect to this computer.
3. On a local computer with RAD Studio XE2 installed, right-click the target platform that you
want to debug in Project Manager and select Assign Remote Profile. Click the Add button
in the displayed window, input your profile name, click the Next button, input the name of a
remote computer and the password to it (that you assigned when you started PAServer on
a remote computer).
After that, you can test the connection by clicking the Test Connection button. If your
connection failed, check that your firewalls on both remote and local computers do not block
your connection, and try to establish a connection once more. If your connection succeeded,
click the Next button and then the Finish button. Select your newly created profile and click
OK.
After performing these steps you will be able to debug your application on a remote computer.
You application will be executed on a remote computer, but you will be able to debug it on
your local computer with RAD Studio XE2.
For more information about working with Platform Assistant Server, please refer to http://
docwiki.embarcadero.com/RADStudio/Tokyo/en/
Running_the_Platform_Assistant_on_Windows
© 2018 Devart
Reference 112
5 Reference
This page shortly describes units that exist in PgDAC.
Units
DADump This unit contains the base class for the TPgDump
component.
DAScript This unit contains the base class for the TPgScript
component.
© 2018 Devart
113 PostgreSQL Data Access Components
5.1 CRAccess
This unit contains base classes for accessing databases.
Classes
Name Description
TCRCursor A base class for classes that work with database
cursors.
Types
© 2018 Devart
Reference 114
Name Description
TBeforeFetchProc This type is used for the
TCustomDADataSet.BeforeFetch event.
Enumerations
Name Description
TCRIsolationLevel Specifies how to handle transactions containing
database modifications.
Specifies the transaction behaviour when it is
TCRTransactionAction destroyed while being active, or when one of its
connections is closed with the active transaction.
TCursorState Used to set cursor state
5.1.1 Classes
Classes in the CRAccess unit.
Classes
Name Description
TCRCursor A base class for classes that work with database
cursors.
Unit
CRAccess
Syntax
TCRCursor = class(TSharedObject);
Remarks
TCRCursor is a base class for classes that work with database cursors.
Inheritance Hierarchy
© 2018 Devart
115 PostgreSQL Data Access Components
TSharedObject
TCRCursor
5.1.1.1.1 Members
Properties
Name Description
RefCount (inherited from Used to return the count of reference to a
TSharedObject) TSharedObject object.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.1.2 Types
Types in the CRAccess unit.
Types
Name Description
TBeforeFetchProc This type is used for the
TCustomDADataSet.BeforeFetch event.
Unit
CRAccess
© 2018 Devart
Reference 116
Syntax
TBeforeFetchProc = procedure (var Cancel: boolean) of object;
Parameters
Cancel
True, if the current fetch operation should be aborted.
5.1.3 Enumerations
Enumerations in the CRAccess unit.
Enumerations
Name Description
TCRIsolationLevel Specifies how to handle transactions containing
database modifications.
Specifies the transaction behaviour when it is
TCRTransactionAction destroyed while being active, or when one of its
connections is closed with the active transaction.
TCursorState Used to set cursor state
Unit
CRAccess
Syntax
TCRIsolationLevel = (ilReadCommitted);
Values
Value Meaning
The default transaction behavior. If the transaction contains DML
ilReadCommitted that requires row locks held by another transaction, then the DML
statement waits until the row locks are released.
© 2018 Devart
117 PostgreSQL Data Access Components
Specifies the transaction behaviour when it is destroyed while being active, or when one of its
connections is closed with the active transaction.
Unit
CRAccess
Syntax
TCRTransactionAction = (taCommit, taRollback);
Values
Value Meaning
taCommit Transaction is committed.
taRollback Transaction is rolled back.
5.1.3.3 TCursorState Enumeration
Unit
CRAccess
Syntax
TCursorState = (csInactive, csOpen, csParsed, csPrepared, csBound,
csExecuteFetchAll, csExecuting, csExecuted, csFetching,
csFetchingAll, csFetched);
Values
Value Meaning
csBound Parameters bound
csExecuted Statement successfully executed
csExecuteFetchAll Set before FetchAll
csExecuting Statement is set before executing
csFetched Fetch finished or canceled
csFetching Set on first
csFetchingAll Set on the FetchAll start
csInactive Default state
csOpen statement open
© 2018 Devart
Reference 118
5.2 CRBatchMove
This unit contains implementation of the TCRBatchMove component.
Classes
Name Description
TCRBatchMove Transfers records between datasets.
Types
Name Description
TCRBatchMoveProgressEvent This type is used for the
TCRBatchMove.OnBatchMoveProgress event.
Enumerations
Name Description
Used to set the type of the batch operation that will
TCRBatchMode be executed after calling the
TCRBatchMove.Execute method.
Used to specify the way fields of the destination
TCRFieldMappingMode and source datasets will be mapped to each other
if the TCRBatchMove.Mappings list is empty.
5.2.1 Classes
Classes in the CRBatchMove unit.
Classes
Name Description
TCRBatchMove Transfers records between datasets.
© 2018 Devart
119 PostgreSQL Data Access Components
Unit
CRBatchMove
Syntax
TCRBatchMove = class(TComponent);
Remarks
The TCRBatchMove component transfers records between datasets. Use it to copy dataset
records to another dataset or to delete datasets records that match records in another
dataset. The TCRBatchMove.Mode property determines the desired operation type, the
TCRBatchMove.Source and TCRBatchMove.Destination properties indicate corresponding
datasets.
Note: A TCRBatchMove component is added to the Data Access page of the component
palette, not to the PgDAC page.
5.2.1.1.1 Members
Properties
Name Description
Used to specify whether the batch operation
AbortOnKeyViol should be terminated immediately after key or
integrity violation.
Used to specify whether the batch operation
AbortOnProblem should be terminated immediately when it is
necessary to truncate data to make it fit the
specified Destination.
ChangedCount Used to get the number of records changed in the
destination dataset.
© 2018 Devart
Reference 120
Methods
Name Description
Execute Performs the batch operation.
Events
Name Description
OnBatchMoveProgress Occurs when providing feedback to the user about
the batch operation in progress is needed.
5.2.1.1.2 Properties
© 2018 Devart
121 PostgreSQL Data Access Components
Public
Name Description
ChangedCount Used to get the number of records changed in the
destination dataset.
Used to get the number of records that could not
KeyViolCount be moved to or from the destination dataset
because of integrity or key violations.
Used to get the number of records that were read
MovedCount from the source dataset during the batch
operation.
Used to get the number of records that could not
ProblemCount be added to the destination dataset because of
the field type mismatch.
Published
Name Description
Used to specify whether the batch operation
AbortOnKeyViol should be terminated immediately after key or
integrity violation.
Used to specify whether the batch operation
AbortOnProblem should be terminated immediately when it is
necessary to truncate data to make it fit the
specified Destination.
CommitCount Used to set the number of records to be batch
moved before commit occurs.
© 2018 Devart
Reference 122
See Also
TCRBatchMove Class
TCRBatchMove Class Members
Used to specify whether the batch operation should be terminated immediately after key or
integrity violation.
Class
TCRBatchMove
Syntax
property AbortOnKeyViol: boolean default True;
Remarks
Use the AbortOnKeyViol property to specify whether the batch operation is terminated
immediately after key or integrity violation.
5.2.1.1.2.2 AbortOnProblem Property
Used to specify whether the batch operation should be terminated immediately when it is
necessary to truncate data to make it fit the specified Destination.
Class
TCRBatchMove
Syntax
property AbortOnProblem: boolean default True;
Remarks
Use the AbortOnProblem property to specify whether the batch operation is terminated
immediately when it is necessary to truncate data to make it fit the specified Destination.
© 2018 Devart
123 PostgreSQL Data Access Components
Class
TCRBatchMove
Syntax
property ChangedCount: Integer;
Remarks
Use the ChangedCount property to get the number of records changed in the destination
dataset. It shows the number of records that were updated in the bmUpdate or
bmAppendUpdate mode or were deleted in the bmDelete mode.
5.2.1.1.2.4 CommitCount Property
Used to set the number of records to be batch moved before commit occurs.
Class
TCRBatchMove
Syntax
property CommitCount: integer default 0;
Remarks
Use the CommitCount property to set the number of records to be batch moved before the
commit occurs. If it is set to 0, the operation will be chunked to the number of records to fit 32
Kb.
5.2.1.1.2.5 Destination Property
Class
TCRBatchMove
Syntax
property Destination: TDataSet;
© 2018 Devart
Reference 124
Remarks
Specifies the destination dataset for the batch operation.
5.2.1.1.2.6 FieldMappingMode Property
Used to specify the way fields of destination and source datasets will be mapped to each
other if the Mappings list is empty.
Class
TCRBatchMove
Syntax
property FieldMappingMode: TCRFieldMappingMode default
mmFieldIndex;
Remarks
Specifies in what way fields of destination and source datasets will be mapped to each other
if the Mappings list is empty.
5.2.1.1.2.7 KeyViolCount Property
Used to get the number of records that could not be moved to or from the destination dataset
because of integrity or key violations.
Class
TCRBatchMove
Syntax
property KeyViolCount: Integer;
Remarks
Use the KeyViolCount property to get the number of records that could not be replaced,
added, deleted from the destination dataset because of integrity or key violations.
If AbortOnKeyViol is True, then KeyViolCount will never exceed one, because the operation
aborts when the integrity or key violation occurs.
See Also
AbortOnKeyViol
© 2018 Devart
125 PostgreSQL Data Access Components
Used to set field matching between source and destination datasets for the batch operation.
Class
TCRBatchMove
Syntax
property Mappings: TStrings;
Remarks
Use the Mappings property to set field matching between the source and destination datasets
for the batch operation. By default fields matching is based on their position in the datasets.
To map the column ColName in the source dataset to the column with the same name in the
destination dataset, use:
ColName
Example
To map a column named SourceColName in the source dataset to the column named
DestColName in the destination dataset, use:
DestColName=SourceColName
5.2.1.1.2.9 Mode Property
Used to set the type of the batch operation that will be executed after calling the Execute
method.
Class
TCRBatchMove
Syntax
property Mode: TCRBatchMode default bmAppend;
Remarks
Use the Mode property to set the type of the batch operation that will be executed after calling
the Execute method.
© 2018 Devart
Reference 126
Used to get the number of records that were read from the source dataset during the batch
operation.
Class
TCRBatchMove
Syntax
property MovedCount: Integer;
Remarks
Use the MovedCount property to get the number of records that were read from the source
dataset during the batch operation. This number includes records that caused key or integrity
violations or were trimmed.
5.2.1.1.2.11 ProblemCount Property
Used to get the number of records that could not be added to the destination dataset because
of the field type mismatch.
Class
TCRBatchMove
Syntax
property ProblemCount: Integer;
Remarks
Use the ProblemCount property to get the number of records that could not be added to the
destination dataset because of the field type mismatch.
If AbortOnProblem is True, then ProblemCount will never exceed one, because the operation
aborts when the problem occurs.
See Also
AbortOnProblem
Used to indicate the maximum number of records in the source dataset that will be applied to
the destination dataset.
© 2018 Devart
127 PostgreSQL Data Access Components
Class
TCRBatchMove
Syntax
property RecordCount: Integer default 0;
Remarks
Determines the maximum number of records in the source dataset, that will be applied to the
destination dataset. If it is set to 0, all records in the source dataset will be applied to the
destination dataset, starting from the first record. If RecordCount is greater than 0, up to the
RecordCount records are applied to the destination dataset, starting from the current record
in the source dataset. If RecordCount exceeds the number of records left in the source
dataset, batch operation terminates after reaching last record.
5.2.1.1.2.13 Source Property
Class
TCRBatchMove
Syntax
property Source: TDataSet;
Remarks
Specifies the source dataset for the batch operation.
5.2.1.1.3 Methods
Public
Name Description
Execute Performs the batch operation.
© 2018 Devart
Reference 128
See Also
TCRBatchMove Class
TCRBatchMove Class Members
Class
TCRBatchMove
Syntax
procedure Execute;
Remarks
Call the Execute method to perform the batch operation.
5.2.1.1.4 Events
Published
Name Description
See Also
TCRBatchMove Class
TCRBatchMove Class Members
Occurs when providing feedback to the user about the batch operation in progress is needed.
Class
TCRBatchMove
© 2018 Devart
129 PostgreSQL Data Access Components
Syntax
property OnBatchMoveProgress: TCRBatchMoveProgressEvent;
Remarks
Write the OnBatchMoveProgress event handler to provide feedback to the user about the
batch operation progress.
5.2.2 Types
Types in the CRBatchMove unit.
Types
Name Description
TCRBatchMoveProgressEvent This type is used for the
TCRBatchMove.OnBatchMoveProgress event.
Unit
CRBatchMove
Syntax
TCRBatchMoveProgressEvent = procedure (Sender: TObject; Percent:
integer) of object;
Parameters
Sender
An object that raised the event.
Percent
Percentage of the batch operation progress.
5.2.3 Enumerations
Enumerations in the CRBatchMove unit.
Enumerations
Name Description
© 2018 Devart
Reference 130
Used to set the type of the batch operation that will be executed after calling the
TCRBatchMove.Execute method.
Unit
CRBatchMove
Syntax
TCRBatchMode = (bmAppend, bmUpdate, bmAppendUpdate, bmDelete);
Values
Value Meaning
bmAppend Appends the records from the source dataset to the destination
dataset. The default mode.
Replaces records in the destination dataset with the matching
bmAppendUpdate records from the source dataset. If there is no matching record in
the destination dataset, the record will be appended to it.
bmDelete Deletes records from the destination dataset if there are
matching records in the source dataset.
bmUpdate Replaces records in the destination dataset with the matching
records from the source dataset.
Used to specify the way fields of the destination and source datasets will be mapped to each
other if the TCRBatchMove.Mappings list is empty.
Unit
CRBatchMove
Syntax
TCRFieldMappingMode = (mmFieldIndex, mmFieldName);
© 2018 Devart
131 PostgreSQL Data Access Components
Values
Value Meaning
mmFieldIndex Specifies that the fields of the destination dataset will be mapped
to the fields of the source dataset by field index.
mmFieldName Mapping is performed by field names.
5.3 CREncryption
This unit contains base classes for data encryption.
Classes
Name Description
The class that performs data encryption and
TCREncryptor decryption in a client application using various
encryption algorithms.
Enumerations
Name Description
TCREncDataHeader Specifies whether the additional information is
stored with the encrypted data.
5.3.1 Classes
Classes in the CREncryption unit.
Classes
Name Description
The class that performs data encryption and
TCREncryptor decryption in a client application using various
encryption algorithms.
© 2018 Devart
Reference 132
The class that performs data encryption and decryption in a client application using various
encryption algorithms.
For a list of all members of this type, see TCREncryptor members.
Unit
CREncryption
Syntax
TCREncryptor = class(TComponent);
5.3.1.1.1 Members
Properties
Name Description
DataHeader Specifies whether the additional information is
stored with the encrypted data.
Methods
Name Description
SetKey Sets a key, using which data is encrypted.
5.3.1.1.2 Properties
© 2018 Devart
133 PostgreSQL Data Access Components
topic.
Published
Name Description
DataHeader Specifies whether the additional information is
stored with the encrypted data.
See Also
TCREncryptor Class
TCREncryptor Class Members
Specifies whether the additional information is stored with the encrypted data.
Class
TCREncryptor
Syntax
property DataHeader: TCREncDataHeader default ehTagAndHash;
Remarks
Use DataHeader to specify whether the additional information is stored with the encrypted
data. Default value is ehTagAndHash.
5.3.1.1.2.2 EncryptionAlgorithm Property
Class
© 2018 Devart
Reference 134
TCREncryptor
Syntax
property EncryptionAlgorithm: TCREncryptionAlgorithm default
eaBlowfish;
Remarks
Use EncryptionAlgorithm to specify the algorithm of data encryption. Default value is
eaBlowfish.
5.3.1.1.2.3 HashAlgorithm Property
Class
TCREncryptor
Syntax
property HashAlgorithm: TCRHashAlgorithm default haSHA1;
Remarks
Use HashAlgorithm to specify the algorithm of generating hash data. This property is used
only if hash is stored with the encrypted data (the DataHeader property is set to
ehTagAndHash). Default value is haSHA1.
5.3.1.1.2.4 InvalidHashAction Property
Specifies the action to perform on data fetching when hash data is invalid.
Class
TCREncryptor
Syntax
property InvalidHashAction: TCRInvalidHashAction default ihFail;
Remarks
Use InvalidHashAction to specify the action to perform on data fetching when hash data is
invalid. This property is used only if hash is stored with the encrypted data (the DataHeader
property is set to ehTagAndHash). Default value is ihFail.
© 2018 Devart
135 PostgreSQL Data Access Components
If the DataHeader property is set to ehTagAndHash, then on data fetching from a server the
hash check is performed for each record. After data decryption its hash is calculated and
compared with the hash stored in the field. If these values don't coincide, it means that the
stored data is incorrect, and depending on the value of the InvalidHashAction property one of
the following actions is performed:
ihFail - the EInvalidHash exception is raised and further data reading from the server is
interrupted.
ihSkipData - the value of the field for this record is set to Null. No exception is raised.
ihIgnoreError - in spite of the fact that the data is not valid, the value is set in the field. No
exception is raised.
5.3.1.1.2.5 Passw ord Property
Class
TCREncryptor
Syntax
property Password: string stored False;
Remarks
Use Password to set a password that is used to generate a key for encryption.
Note: Calling of the SetKey method clears the Password property.
5.3.1.1.3 Methods
Public
Name Description
SetKey Sets a key, using which data is encrypted.
See Also
TCREncryptor Class
TCREncryptor Class Members
© 2018 Devart
Reference 136
Class
TCREncryptor
Syntax
procedure SetKey(const Key; Count: Integer); overload;procedure
SetKey(const Key: TBytes; Offset: Integer; Count: Integer);
overload;
Parameters
Key
Holds bytes that represent a key.
Offset
Offset in bytes to the position, where the key begins.
Count
Number of bytes to use from Key.
Remarks
Use SetKey to set a key, using which data is encrypted.
Note: Calling of the SetKey method clears the Password property.
5.3.2 Enumerations
Enumerations in the CREncryption unit.
Enumerations
Name Description
TCREncDataHeader Specifies whether the additional information is
stored with the encrypted data.
© 2018 Devart
137 PostgreSQL Data Access Components
Specifies whether the additional information is stored with the encrypted data.
Unit
CREncryption
Syntax
TCREncDataHeader = (ehTagAndHash, ehTag, ehNone);
Values
Value Meaning
ehNone No additional information is stored.
ehTag GUID and the random initialization vector are stored with the
encrypted data.
ehTagAndHash Hash, GUID, and the random initialization vector are stored with
the encrypted data.
5.3.2.2 TCREncryptionAlgorithm Enumeration
Unit
CREncryption
Syntax
TCREncryptionAlgorithm = (eaTripleDES, eaBlowfish, eaAES128,
eaAES192, eaAES256, eaCast128, eaRC4);
Values
Value Meaning
eaAES128 The AES encryption algorithm with key size of 128 bits is used.
eaAES192 The AES encryption algorithm with key size of 192 bits is used.
eaAES256 The AES encryption algorithm with key size of 256 bits is used.
eaBlowfish The Blowfish encryption algorithm is used.
eaCast128 The CAST-128 encryption algorithm with key size of 128 bits is
used.
eaRC4 The RC4 encryption algorithm is used.
eaTripleDES The Triple DES encryption algorithm is used.
© 2018 Devart
Reference 138
Unit
CREncryption
Syntax
TCRHashAlgorithm = (haSHA1, haMD5);
Values
Value Meaning
haMD5 The MD5 hash algorithm is used.
haSHA1 The SHA-1 hash algorithm is used.
5.3.2.4 TCRInvalidHashAction Enumeration
Specifies the action to perform on data fetching when hash data is invalid.
Unit
CREncryption
Syntax
TCRInvalidHashAction = (ihFail, ihSkipData, ihIgnoreError);
Values
Value Meaning
ihFail The EInvalidHash exception is raised and further data reading
from the server is interrupted.
ihIgnoreError In spite of the fact that the data is not valid, the value is set in the
field. No exception is raised.
ihSkipData The value of the field for this record is set to Null. No exception is
raised.
5.4 DAAlerter
This unit contains the base class for the TPgAlerter component.
Classes
© 2018 Devart
139 PostgreSQL Data Access Components
Name Description
TDAAlerter A base class that defines functionality for
database event notification.
Types
Name Description
TAlerterErrorEvent This type is used for the TDAAlerter.OnError
event.
5.4.1 Classes
Classes in the DAAlerter unit.
Classes
Name Description
TDAAlerter A base class that defines functionality for
database event notification.
Unit
DAAlerter
Syntax
TDAAlerter = class(TComponent);
Remarks
TDAAlerter is a base class that defines functionality for descendant classes support database
event notification. Applications never use TDAAlerter objects directly. Instead they use
descendants of TDAAlerter.
The TDAAlerter component allows you to register interest in and handle events posted by a
database server. Use TDAAlerter to handle events for responding to actions and database
changes made by other applications. To get events, an application must register required
events. To do this, set the Events property to the required events and call the Start method.
© 2018 Devart
Reference 140
Properties
Name Description
Active Used to determine if TDAAlerter waits for
messages.
Methods
Name Description
Events
Name Description
OnError Occurs if an exception occurs in waiting process
5.4.1.1.2 Properties
Public
Name Description
© 2018 Devart
141 PostgreSQL Data Access Components
See Also
TDAAlerter Class
TDAAlerter Class Members
Class
TDAAlerter
Syntax
property Active: boolean default False;
Remarks
Check the Active property to know whether TDAlerter waits for messages or not. Set it to
True to register events.
See Also
Start
Stop
Class
TDAAlerter
Syntax
property AutoRegister: boolean default False;
© 2018 Devart
Reference 142
Remarks
Set the AutoRegister property to True to automatically register events whenever connection
opens.
5.4.1.1.2.3 Connection Property
Class
TDAAlerter
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify the connection for TDAAlerter.
5.4.1.1.3 Methods
Public
Name Description
SendEvent Sends an event with Name and content Message.
See Also
TDAAlerter Class
TDAAlerter Class Members
© 2018 Devart
143 PostgreSQL Data Access Components
Class
TDAAlerter
Syntax
procedure SendEvent(const EventName: string; const Message:
string);
Parameters
EventName
Holds the event name.
Message
Holds the content Message of the event.
Remarks
Use SendEvent procedure to send an event with Name and content Message.
5.4.1.1.3.2 Start Method
Class
TDAAlerter
Syntax
procedure Start;
Remarks
Call the Start method to run waiting process. After starting TDAAlerter waits for messages
with names defined by the Events property.
See Also
Stop
Active
© 2018 Devart
Reference 144
Class
TDAAlerter
Syntax
procedure Stop;
Remarks
Call Stop method to end waiting process.
See Also
Start
5.4.1.1.4 Events
Public
Name Description
OnError Occurs if an exception occurs in waiting process
See Also
TDAAlerter Class
TDAAlerter Class Members
Class
TDAAlerter
Syntax
property OnError: TAlerterErrorEvent;
© 2018 Devart
145 PostgreSQL Data Access Components
Remarks
The OnError event occurs if an exception occurs in waiting process. Alerter stops in this
case. The exception can be accessed using the E parameter.
5.4.2 Types
Types in the DAAlerter unit.
Types
Name Description
TAlerterErrorEvent This type is used for the TDAAlerter.OnError
event.
Unit
DAAlerter
Syntax
TAlerterErrorEvent = procedure (Sender: TDAAlerter; E: Exception)
of object;
Parameters
Sender
An object that raised the event.
E
Exception object.
5.5 DADump
This unit contains the base class for the TPgDump component.
Classes
Name Description
A base class that defines functionality for
TDADump descendant classes that dump database objects
to a script.
© 2018 Devart
Reference 146
Types
Name Description
TDABackupProgressEvent This type is used for the
TDADump.OnBackupProgress event.
5.5.1 Classes
Classes in the DADump unit.
Classes
Name Description
A base class that defines functionality for
TDADump descendant classes that dump database objects
to a script.
TDADumpOptions This class allows setting up the behaviour of the
TDADump class.
A base class that defines functionality for descendant classes that dump database objects to
a script.
For a list of all members of this type, see TDADump members.
Unit
DADump
Syntax
TDADump = class(TComponent);
Remarks
TDADump is a base class that defines functionality for descendant classes that dump
database objects to a script. Applications never use TDADump objects directly. Instead they
© 2018 Devart
147 PostgreSQL Data Access Components
Properties
Name Description
Connection Used to specify a connection object that will be
used to connect to a data store.
Methods
Name Description
Backup Dumps database objects to the TDADump.SQL
property.
© 2018 Devart
Reference 148
Events
Name Description
Occurs to indicate the TDADump.Backup,
M:Devart.Dac.TDADump.BackupToFile(System.S
OnBackupProgress tring) or
M:Devart.Dac.TDADump.BackupToStream(Borla
nd.Vcl.TStream) method execution progress.
OnError Occurs when PostgreSQL raises some error on
TDADump.Restore.
Occurs to indicate the TDADump.Restore,
OnRestoreProgress TDADump.RestoreFromFile, or
TDADump.RestoreFromStream method execution
progress.
5.5.1.1.2 Properties
Public
Name Description
Connection Used to specify a connection object that will be
used to connect to a data store.
Published
Name Description
Debug Used to display executing statement, all its
parameters' values, and the type of parameters.
© 2018 Devart
149 PostgreSQL Data Access Components
See Also
TDADump Class
TDADump Class Members
Used to specify a connection object that will be used to connect to a data store.
Class
TDADump
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify a connection object that will be used to connect to a
data store.
Set at design-time by selecting from the list of provided TCustomDAConnection or its
descendant class objects.
At runtime, link an instance of a TCustomDAConnection descendant to the Connection
property.
See Also
TCustomDAConnection
Used to display executing statement, all its parameters' values, and the type of parameters.
Class
TDADump
Syntax
property Debug: boolean default False;
© 2018 Devart
Reference 150
Remarks
Set the Debug property to True to display executing statement and all its parameters' values.
Also displays the type of parameters.
You should add the PgDacVcl unit to the uses clause of any unit in your project to make the
Debug property work.
Note: If TPgSQLMonitor is used in the project and the TPgSQLMonitor.Active property is set
to False, the debug window is not displayed.
See Also
TCustomDADataSet.Debug
TCustomDASQL.Debug
Class
TDADump
Syntax
property Options: TDADumpOptions;
Remarks
Use the Options property to specify the behaviour of a TDADump component.
Descriptions of all options are in the table below.
© 2018 Devart
151 PostgreSQL Data Access Components
Class
TDADump
Syntax
property SQL: TStrings;
Remarks
Use the SQL property to get or set the dump script. The SQL property stores script that is
executed by the Restore method. This property will store the result of Backup and
BackupQuery. At design time the SQL property can be edited by invoking the String List editor
in Object Inspector.
See Also
Restore
Backup
BackupQuery
Class
TDADump
Syntax
property TableNames: string;
Remarks
Use the TableNames property to set the names of the tables to dump. Table names must be
separated with commas. If it is empty, the Backup method will dump all available tables.
See Also
Backup
© 2018 Devart
Reference 152
5.5.1.1.3 Methods
Public
Name Description
Backup Dumps database objects to the TDADump.SQL
property.
See Also
TDADump Class
TDADump Class Members
Class
TDADump
Syntax
procedure Backup;
Remarks
Call the Backup method to dump database objects. The result script will be stored in the SQL
© 2018 Devart
153 PostgreSQL Data Access Components
property.
See Also
SQL
Restore
BackupToFile
BackupToStream
BackupQuery
Class
TDADump
Syntax
procedure BackupQuery(const Query: string);
Parameters
Query
Holds a query used for data selection.
Remarks
Call the BackupQuery method to dump the results of a particular query. Query must be a
valid select statement. If this query selects data from several tables, only data of the first table
in the from list will be dumped.
See Also
Restore
Backup
BackupToFile
BackupToStream
Class
TDADump
© 2018 Devart
Reference 154
Syntax
procedure BackupToFile(const FileName: string; const Query:
string = '');
Parameters
FileName
Holds the file name to dump database objects to.
Query
Your query to receive the data for dumping.
Remarks
Call the BackupToFile method to dump database objects to the specified file.
See Also
RestoreFromStream
Backup
BackupToStream
Class
TDADump
Syntax
procedure BackupToStream(Stream: TStream; const Query: string =
'');
Parameters
Stream
Holds the stream to dump database objects to.
Query
Your query to receive the data for dumping.
Remarks
Call the BackupToStream method to dump database objects to the stream.
See Also
© 2018 Devart
155 PostgreSQL Data Access Components
RestoreFromStream
Backup
BackupToFile
Class
TDADump
Syntax
procedure Restore;
Remarks
Call the Restore method to execute a script contained in the SQL property.
See Also
RestoreFromFile
RestoreFromStream
Backup
SQL
Class
TDADump
Syntax
procedure RestoreFromFile(const FileName: string);
Parameters
FileName
Holds the file name to execute a script from.
Remarks
Call the RestoreFromFile method to execute a script from the specified file.
© 2018 Devart
Reference 156
See Also
Restore
RestoreFromStream
BackupToFile
Class
TDADump
Syntax
procedure RestoreFromStream(Stream: TStream);
Parameters
Stream
Holds a stream to receive a script to be executed.
Remarks
Call the RestoreFromStream method to execute a script received from the stream.
See Also
Restore
RestoreFromFile
BackupToStream
5.5.1.1.4 Events
Published
Name Description
Occurs to indicate the TDADump.Backup,
M:Devart.Dac.TDADump.BackupToFile(System.S
OnBackupProgress tring) or
M:Devart.Dac.TDADump.BackupToStream(Borla
nd.Vcl.TStream) method execution progress.
© 2018 Devart
157 PostgreSQL Data Access Components
See Also
TDADump Class
TDADump Class Members
Class
TDADump
Syntax
property OnBackupProgress: TDABackupProgressEvent;
Remarks
The OnBackupProgress event occurs several times during the dumping process of the
Backup, M:Devart.Dac.TDADump.BackupToFile(System.String), or
M:Devart.Dac.TDADump.BackupToStream(Borland.Vcl.TStream) method execution and
indicates its progress. ObjectName parameter indicates the name of the currently dumping
database object. ObjectNum shows the number of the current database object in the backup
queue starting from zero. ObjectCount shows the quantity of database objects to dump.
Percent parameter shows the current percentage of the current table data dumped, not the
current percentage of the entire dump process.
See Also
Backup
BackupToFile
BackupToStream
© 2018 Devart
Reference 158
Class
TDADump
Syntax
property OnError: TOnErrorEvent;
Remarks
The OnError event occurs when PostgreSQL raises some error on Restore.
Action indicates the action to take when the OnError handler exits. On entry into the handler,
Action is always set to eaException.
Note: You should add the DAScript module to the 'uses' list to use the OnError event handler.
Class
TDADump
Syntax
property OnRestoreProgress: TDARestoreProgressEvent;
Remarks
The OnRestoreProgress event occurs several times during the dumping process of the
Restore, RestoreFromFile, or RestoreFromStream method execution and indicates its
progress. The Percent parameter of the OnRestoreProgress event handler indicates the
percentage of the whole restore script execution.
See Also
Restore
RestoreFromFile
RestoreFromStream
© 2018 Devart
159 PostgreSQL Data Access Components
Unit
DADump
Syntax
TDADumpOptions = class(TPersistent);
5.5.1.2.1 Members
Properties
Name Description
AddDrop Used to add drop statements to a script before
creating statements.
Used to explicitly specify the table fields names
CompleteInsert when generating the INSERT SQL query. The
default value is False.
GenerateHeader Used to add a comment header to a script.
5.5.1.2.2 Properties
Published
Name Description
AddDrop Used to add drop statements to a script before
creating statements.
Used to explicitly specify the table fields names
CompleteInsert when generating the INSERT SQL query. The
default value is False.
© 2018 Devart
Reference 160
See Also
TDADumpOptions Class
TDADumpOptions Class Members
Class
TDADumpOptions
Syntax
property AddDrop: boolean default True;
Remarks
Use the AddDrop property to add drop statements to a script before creating statements.
5.5.1.2.2.2 CompleteInsert Property
Used to explicitly specify the table fields names when generating the INSERT SQL query. The
default value is False.
Class
TDADumpOptions
Syntax
property CompleteInsert: boolean default False;
Remarks
If the CompleteInsert property is set to True, SQL query will include the field names, for
example:
INSERT INTO dept(deptno, dname, loc) VALUES ('10', 'ACCOUNTING', 'NEW YORK')
If False, it won't include the field names, for example:
© 2018 Devart
161 PostgreSQL Data Access Components
Class
TDADumpOptions
Syntax
property GenerateHeader: boolean default True;
Remarks
Use the GenerateHeader property to add a comment header to a script. It contains script
generation date, DAC version, and some other information.
5.5.1.2.2.4 QuoteNames Property
Used for TDADump to quote all database object names in generated SQL statements.
Class
TDADumpOptions
Syntax
property QuoteNames: boolean default False;
Remarks
If the QuoteNames property is True, TDADump quotes all database object names in
generated SQL statements.
5.5.2 Types
Types in the DADump unit.
Types
Name Description
TDABackupProgressEvent This type is used for the
TDADump.OnBackupProgress event.
© 2018 Devart
Reference 162
Unit
DADump
Syntax
TDABackupProgressEvent = procedure (Sender: TObject; ObjectName:
string; ObjectNum: integer; ObjectCount: integer; Percent:
integer) of object;
Parameters
Sender
An object that raised the event.
ObjectName
The name of the currently dumping database object.
ObjectNum
The number of the current database object in the backup queue starting from zero.
ObjectCount
The quantity of database objects to dump.
Percent
The current percentage of the current table data dumped.
5.5.2.2 TDARestoreProgressEvent Procedure Reference
Unit
DADump
Syntax
TDARestoreProgressEvent = procedure (Sender: TObject; Percent:
integer) of object;
Parameters
Sender
An object that raised the event.
Percent
The percentage of the whole restore script execution.
© 2018 Devart
163 PostgreSQL Data Access Components
5.6 DALoader
This unit contains the base class for the TPgLoader component.
Classes
Name Description
TDAColumn Represents the attributes for column loading.
Types
Name Description
TDAPutDataEvent This type is used for the TDALoader.OnPutData
event.
5.6.1 Classes
Classes in the DALoader unit.
Classes
Name Description
TDAColumn Represents the attributes for column loading.
© 2018 Devart
Reference 164
Unit
DALoader
Syntax
TDAColumn = class(TCollectionItem);
Remarks
Each TDALoader uses TDAColumns to maintain a collection of TDAColumn objects.
TDAColumn object represents the attributes for column loading. Every TDAColumn object
corresponds to one of the table fields with the same name as its TDAColumn.Name property.
To create columns at design-time use the column editor of the TDALoader component.
See Also
TDALoader
TDAColumns
5.6.1.1.1 Members
Properties
Name Description
FieldType Used to specify the types of values that will be
loaded.
5.6.1.1.2 Properties
© 2018 Devart
165 PostgreSQL Data Access Components
Published
Name Description
FieldType Used to specify the types of values that will be
loaded.
See Also
TDAColumn Class
TDAColumn Class Members
Class
TDAColumn
Syntax
property FieldType: TFieldType default ftString;
Remarks
Use the FieldType property to specify the types of values that will be loaded. Field types for
columns may not match data types for the corresponding fields in the database table.
TDALoader will cast data values to the types of their fields.
5.6.1.1.2.2 Name Property
Class
TDAColumn
Syntax
property Name: string;
Remarks
Each TDAColumn corresponds to one field of the loading table. Use the Name property to
© 2018 Devart
Reference 166
See Also
FieldType
Unit
DALoader
Syntax
TDAColumns = class(TOwnedCollection);
Remarks
Each TDAColumns holds a collection of TDAColumn objects. TDAColumns maintains an
index of the columns in its Items array. The Count property contains the number of columns
in the collection. At design-time, use the Columns editor to add, remove, or modify columns.
See Also
TDALoader
TDAColumn
5.6.1.2.1 Members
Properties
Name Description
Items Used to access individual columns.
5.6.1.2.2 Properties
Public
© 2018 Devart
167 PostgreSQL Data Access Components
Name Description
Items Used to access individual columns.
See Also
TDAColumns Class
TDAColumns Class Members
Class
TDAColumns
Syntax
property Items[Index: integer]: TDAColumn; default;
Parameters
Index
Holds the Index of TDAColumn to refer to.
Remarks
Use the Items property to access individual columns. The value of the Index parameter
corresponds to the Index property of TDAColumn.
See Also
TDAColumn
Unit
DALoader
Syntax
TDALoader = class(TComponent);
© 2018 Devart
Reference 168
Remarks
TDALoader allows loading external data into database. To specify the name of loading table
set the TDALoader.TableName property. Use the TDALoader.Columns property to access
individual columns. Write the TDALoader.OnGetColumnData or TDALoader.OnPutData event
handlers to read external data and pass it to the database. Call the TDALoader.Load method
to start loading data.
5.6.1.3.1 Members
Properties
Name Description
Columns Used to add a TDAColumn object for each field
that will be loaded.
Methods
Name Description
Creates TDAColumn objects for all fields of the
CreateColumns table with the same name as
TDALoader.TableName.
Load Starts loading data.
Events
Name Description
© 2018 Devart
169 PostgreSQL Data Access Components
Public
Name Description
Columns Used to add a TDAColumn object for each field
that will be loaded.
See Also
TDALoader Class
TDALoader Class Members
Used to add a TDAColumn object for each field that will be loaded.
Class
TDALoader
Syntax
property Columns: TDAColumns stored IsColumnsStored;
Remarks
Use the Columns property to add a TDAColumn object for each field that will be loaded.
© 2018 Devart
Reference 170
See Also
TDAColumns
Class
TDALoader
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify TCustomDAConnection in which TDALoader will be
executed. If Connection is not connected, the Load method calls
TCustomDAConnection.Connect.
See Also
TCustomDAConnection
Used to specify the name of the table to which data will be loaded.
Class
TDALoader
Syntax
property TableName: string;
Remarks
Set the TableName property to specify the name of the table to which data will be loaded. Add
TDAColumn objects to Columns for the fields that are needed to be loaded.
See Also
TDAColumn
TCustomDAConnection.GetTableNames
© 2018 Devart
171 PostgreSQL Data Access Components
5.6.1.3.3 Methods
Public
Name Description
Creates TDAColumn objects for all fields of the
CreateColumns table with the same name as
TDALoader.TableName.
Load Starts loading data.
See Also
TDALoader Class
TDALoader Class Members
Creates TDAColumn objects for all fields of the table with the same name as TableName.
Class
TDALoader
Syntax
procedure CreateColumns;
Remarks
Call the CreateColumns method to create TDAColumn objects for all fields of the table with
the same name as TableName. If columns were created before, they will be recreated. You
can call CreateColumns from the component popup menu at design-time. After you can
customize column loading by setting properties of TDAColumn objects.
See Also
TDAColumn
© 2018 Devart
Reference 172
TableName
Class
TDALoader
Syntax
procedure Load; virtual;
Remarks
Call the Load method to start loading data. At first it is necessary to create columns and write
one of the OnPutData or OnGetColumnData event handlers.
See Also
OnGetColumnData
OnPutData
Class
TDALoader
Syntax
procedure LoadFromDataSet(DataSet: TDataSet);
Parameters
DataSet
Holds the dataset to load data from.
Remarks
Call the LoadFromDataSet method to load data from the specified dataset. There is no need
to create columns and write event handlers for OnPutData and OnGetColumnData before
calling this method.
© 2018 Devart
173 PostgreSQL Data Access Components
Class
TDALoader
Overload List
Name Description
PutColumnData(Col: integer; Row: integer; Puts the value of individual columns by the
const Value: variant) column index.
PutColumnData(const ColName: string; Puts the value of individual columns by the
Row: integer; const Value: variant) column name.
Class
TDALoader
Syntax
procedure PutColumnData(Col: integer; Row: integer; const Value:
variant); overload; virtual;
Parameters
Col
Holds the index of a loading column. The first column has index 0.
Row
Holds the number of loading row. Row starts from 1.
Value
Holds the column value.
Remarks
Call the PutColumnData method to put the value of individual columns. The Col parameter
indicates the index of loading column. The first column has index 0. The Row parameter
indicates the number of the loading row. Row starts from 1.
This overloaded method works faster because it searches the right index by its index, not by
the index name.
The value of a column should be assigned to the Value parameter.
See Also
© 2018 Devart
Reference 174
TDALoader.OnPutData
Class
TDALoader
Syntax
procedure PutColumnData(const ColName: string; Row: integer;
const Value: variant); overload;
Parameters
ColName
Hods the name of a loading column.
Row
Holds the number of loading row. Row starts from 1.
Value
Holds the column value.
5.6.1.3.4 Events
Public
Name Description
See Also
TDALoader Class
TDALoader Class Members
© 2018 Devart
175 PostgreSQL Data Access Components
Class
TDALoader
Syntax
property OnGetColumnData: TGetColumnDataEvent;
Remarks
Write the OnGetColumnData event handler to put column values. TDALoader calls the
OnGetColumnData event handler for each column in the loop. Column points to a
TDAColumn object that corresponds to the current loading column. Use its Name or Index
property to identify what column is loading. The Row parameter indicates the current loading
record. TDALoader increments the Row parameter when all the columns of the current
record are loaded. The first row is 1. Set EOF to True to stop data loading. Fill the Value
parameter by column values. To start loading call the Load method.
Another way to load data is using the OnPutData event.
Example
This handler loads 1000 rows.
See Also
OnPutData
Load
© 2018 Devart
Reference 176
Class
TDALoader
Syntax
property OnProgress: TLoaderProgressEvent;
Remarks
Add a handler to this event if you want to handle data loading progress of the
LoadFromDataSet method.
See Also
LoadFromDataSet
Class
TDALoader
Syntax
property OnPutData: TDAPutDataEvent;
Remarks
Write the OnPutData event handler to put loading data by rows.
Note that rows should be loaded from the first in the ascending order.
To start loading, call the Load method.
Example
This handler loads 1000 rows.
© 2018 Devart
177 PostgreSQL Data Access Components
Sender.PutColumnData(0, i, 1);
Sender.PutColumnData(1, i, Random(100));
Sender.PutColumnData(2, i, Random*100);
Sender.PutColumnData(3, i, 'abc01234567890123456789');
Sender.PutColumnData(4, i, Date);
end;
end;
See Also
TDALoader.PutColumnData
Load
OnGetColumnData
Unit
DALoader
Syntax
TDALoaderOptions = class(TPersistent);
5.6.1.4.1 Members
Properties
Name Description
UseBlankValues Forces PgDAC to fill the buffer with null values
after loading a row to the database.
5.6.1.4.2 Properties
Public
Name Description
© 2018 Devart
Reference 178
See Also
TDALoaderOptions Class
TDALoaderOptions Class Members
Forces PgDAC to fill the buffer with null values after loading a row to the database.
Class
TDALoaderOptions
Syntax
property UseBlankValues: boolean default True;
Remarks
Used to force PgDAC to fill the buffer with null values after loading a row to the database.
5.6.2 Types
Types in the DALoader unit.
Types
Name Description
TDAPutDataEvent This type is used for the TDALoader.OnPutData
event.
Unit
DALoader
© 2018 Devart
179 PostgreSQL Data Access Components
Syntax
TDAPutDataEvent = procedure (Sender: TDALoader) of object;
Parameters
Sender
An object that raised the event.
5.6.2.2 TGetColumnDataEvent Procedure Reference
Unit
DALoader
Syntax
TGetColumnDataEvent = procedure (Sender: TObject; Column:
TDAColumn; Row: integer; var Value: variant; var IsEOF: boolean)
of object;
Parameters
Sender
An object that raised the event.
Column
Points to TDAColumn object that corresponds to the current loading column.
Row
Indicates the current loading record.
Value
Holds column values.
IsEOF
True, if data loading needs to be stopped.
5.6.2.3 TLoaderProgressEvent Procedure Reference
Unit
DALoader
Syntax
TLoaderProgressEvent = procedure (Sender: TObject; Percent:
integer) of object;
© 2018 Devart
Reference 180
Parameters
Sender
An object that raised the event.
Percent
Percentage of the load operation progress.
5.7 DAScript
This unit contains the base class for the TPgScript component.
Classes
Name Description
TDAScript Makes it possible to execute several SQL
statements one by one.
Types
Name Description
Enumerations
Name Description
TErrorAction Indicates the action to take when the OnError
handler exits.
© 2018 Devart
181 PostgreSQL Data Access Components
5.7.1 Classes
Classes in the DAScript unit.
Classes
Name Description
TDAScript Makes it possible to execute several SQL
statements one by one.
Unit
DAScript
Syntax
TDAScript = class(TComponent);
Remarks
Often it is necessary to execute several SQL statements one by one. This can be performed
using a lot of components such as TCustomDASQL descendants. Usually it isn't the best
solution. With only one TDAScript descedant component you can execute several SQL
statements as one. This sequence of statements is called script. To separate single
statements use semicolon (;) or slash (/) and for statements that can contain semicolon, only
slash. Note that slash must be the first character in line.
Errors that occur during execution can be processed in the TDAScript.OnError event handler.
By default, on error TDAScript shows exception and continues execution.
See Also
TCustomDASQL
© 2018 Devart
Reference 182
5.7.1.1.1 Members
Properties
Name Description
Connection Used to specify the connection in which the script
will be executed.
EndOffset Used to get the offset in the last line of the current
statement.
StartOffset Used to get the offset in the first line of the current
statement.
Methods
Name Description
© 2018 Devart
183 PostgreSQL Data Access Components
Events
Name Description
AfterExecute Occurs after a SQL script execution.
5.7.1.1.2 Properties
Public
Name Description
Connection Used to specify the connection in which the script
will be executed.
© 2018 Devart
Reference 184
EndOffset Used to get the offset in the last line of the current
statement.
StartOffset Used to get the offset in the first line of the current
statement.
Published
Name Description
Debug Used to display the script execution and all its
parameter values.
See Also
TDAScript Class
TDAScript Class Members
Class
TDAScript
© 2018 Devart
185 PostgreSQL Data Access Components
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify the connection in which the script will be executed. If
Connection is not connected, the Execute method calls the Connect method of Connection.
Set at design-time by selecting from the list of provided TCustomDAConnection objects.
At run-time, set the Connection property to reference an existing TCustomDAConnection
object.
See Also
TCustomDAConnection
Class
TDAScript
Syntax
property DataSet: TCustomDADataSet;
Remarks
Set the DataSet property to retrieve the results of the SELECT statements execution inside a
script.
See Also
ExecuteNext
Execute
Used to display the script execution and all its parameter values.
Class
TDAScript
Syntax
© 2018 Devart
Reference 186
Remarks
Set the Debug property to True to display executing statement and all its parameters' values.
Also displays the type of parameters.
You should add the PgDacVcl unit to the uses clause of any unit in your project to make the
Debug property work.
Note: If TPgSQLMonitor is used in the project and the TPgSQLMonitor.Active property is set
to False, the debug window is not displayed.
5.7.1.1.2.4 Delimiter Property
Class
TDAScript
Syntax
property Delimiter: string stored IsDelimiterStored;
Remarks
Use the Delimiter property to set the delimiter string that separates script statements. By
default it is semicolon (;). You can use slash (/) to separate statements that can contain
semicolon if the Delimiter property's default value is semicolon. Note that slash must be the
first character in line.
5.7.1.1.2.5 EndLine Property
Class
TDAScript
Syntax
property EndLine: Int64;
Remarks
Use the EndLine property to get the current statement last line number in a script.
© 2018 Devart
187 PostgreSQL Data Access Components
Used to get the offset in the last line of the current statement.
Class
TDAScript
Syntax
property EndOffset: Int64;
Remarks
Use the EndOffset property to get the offset in the last line of the current statement.
5.7.1.1.2.7 EndPos Property
Class
TDAScript
Syntax
property EndPos: Int64;
Remarks
Use the EndPos property to get the end position of the current statement (the position of the
last character in the statement) in a script.
5.7.1.1.2.8 Macros Property
Class
TDAScript
Syntax
property Macros: TMacros stored False;
Remarks
With the help of macros you can easily change SQL script text in design- or run-time. Macros
extend abilities of parameters and allow changing conditions in the WHERE clause or sort
© 2018 Devart
Reference 188
order in the ORDER BY clause. You just insert &MacroName in a SQL query text and change
value of macro by the Macro property editor in design-time or the MacroByName function in
run-time. In time of opening query macro is replaced by its value.
See Also
TMacro
MacroByName
Class
TDAScript
Syntax
property SQL: TStrings;
Remarks
Use the SQL property to get or set script text.
5.7.1.1.2.10 StartLine Property
Class
TDAScript
Syntax
property StartLine: Int64;
Remarks
Use the StartLine property to get the current statement start line number in a script.
5.7.1.1.2.11 StartOffset Property
Used to get the offset in the first line of the current statement.
Class
TDAScript
© 2018 Devart
189 PostgreSQL Data Access Components
Syntax
property StartOffset: Int64;
Remarks
Use the StartOffset property to get the offset in the first line of the current statement.
5.7.1.1.2.12 StartPos Property
Class
TDAScript
Syntax
property StartPos: Int64;
Remarks
Use the StartPos property to get the start position of the current statement (the position of the
first statement character) in a script.
5.7.1.1.2.13 Statements Property
Class
TDAScript
Syntax
property Statements: TDAStatements;
Remarks
Contains a list of statements that are obtained from the SQL property. Use the Access
Statements property to view SQL statement, set parameters or execute the specified
statement. Statements is a zero-based array of statement records. Index specifies the array
element to access.
For example, consider the following script:
CREATE TABLE A (FIELD1 INTEGER);
INSERT INTO A VALUES(1);
INSERT INTO A VALUES(2);
INSERT INTO A VALUES(3);
© 2018 Devart
Reference 190
Example
You can use the Statements property in the following way:
See Also
TDAStatements
5.7.1.1.3 Methods
Public
Name Description
BreakExec Stops script execution.
© 2018 Devart
191 PostgreSQL Data Access Components
See Also
TDAScript Class
TDAScript Class Members
Class
TDAScript
Syntax
procedure BreakExec; virtual;
Remarks
Call the BreakExec method to stop script execution.
5.7.1.1.3.2 ErrorOffset Method
Used to get the offset of the statement if the Execute method raised an exception.
Class
TDAScript
Syntax
function ErrorOffset: Int64;
Return Value
offset of an error.
Remarks
Call the ErrorOffset method to get the offset of the statement if the Execute method raised an
exception.
© 2018 Devart
Reference 192
See Also
OnError
Executes a script.
Class
TDAScript
Syntax
procedure Execute; virtual;
Remarks
Call the Execute method to execute a script. If PostgreSQL raises an error, the OnError event
occurs.
See Also
ExecuteNext
OnError
ErrorOffset
Class
TDAScript
Syntax
procedure ExecuteFile(const FileName: string);
Parameters
FileName
Holds the file name.
Remarks
Call the ExecuteFile method to execute SQL statements contained in a file. Script doesn't
load full content into memory. Reading and execution is performed by blocks of 64k size.
© 2018 Devart
193 PostgreSQL Data Access Components
Class
TDAScript
Syntax
function ExecuteNext: boolean; virtual;
Return Value
True, if there are any statements left in the script, False otherwise.
Remarks
Use the ExecuteNext method to execute the next statement in the script statement and stop.
If PostgreSQL raises an error, the OnError event occurs.
See Also
Execute
OnError
ErrorOffset
Class
TDAScript
Syntax
procedure ExecuteStream(Stream: TStream);
Parameters
Stream
Holds the stream object from which the statements will be executed.
Remarks
Call the ExecuteStream method to execute SQL statements contained in a stream object.
Reading from the stream and execution is performed by blocks of 64k size.
© 2018 Devart
Reference 194
Class
TDAScript
Syntax
function MacroByName(Name: string): TMacro;
Parameters
Name
Holds the name of the Macro to search for.
Return Value
the Macro, if a match was found.
Remarks
Call the MacroByName method to find a Macro with the name passed in Name. If a match
was found, MacroByName returns the Macro. Otherwise, an exception is raised. Use this
method rather than a direct reference to the Items property to avoid depending on the order of
the entries.
To locate a parameter by name without raising an exception if the parameter is not found, use
the FindMacro method.
To assign the value of macro use the TMacro.Value property.
See Also
TMacro
Macros
M:Devart.Dac.TDAScript.FindMacro(System.String)
5.7.1.1.4 Events
Published
Name Description
AfterExecute Occurs after a SQL script execution.
© 2018 Devart
195 PostgreSQL Data Access Components
See Also
TDAScript Class
TDAScript Class Members
Class
TDAScript
Syntax
property AfterExecute: TAfterStatementExecuteEvent;
Remarks
Occurs after a SQL script has been executed.
See Also
Execute
Occurs when taking a specific action before executing the current SQL statement is needed.
Class
TDAScript
Syntax
property BeforeExecute: TBeforeStatementExecuteEvent;
Remarks
Write the BeforeExecute event handler to take specific action before executing the current
SQL statement. SQL holds text of the current SQL statement. Write SQL to change the
statement that will be executed. Set Omit to True to skip statement execution.
© 2018 Devart
Reference 196
Class
TDAScript
Syntax
property OnError: TOnErrorEvent;
Remarks
Occurs when PostgreSQL raises an error.
Action indicates the action to take when the OnError handler exits. On entry into the handler,
Action is always set to eaFail.
See Also
ErrorOffset
This class has attributes and methods for controlling single SQL statement of a script.
For a list of all members of this type, see TDAStatement members.
Unit
DAScript
Syntax
TDAStatement = class(TCollectionItem);
Remarks
TDAScript contains SQL statements, represented as TDAStatement objects. The
TDAStatement class has attributes and methods for controlling single SQL statement of a
script.
See Also
TDAScript
TDAStatements
© 2018 Devart
197 PostgreSQL Data Access Components
5.7.1.2.1 Members
Properties
Name Description
EndLine Used to determine the number of the last
statement line in a script.
Methods
Name Description
Execute Executes a statement.
5.7.1.2.2 Properties
© 2018 Devart
Reference 198
Public
Name Description
EndLine Used to determine the number of the last
statement line in a script.
See Also
TDAStatement Class
TDAStatement Class Members
Class
TDAStatement
Syntax
property EndLine: integer;
© 2018 Devart
199 PostgreSQL Data Access Components
Remarks
Use the EndLine property to determine the number of the last statement line in a script.
5.7.1.2.2.2 EndOffset Property
Class
TDAStatement
Syntax
property EndOffset: integer;
Remarks
Use the EndOffset property to get the offset in the last line of the statement.
5.7.1.2.2.3 EndPos Property
Class
TDAStatement
Syntax
property EndPos: integer;
Remarks
Use the EndPos property to get the end position of the statement (the position of the last
character in the statement) in a script.
5.7.1.2.2.4 Omit Property
Class
TDAStatement
Syntax
property Omit: boolean;
© 2018 Devart
Reference 200
Remarks
Set the Omit property to True to avoid execution of a statement.
5.7.1.2.2.5 Params Property
Class
TDAStatement
Syntax
property Params: TDAParams;
Remarks
Contains parameters for an SQL statement.
Access Params at runtime to view and set parameter names, values, and data types
dynamically. Params is a zero-based array of parameter records. Index specifies the array
element to access.
See Also
TDAParam
Used to determine the TDAScript object the SQL Statement belongs to.
Class
TDAStatement
Syntax
property Script: TDAScript;
Remarks
Use the Script property to determine the TDAScript object the SQL Statement belongs to.
5.7.1.2.2.7 SQL Property
Class
© 2018 Devart
201 PostgreSQL Data Access Components
TDAStatement
Syntax
property SQL: string;
Remarks
Use the SQL property to get or set the text of an SQL statement.
5.7.1.2.2.8 StartLine Property
Class
TDAStatement
Syntax
property StartLine: integer;
Remarks
Use the StartLine property to determine the number of the first statement line in a script.
5.7.1.2.2.9 StartOffset Property
Class
TDAStatement
Syntax
property StartOffset: integer;
Remarks
Use the StartOffset property to get the offset in the first line of a statement.
5.7.1.2.2.10 StartPos Property
Class
TDAStatement
© 2018 Devart
Reference 202
Syntax
property StartPos: integer;
Remarks
Use the StartPos property to get the start position of the statement (the position of the first
statement character) in a script.
5.7.1.2.3 Methods
Public
Name Description
Execute Executes a statement.
See Also
TDAStatement Class
TDAStatement Class Members
Executes a statement.
Class
TDAStatement
Syntax
procedure Execute;
Remarks
Use the Execute method to execute a statement.
© 2018 Devart
203 PostgreSQL Data Access Components
Unit
DAScript
Syntax
TDAStatements = class(TCollection);
Remarks
Each TDAStatements holds a collection of TDAStatement objects. TDAStatements maintains
an index of the statements in its Items array. The Count property contains the number of
statements in the collection. Use TDAStatements class to manipulate script SQL statements.
See Also
TDAScript
TDAStatement
5.7.1.3.1 Members
Properties
Name Description
Items Used to access separate script statements.
5.7.1.3.2 Properties
Public
Name Description
Items Used to access separate script statements.
See Also
TDAStatements Class
© 2018 Devart
Reference 204
Class
TDAStatements
Syntax
property Items[Index: Integer]: TDAStatement; default;
Parameters
Index
Holds the index value.
Remarks
Use the Items property to access individual script statements. The value of the Index
parameter corresponds to the Index property of TDAStatement.
See Also
TDAStatement
5.7.2 Types
Types in the DAScript unit.
Types
Name Description
TAfterStatementExecuteEvent This type is used for the TDAScript.AfterExecute
event.
Unit
© 2018 Devart
205 PostgreSQL Data Access Components
DAScript
Syntax
TAfterStatementExecuteEvent = procedure (Sender: TObject; SQL:
string) of object;
Parameters
Sender
An object that raised the event.
SQL
Holds the passed SQL statement.
5.7.2.2 TBeforeStatementExecuteEvent Procedure Reference
Unit
DAScript
Syntax
TBeforeStatementExecuteEvent = procedure (Sender: TObject; var
SQL: string; var Omit: boolean) of object;
Parameters
Sender
An object that raised the event.
SQL
Holds the passed SQL statement.
Omit
True, if the statement execution should be skipped.
5.7.2.3 TOnErrorEvent Procedure Reference
Unit
DAScript
Syntax
TOnErrorEvent = procedure (Sender: TObject; E: Exception; SQL:
string; var Action: TErrorAction) of object;
© 2018 Devart
Reference 206
Parameters
Sender
An object that raised the event.
E
The error code.
SQL
Holds the passed SQL statement.
Action
The action to take when the OnError handler exits.
5.7.3 Enumerations
Enumerations in the DAScript unit.
Enumerations
Name Description
TErrorAction Indicates the action to take when the OnError
handler exits.
Unit
DAScript
Syntax
TErrorAction = (eaAbort, eaFail, eaException, eaContinue);
Values
Value Meaning
eaAbort Abort execution without displaying an error message.
eaContinue Continue execution.
eaException In Delphi 6 and higher exception is handled by the
Application.HandleException method.
eaFail Abort execution and display an error message.
© 2018 Devart
207 PostgreSQL Data Access Components
5.8 DASQLMonitor
This unit contains the base class for the TPgSQLMonitor component.
Classes
Name Description
A base class that introduces properties and
TCustomDASQLMonitor methods to monitor dynamic SQL execution in
database applications interactively.
TDBMonitorOptions This class holds options for dbMonitor.
Types
Name Description
TDATraceFlags Represents the set of TDATraceFlag.
Enumerations
Name Description
Use TraceFlags to specify which database
TDATraceFlag operations the monitor should track in an
application at runtime.
TMonitorOption Used to define where information from
SQLMonitor will be dispalyed.
5.8.1 Classes
Classes in the DASQLMonitor unit.
Classes
Name Description
© 2018 Devart
Reference 208
A base class that introduces properties and methods to monitor dynamic SQL execution in
database applications interactively.
For a list of all members of this type, see TCustomDASQLMonitor members.
Unit
DASQLMonitor
Syntax
TCustomDASQLMonitor = class(TComponent);
Remarks
TCustomDASQLMonitor is a base class that introduces properties and methods to monitor
dynamic SQL execution in database applications interactively. TCustomDASQLMonitor
provides two ways of displaying debug information. It monitors either by dialog window or by
Borland's proprietary SQL Monitor. Furthermore to receive debug information use the
TCustomDASQLMonitor.OnSQL event.
In applications use descendants of TCustomDASQLMonitor.
5.8.1.1.1 Members
Properties
Name Description
Active Used to activate monitoring of SQL.
© 2018 Devart
209 PostgreSQL Data Access Components
Events
Name Description
OnSQL Occurs when tracing of SQL activity on database
components is needed.
5.8.1.1.2 Properties
Public
Name Description
See Also
TCustomDASQLMonitor Class
TCustomDASQLMonitor Class Members
Class
TCustomDASQLMonitor
Syntax
© 2018 Devart
Reference 210
Remarks
Set the Active property to True to activate monitoring of SQL.
See Also
OnSQL
Class
TCustomDASQLMonitor
Syntax
property DBMonitorOptions: TDBMonitorOptions;
Remarks
Use DBMonitorOptions to set options for dbMonitor.
5.8.1.1.2.3 Options Property
Class
TCustomDASQLMonitor
Syntax
property Options: TMonitorOptions default [moDialog,
moSQLMonitor, moDBMonitor, moCustom];
Remarks
Set Options to include the desired properties for TCustomDASQLMonitor.
See Also
OnSQL
© 2018 Devart
211 PostgreSQL Data Access Components
Used to specify which database operations the monitor should track in an application at
runtime.
Class
TCustomDASQLMonitor
Syntax
property TraceFlags: TDATraceFlags default [tfQPrepare,
tfQExecute, tfError, tfConnect, tfTransact, tfParams, tfMisc];
Remarks
Use the TraceFlags property to specify which database operations the monitor should track in
an application at runtime.
See Also
OnSQL
5.8.1.1.3 Events
Public
Name Description
OnSQL Occurs when tracing of SQL activity on database
components is needed.
See Also
TCustomDASQLMonitor Class
TCustomDASQLMonitor Class Members
Class
TCustomDASQLMonitor
© 2018 Devart
Reference 212
Syntax
property OnSQL: TOnSQLEvent;
Remarks
Write the OnSQL event handler to let an application trace SQL activity on database
components. The Text parameter holds the detected SQL statement. Use the Flag parameter
to make selective processing of SQL in the handler body.
See Also
TraceFlags
Unit
DASQLMonitor
Syntax
TDBMonitorOptions = class(TPersistent);
5.8.1.2.1 Members
Properties
Name Description
Host Used to set the host name or IP address of the
computer where dbMonitor application runs.
© 2018 Devart
213 PostgreSQL Data Access Components
5.8.1.2.2 Properties
Published
Name Description
See Also
TDBMonitorOptions Class
TDBMonitorOptions Class Members
Used to set the host name or IP address of the computer where dbMonitor application runs.
Class
TDBMonitorOptions
Syntax
property Host: string;
Remarks
Use the Host property to set the host name or IP address of the computer where dbMonitor
application runs.
dbMonitor supports remote monitoring. You can run dbMonitor on a different computer than
monitored application runs. In this case you need to set the Host property to the
corresponding computer name.
© 2018 Devart
Reference 214
Class
TDBMonitorOptions
Syntax
property Port: integer default DBMonitorPort;
Remarks
Use the Port property to set the port number for connecting to dbMonitor.
5.8.1.2.2.3 ReconnectTimeout Property
Used to set the minimum time that should be spent before reconnecting to dbMonitor is
allowed.
Class
TDBMonitorOptions
Syntax
property ReconnectTimeout: integer default
DefaultReconnectTimeout;
Remarks
Use the ReconnectTimeout property to set the minimum time (in milliseconds) that should be
spent before allowing reconnecting to dbMonitor. If an error occurs when the component
sends an event to dbMonitor (dbMonitor is not running), next events are ignored and the
component does not restore the connection until ReconnectTimeout is over.
5.8.1.2.2.4 SendTimeout Property
Class
TDBMonitorOptions
Syntax
property SendTimeout: integer default DefaultSendTimeout;
© 2018 Devart
215 PostgreSQL Data Access Components
Remarks
Use the SendTimeout property to set timeout (in milliseconds) for sending events to
dbMonitor. If dbMonitor does not respond in the specified timeout, event is ignored.
5.8.2 Types
Types in the DASQLMonitor unit.
Types
Name Description
TDATraceFlags Represents the set of TDATraceFlag.
Unit
DASQLMonitor
Syntax
TDATraceFlags = set of TDATraceFlag;
Unit
DASQLMonitor
Syntax
TMonitorOptions = set of TMonitorOption;
© 2018 Devart
Reference 216
Unit
DASQLMonitor
Syntax
TOnSQLEvent = procedure (Sender: TObject; Text: string; Flag:
TDATraceFlag) of object;
Parameters
Sender
An object that raised the event.
Text
Holds the detected SQL statement.
Flag
Use the Flag parameter to make selective processing of SQL in the handler body.
5.8.3 Enumerations
Enumerations in the DASQLMonitor unit.
Enumerations
Name Description
Use TraceFlags to specify which database
TDATraceFlag operations the monitor should track in an
application at runtime.
TMonitorOption Used to define where information from
SQLMonitor will be dispalyed.
Use TraceFlags to specify which database operations the monitor should track in an
application at runtime.
Unit
DASQLMonitor
Syntax
TDATraceFlag = (tfQPrepare, tfQExecute, tfQFetch, tfError, tfStmt,
© 2018 Devart
217 PostgreSQL Data Access Components
Values
Value Meaning
tfBlob This option is declared for future use.
tfConnect Establishing a connection.
tfError Errors of query execution.
tfMisc This option is declared for future use.
tfObjDestroy Destroying of components.
tfParams Representing parameter values for tfQPrepare and tfQExecute.
tfPool Connection pool operations.
tfQExecute Execution of the queries.
tfQFetch This option is declared for future use.
tfQPrepare Queries preparation.
tfService This option is declared for future use.
tfStmt This option is declared for future use.
tfTransact Processing transactions.
Unit
DASQLMonitor
Syntax
TMonitorOption = (moDialog, moSQLMonitor, moDBMonitor, moCustom,
moHandled);
Values
Value Meaning
Monitoring of SQL for individual components is allowed. Set
moCustom Debug properties in SQL-related components to True to let
TCustomDASQLMonitor instance to monitor their behavior. Has
effect when moDialog is included.
moDBMonitor Debug information is displayed in DBMonitor.
moDialog Debug information is displayed in debug window.
© 2018 Devart
Reference 218
5.9 DBAccess
This unit contains base classes for most of the components.
Classes
Name Description
EDAError A base class for exceptions that are raised when
an error occurs on the server side.
© 2018 Devart
219 PostgreSQL Data Access Components
Types
Name Description
This type is used for the
TAfterExecuteEvent TCustomDADataSet.AfterExecute and
TCustomDASQL.AfterExecute events.
TAfterFetchEvent This type is used for the
TCustomDADataSet.AfterFetch event.
© 2018 Devart
Reference 220
Enumerations
Name Description
TLabelSet Sets the languauge of labels in the connect dialog.
Variables
Name Description
After assigning SQL text and modifying it by
BaseSQLOldBehavior AddWhere, DeleteWhere, and SetOrderBy, all
subsequent changes of the SQL property will not
be reflected in the BaseSQL property.
ChangeCursor When set to True allows data access components
to change screen cursor for the execution time.
The value of the TCustomDADataSet.BaseSQL
property is used to complete the refresh SQL
SQLGeneratorCompatibility statement, if the manually assigned
TCustomDAUpdateSQL.RefreshSQL property
contains only WHERE clause.
5.9.1 Classes
Classes in the DBAccess unit.
Classes
Name Description
© 2018 Devart
221 PostgreSQL Data Access Components
© 2018 Devart
Reference 222
A base class for exceptions that are raised when an error occurs on the server side.
For a list of all members of this type, see EDAError members.
Unit
DBAccess
Syntax
EDAError = class(EDatabaseError);
Remarks
EDAError is a base class for exceptions that are raised when an error occurs on the server
side.
5.9.1.1.1 Members
Properties
Name Description
Component Contains the component that caused the error.
© 2018 Devart
223 PostgreSQL Data Access Components
5.9.1.1.2 Properties
Public
Name Description
Component Contains the component that caused the error.
See Also
EDAError Class
EDAError Class Members
Class
EDAError
Syntax
property Component: TObject;
Remarks
The Component property contains the component that caused the error.
5.9.1.1.2.2 ErrorCode Property
Class
EDAError
Syntax
property ErrorCode: integer;
Remarks
© 2018 Devart
Reference 224
Use the ErrorCode property to determine the error code returned by PostgreSQL. This value
is always positive.
Unit
DBAccess
Syntax
TCRDataSource = class(TDataSource);
Remarks
TCRDataSource provides an interface between a DAC dataset components and data-aware
controls on a form.
TCRDataSource inherits its functionality directly from the TDataSource component.
At design time assign individual data-aware components' DataSource properties from their
drop-down listboxes.
5.9.1.2.1 Members
Unit
DBAccess
Syntax
TCustomConnectDialog = class(TComponent);
Remarks
TCustomConnectDialog is a base class for the connect dialog components. It provides
functionality to show a dialog box where user can edit username, password and server name
before connecting to a database. You can customize captions of buttons and labels by their
© 2018 Devart
225 PostgreSQL Data Access Components
properties.
5.9.1.3.1 Members
Properties
Name Description
CancelButton Used to specify the label for the Cancel button.
Methods
Name Description
Displays the connect dialog and calls the
Execute connection's Connect method when user clicks the
Connect button.
© 2018 Devart
Reference 226
5.9.1.3.2 Properties
Public
Name Description
CancelButton Used to specify the label for the Cancel button.
See Also
© 2018 Devart
227 PostgreSQL Data Access Components
TCustomConnectDialog Class
TCustomConnectDialog Class Members
Class
TCustomConnectDialog
Syntax
property CancelButton: string;
Remarks
Use the CancelButton property to specify the label for the Cancel button.
5.9.1.3.2.2 Caption Property
Class
TCustomConnectDialog
Syntax
property Caption: string;
Remarks
Use the Caption property to set the caption of dialog box.
5.9.1.3.2.3 ConnectButton Property
Class
TCustomConnectDialog
Syntax
property ConnectButton: string;
Remarks
© 2018 Devart
Reference 228
Use the ConnectButton property to specify the label for the Connect button.
5.9.1.3.2.4 DialogClass Property
Used to specify the class of the form that will be displayed to enter login information.
Class
TCustomConnectDialog
Syntax
property DialogClass: string;
Remarks
Use the DialogClass property to specify the class of the form that will be displayed to enter
login information. When this property is blank, TCustomConnectDialog uses the default form -
TConnectForm. You can write your own login form to enter login information and assign its
class name to the DialogClass property. Each login form must have ConnectDialog:
TCustomConnectDialog published property to access connection information. For details see
the implementation of the connect form which sources are in the Lib subdirectory of the
PgDAC installation directory.
See Also
GetServerList
Class
TCustomConnectDialog
Syntax
property LabelSet: TLabelSet default lsEnglish;
Remarks
Use the LabelSet property to set the language of labels and buttons captions.
The default value is lsEnglish.
© 2018 Devart
229 PostgreSQL Data Access Components
Class
TCustomConnectDialog
Syntax
property PasswordLabel: string;
Remarks
Use the PasswordLabel property to specify a prompt for password edit.
5.9.1.3.2.7 Retries Property
Class
TCustomConnectDialog
Syntax
property Retries: word default 3;
Remarks
Use the Retries property to determine the number of retries of failed connections.
5.9.1.3.2.8 SavePassw ord Property
Class
TCustomConnectDialog
Syntax
property SavePassword: boolean default False;
Remarks
If True, and the Password property of the connection instance is assigned, the password in
ConnectDialog is displayed in asterisks.
© 2018 Devart
Reference 230
Class
TCustomConnectDialog
Syntax
property ServerLabel: string;
Remarks
Use the ServerLabel property to specify a prompt for the server name edit.
5.9.1.3.2.10 StoreLogInfo Property
Used to specify whether the login information should be kept in system registry after a
connection was established.
Class
TCustomConnectDialog
Syntax
property StoreLogInfo: boolean default True;
Remarks
Use the StoreLogInfo property to specify whether to keep login information in system registry
after a connection was established using provided username, password and servername.
Set this property to True to store login information.
The default value is True.
5.9.1.3.2.11 UsernameLabel Property
Class
TCustomConnectDialog
Syntax
property UsernameLabel: string;
© 2018 Devart
231 PostgreSQL Data Access Components
Remarks
Use the UsernameLabel property to specify a prompt for username edit.
5.9.1.3.3 Methods
Public
Name Description
Displays the connect dialog and calls the
Execute connection's Connect method when user clicks the
Connect button.
GetServerList Retrieves a list of available server names.
See Also
TCustomConnectDialog Class
TCustomConnectDialog Class Members
Displays the connect dialog and calls the connection's Connect method when user clicks the
Connect button.
Class
TCustomConnectDialog
Syntax
function Execute: boolean; virtual;
Return Value
True, if connected.
Remarks
Displays the connect dialog and calls the connection's Connect method when user clicks the
Connect button. Returns True if connected. If user clicks Cancel, Execute returns False.
In the case of failed connection Execute offers to connect repeat Retries times.
© 2018 Devart
Reference 232
Class
TCustomConnectDialog
Syntax
procedure GetServerList(List: TStrings); virtual;
Parameters
List
Holds a list of available server names.
Remarks
Call the GetServerList method to retrieve a list of available server names. It is particularly
relevant for writing custom login form.
See Also
DialogClass
Unit
DBAccess
Syntax
TCustomDAConnection = class(TCustomConnection);
Remarks
TCustomDAConnection is a base class for components that establish connection with
database, provide customised login support, and perform transaction control.
Do not create instances of TCustomDAConnection. To add a component that represents a
connection to a source of data, use descendants of the TCustomDAConnection class.
© 2018 Devart
233 PostgreSQL Data Access Components
5.9.1.4.1 Members
Properties
Name Description
ConnectDialog Allows to link a TCustomConnectDialog
component.
Methods
Name Description
ApplyUpdates Overloaded. Applies changes in datasets.
© 2018 Devart
Reference 234
Events
© 2018 Devart
235 PostgreSQL Data Access Components
Name Description
OnConnectionLost This event occurs when connection was lost.
Public
Name Description
ConnectDialog Allows to link a TCustomConnectDialog
component.
© 2018 Devart
Reference 236
See Also
TCustomDAConnection Class
TCustomDAConnection Class Members
Class
TCustomDAConnection
Syntax
property ConnectDialog: TCustomConnectDialog;
Remarks
Use the ConnectDialog property to assign to connection a TCustomConnectDialog
component.
See Also
TCustomConnectDialog
Used to specify the connection information, such as: UserName, Password, Server, etc.
Class
TCustomDAConnection
Syntax
property ConnectString: string stored False;
Remarks
PgDAC recognizes an ODBC-like syntax in provider string property values. Within the string,
elements are delimited by using a semicolon. Each element consists of a keyword, an equal
sign character, and the value passed on initialization. For example:
Server=London1;User ID=nancyd
Connection parameters
© 2018 Devart
237 PostgreSQL Data Access Components
© 2018 Devart
Reference 238
See Also
Password
Username
Server
Connect
Class
TCustomDAConnection
Syntax
property ConvertEOL: boolean default False;
Remarks
Affects the line break behavior in string fields and parameters. When fetching strings
(including the TEXT fields) with ConvertEOL = True, dataset converts their line breaks from
the LF to CRLF form. And when posting strings to server with ConvertEOL turned on, their
line breaks are converted from CRLF to LF form. By default, strings are not converted.
5.9.1.4.2.4 InTransaction Property
Class
TCustomDAConnection
Syntax
property InTransaction: boolean;
Remarks
Examine the InTransaction property at runtime to determine whether user transaction is
© 2018 Devart
239 PostgreSQL Data Access Components
currently in progress. In other words InTransaction is set to True when user explicitly calls
StartTransaction. Calling Commit or Rollback sets InTransaction to False. The value of the
InTransaction property cannot be changed directly.
See Also
StartTransaction
Commit
Rollback
Specifies whether a login dialog appears immediately before opening a new connection.
Class
TCustomDAConnection
Syntax
property LoginPrompt default DefValLoginPrompt;
Remarks
Specifies whether a login dialog appears immediately before opening a new connection. If
ConnectDialog is not specified, the default connect dialog will be shown. The connect dialog
will appear only if the PgDacVcl unit appears to the uses clause.
5.9.1.4.2.6 Options Property
Class
TCustomDAConnection
Syntax
property Options: TDAConnectionOptions;
Remarks
Set the properties of Options to specify the behaviour of the connection.
Descriptions of all options are in the table below.
© 2018 Devart
Reference 240
See Also
Disconnected Mode
Working in an Unstable Network
Class
TCustomDAConnection
Syntax
property Password: string stored False;
Remarks
Use the Password property to supply a password to handle server's request for a login.
Warning: Storing hard-coded user name and password entries as property values or in code
for the OnLogin event handler can compromise server security.
See Also
Username
Server
© 2018 Devart
241 PostgreSQL Data Access Components
Class
TCustomDAConnection
Syntax
property Pooling: boolean default DefValPooling;
Remarks
Normally, when TCustomDAConnection establishes connection with the server it takes
server memory and time resources for allocating new server connection. For example,
pooling can be very useful when using disconnect mode. If an application has wide user
activity that forces many connect/disconnect operations, it may spend a lot of time on
creating connection and sending requests to the server. TCustomDAConnection has
software pool which stores open connections with identical parameters.
Connection pool uses separate thread that validates the pool every 30 seconds. Pool
validation consists of checking each connection in the pool. If a connection is broken due to a
network problem or another reason, it is deleted from the pool. The validation procedure
removes also connections that are not used for a long time even if they are valid from the
pool.
Set Pooling to True to enable pooling. Specify correct values for PoolingOptions. Two
connections belong to the same pool if they have identical values for the parameters:
MinPoolSize, MaxPoolSize, Validate, ConnectionLifeTime
Note: Using Pooling := True can cause errors with working with temporary tables.
See Also
Username
Password
PoolingOptions
Connection Pooling
Class
TCustomDAConnection
© 2018 Devart
Reference 242
Syntax
property PoolingOptions: TPoolingOptions;
Remarks
Set the properties of PoolingOptions to specify the behaviour of connection pool.
Descriptions of all options are in the table below.
See Also
Pooling
Class
TCustomDAConnection
Syntax
property Server: string;
Remarks
Use the Server property to supply server name to handle server's request for a login.
See Also
Username
Password
© 2018 Devart
243 PostgreSQL Data Access Components
Class
TCustomDAConnection
Syntax
property Username: string;
Remarks
Use the Username property to supply a user name to handle server's request for login. If this
property is not set, PgDAC tries to connect with the user name.
Warning: Storing hard-coded user name and password entries as property values or in code
for the OnLogin event handler can compromise server security.
See Also
Password
Server
5.9.1.4.3 Methods
Public
Name Description
ApplyUpdates Overloaded. Applies changes in datasets.
© 2018 Devart
Reference 244
See Also
TCustomDAConnection Class
TCustomDAConnection Class Members
Class
TCustomDAConnection
© 2018 Devart
245 PostgreSQL Data Access Components
Overload List
Name Description
ApplyUpdates Applies changes from all active datasets.
ApplyUpdates(const DataSets: array of Applies changes from the specified
TCustomDADataSet) datasets.
Class
TCustomDAConnection
Syntax
procedure ApplyUpdates; overload; virtual;
Remarks
Call the ApplyUpdates method to write all pending cached updates from all active datasets
attached to this connection to a database or from specific datasets. The ApplyUpdates
method passes cached data to the database for storage, takes care of committing or rolling
back transactions, and clearing the cache when the operation is successful.
Using ApplyUpdates for connection is a preferred method of updating datasets rather than
calling each individual dataset's ApplyUpdates method.
See Also
TMemDataSet.CachedUpdates
TMemDataSet.ApplyUpdates
Class
TCustomDAConnection
Syntax
procedure ApplyUpdates(const DataSets: array of
TCustomDADataSet); overload; virtual;
Parameters
DataSets
A list of datasets changes in which are to be applied.
© 2018 Devart
Reference 246
Remarks
Call the ApplyUpdates method to write all pending cached updates from the specified
datasets. The ApplyUpdates method passes cached data to the database for storage, takes
care of committing or rolling back transactions and clearing the cache when operation is
successful.
Using ApplyUpdates for connection is a preferred method of updating datasets rather than
calling each individual dataset's ApplyUpdates method.
5.9.1.4.3.2 Commit Method
Class
TCustomDAConnection
Syntax
procedure Commit; virtual;
Remarks
Call the Commit method to commit current transaction. On commit server writes
permanently all pending data updates associated with the current transaction to the database
and then ends the transaction. The current transaction is the last transaction started by
calling StartTransaction.
See Also
Rollback
StartTransaction
TCustomPgDataSet.FetchAll
Class
TCustomDAConnection
Syntax
procedure Connect; overload;procedure Connect(const
ConnectString: string); overload;
© 2018 Devart
247 PostgreSQL Data Access Components
Remarks
Call the Connect method to establish a connection to the server. Connect sets the Connected
property to True. If LoginPrompt is True, Connect prompts user for login information as
required by the server, or otherwise tries to establish a connection using values provided in
the Username, Password, and Server properties.
See Also
Disconnect
Username
Password
Server
ConnectDialog
Class
TCustomDAConnection
Syntax
function CreateSQL: TCustomDASQL; virtual;
Return Value
A new instance of the class.
Remarks
Call the CreateSQL to return a new instance of the TCustomDASQL class and associates it
with this connection object. In the descendant classes this method should be overridden to
create an appropriate descendant of the TCustomDASQL component.
5.9.1.4.3.5 Disconnect Method
Performs disconnect.
Class
TCustomDAConnection
Syntax
© 2018 Devart
Reference 248
procedure Disconnect;
Remarks
Call the Disconnect method to drop a connection to database. Before the connection
component is deactivated, all associated datasets are closed. Calling Disconnect is similar to
setting the Connected property to False.
In most cases, closing a connection frees system resources allocated to the connection.
If user transaction is active, e.g. the InTransaction flag is set, calling to Disconnect the current
user transaction.
Note: If a previously active connection is closed and then reopened, any associated datasets
must be individually reopened; reopening the connection does not automatically reopen
associated datasets.
See Also
Connect
Allows to execute stored procedure or function providing its name and parameters.
Class
TCustomDAConnection
Syntax
function ExecProc(const Name: string; const Params: array of
variant): variant; virtual;
Parameters
Name
Holds the name of the stored procedure or function.
Params
Holds the parameters of the stored procedure or function.
Return Value
the result of the stored procedure.
Remarks
Allows to execute stored procedure or function providing its name and parameters.
Use the following Name value syntax for executing specific overloaded routine:
"StoredProcName:1" or "StoredProcName:5". The first example executes the first overloaded
© 2018 Devart
249 PostgreSQL Data Access Components
stored procedure, while the second example executes the fifth overloaded procedure.
Assign parameters' values to the Params array in exactly the same order and number as they
appear in the stored procedure declaration. Out parameters of the procedure can be
accessed with the ParamByName procedure.
If the value of an input parameter was not included to the Params array, parameter default
value is taken. Only parameters at the end of the list can be unincluded to the Params array. If
the parameter has no default value, the NULL value is sent.
Note: Stored functions unlike stored procedures return result values that are obtained
internally through the RESULT parameter. You will no longer have to provide anonymous
value in the Params array to describe the result of the function. The stored function result is
obtained from the Params[0] indexed property or with the ParamByName('RESULT') method
call.
For further examples of parameter usage see ExecSQL, ExecSQLEx.
Example
For example, having stored function declaration presented in Example 1), you may execute it
and retrieve its result with commands presented in Example 2):
Example 1)
CREATE procedure MY_SUM (
A INTEGER,
B INTEGER)
RETURNS (
RESULT INTEGER)
as
begin
Result = a + b;
end;
Example 2)
Label1.Caption:= MyPgConnection1.ExecProc('My_Sum', [10, 20]);
Label2.Caption:= MyPgConnection1.ParamByName('Result').AsString;
See Also
ExecProcEx
ExecSQL
ExecSQLEx
Class
TCustomDAConnection
© 2018 Devart
Reference 250
Syntax
function ExecProcEx(const Name: string; const Params: array of
variant): variant; virtual;
Parameters
Name
Holds the stored procedure name.
Params
Holds an array of pairs of parameters' names and values.
Return Value
the result of the stored procedure.
Remarks
Allows to execute a stored procedure or function. Provide the stored procedure name and its
parameters to the call of ExecProcEx.
Use the following Name value syntax for executing specific overloaded routine:
"StoredProcName:1" or "StoredProcName:5". The first example executes the first overloaded
stored procedure, while the second example executes the fifth overloaded procedure.
Assign pairs of parameters' names and values to a Params array so that every name comes
before its corresponding value when an array is being indexed.
Out parameters of the procedure can be accessed with the ParamByName procedure. If the
value for an input parameter was not included to the Params array, the parameter default
value is taken. If the parameter has no default value, the NULL value is sent.
Note: Stored functions unlike stored procedures return result values that are obtained
internally through the RESULT parameter. You will no longer have to provide anonymous
value in the Params array to describe the result of the function. Stored function result is
obtained from the Params[0] indexed property or with the ParamByName('RESULT') method
call.
For an example of parameters usage see ExecSQLEx.
Example
If you have some stored procedure accepting four parameters, and you want to provide
values only for the first and fourth parameters, you should call ExecProcEx in the following
way:
See Also
ExecSQL
© 2018 Devart
251 PostgreSQL Data Access Components
ExecSQLEx
ExecProc
Class
TCustomDAConnection
Syntax
function ExecSQL(const Text: string): variant;
overload;function ExecSQL(const Text: string; const Params:
array of variant): variant; overload; virtual;
Parameters
Text
a SQL statement to be executed.
Params
Array of parameter values arranged in the same order as they appear in SQL statement.
Return Value
Out parameter with the name Result will hold the result of function having data type dtString.
Otherwise returns Null.
Remarks
Use the ExecSQL method to execute any SQL statement outside the TCustomDADataSet or
TCustomDASQL components. Supply the Params array with the values of parameters
arranged in the same order as they appear in a SQL statement which itself is passed to the
Text string parameter.
See Also
ExecSQLEx
ExecProc
Class
TCustomDAConnection
© 2018 Devart
Reference 252
Syntax
function ExecSQLEx(const Text: string; const Params: array of
variant): variant; virtual;
Parameters
Text
a SQL statement to be executed.
Params
Array of parameter values arranged in the same order as they appear in SQL statement.
Return Value
Out parameter with the name Result will hold the result of a function having data type
dtString. Otherwise returns Null.
Remarks
Call the ExecSQLEx method to execute any SQL statement outside the TQuery or TSQL
components. Supply the Params array with values arranged in pairs of parameter name and
its value. This way each parameter name in the array is found on even index values whereas
parameter value is on odd index value but right after its parameter name. The parameter pairs
must be arranged according to their occurrence in a SQL statement which itself is passed in
the Text string parameter.
The Params array must contain all IN and OUT parameters defined in the SQL statement.
For OUT parameters provide any values of valid types so that they are explicitly defined
before call to the ExecSQLEx method.
Out parameter with the name Result will hold the result of a function having data type dtString.
If neither of the parameters in the Text statement is named Result, ExecSQLEx will return
Null.
To get the values of OUT parameters use the ParamByName function.
Example
PgConnection.ExecSQLEx('begin :A:= :B + :C; end;',
['A', 0, 'B', 5, 'C', 3]);
A:= PgConnection.ParamByName('A').AsInteger;
See Also
ExecSQL
© 2018 Devart
253 PostgreSQL Data Access Components
Class
TCustomDAConnection
Syntax
procedure GetDatabaseNames(List: TStrings); virtual;
Parameters
List
A TStrings descendant that will be filled with database names.
Remarks
Populates a string list with the names of databases.
Note: Any contents already in the target string list object are eliminated and overwritten by
data produced by GetDatabaseNames.
See Also
GetTableNames
GetStoredProcNames
Class
TCustomDAConnection
Syntax
procedure GetKeyFieldNames(const TableName: string; List:
TStrings); virtual;
Parameters
TableName
Holds the table name
List
The list of available key field names
Return Value
Key field name
© 2018 Devart
Reference 254
Remarks
Call the GetKeyFieldNames method to get the names of available key fields. Populates a
string list with the names of key fields in tables.
See Also
GetTableNames
GetStoredProcNames
Class
TCustomDAConnection
Syntax
procedure GetStoredProcNames(List: TStrings; AllProcs: boolean =
False); virtual;
Parameters
List
A TStrings descendant that will be filled with the names of stored procedures in the
database.
AllProcs
True, if stored procedures from all schemas or including system procudures (depending on
the server) are returned. False otherwise.
Remarks
Call the GetStoredProcNames method to get the names of available stored procedures and
functions. GetStoredProcNames populates a string list with the names of stored procs in the
database. If AllProcs = True, the procedure returns to the List parameter the names of the
stored procedures that belong to all schemas; otherwise, List will contain the names of
functions that belong to the current schema.
Note: Any contents already in the target string list object are eliminated and overwritten by
data produced by GetStoredProcNames.
See Also
GetDatabaseNames
GetTableNames
© 2018 Devart
255 PostgreSQL Data Access Components
Class
TCustomDAConnection
Syntax
procedure GetTableNames(List: TStrings; AllTables: boolean =
False; OnlyTables: boolean = False); virtual;
Parameters
List
A TStrings descendant that will be filled with table names.
AllTables
True, if procedure returns all table names including the names of system tables to the List
parameter.
OnlyTables
Remarks
Call the GetTableNames method to get the names of available tables. Populates a string list
with the names of tables in the database. If AllTables = True, procedure returns all table
names including the names of system tables to the List parameter, otherwise List will not
contain the names of system tables. If AllTables = True, the procedure returns to the List
parameter the names of the tables that belong to all schemas; otherwise, List will contain the
names of the tables that belong to the current schema.
Note: Any contents already in the target string list object are eliminated and overwritten by the
data produced by GetTableNames.
See Also
GetDatabaseNames
GetStoredProcNames
Class
TCustomDAConnection
Syntax
© 2018 Devart
Reference 256
Parameters
Msg
Message text that will be sent.
Remarks
Call the MonitorMessage method to output specified message via the
TCustomDASQLMonitor component.
See Also
TCustomDASQLMonitor
Class
TCustomDAConnection
Syntax
procedure Ping;
Remarks
The method is used for checking server connection state.
5.9.1.4.3.16 RemoveFromPool Method
Marks the connection that should not be returned to the pool after disconnect.
Class
TCustomDAConnection
Syntax
procedure RemoveFromPool;
Remarks
Call the RemoveFromPool method to mark the connection that should be deleted after
disconnect instead of returning to the connection pool.
© 2018 Devart
257 PostgreSQL Data Access Components
See Also
Pooling
PoolingOptions
Class
TCustomDAConnection
Syntax
procedure Rollback; virtual;
Remarks
Call the Rollback method to discard all updates, insertions, and deletions of data associated
with the current transaction to the database server and then end the transaction. The current
transaction is the last transaction started by calling StartTransaction.
See Also
Commit
StartTransaction
TCustomPgDataSet.FetchAll
Class
TCustomDAConnection
Syntax
procedure StartTransaction; virtual;
Remarks
Call the StartTransaction method to begin a new user transaction against the database
server. Before calling StartTransaction, an application should check the status of the
InTransaction property. If InTransaction is True, indicating that a transaction is already in
progress, a subsequent call to StartTransaction without first calling Commit or Rollback to
© 2018 Devart
Reference 258
See Also
Commit
Rollback
InTransaction
5.9.1.4.4 Events
Public
Name Description
See Also
TCustomDAConnection Class
TCustomDAConnection Class Members
Class
TCustomDAConnection
Syntax
property OnConnectionLost: TConnectionLostEvent;
Remarks
Write the OnConnectionLost event handler to process fatal errors and perform failover.
© 2018 Devart
259 PostgreSQL Data Access Components
Note: To use the OnConnectionLost event handler, you should explicitly add the MemData
unit to the 'uses' list and set the TCustomDAConnection.Options.LocalFailover property to
True.
5.9.1.4.4.2 OnError Event
Class
TCustomDAConnection
Syntax
property OnError: TDAConnectionErrorEvent;
Remarks
Write the OnError event handler to respond to errors that arise with connection. Check the E
parameter to get the error code. Set the Fail parameter to False to prevent an error dialog
from being displayed and to raise the EAbort exception to cancel current operation. The
default value of Fail is True.
Encapsulates general set of properties, events, and methods for working with data accessed
through various database engines.
For a list of all members of this type, see TCustomDADataSet members.
Unit
DBAccess
Syntax
TCustomDADataSet = class(TMemDataSet);
Remarks
TCustomDADataSet encapsulates general set of properties, events, and methods for working
with data accessed through various database engines. All database-specific features are
supported by descendants of TCustomDADataSet.
Applications should not use TCustomDADataSet objects directly.
Inheritance Hierarchy
TMemDataSet
© 2018 Devart
Reference 260
TCustomDADataSet
5.9.1.5.1 Members
Properties
Name Description
Used to return SQL text without any changes
BaseSQL performed by AddWhere, SetOrderBy, and
FilterSQL.
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
© 2018 Devart
261 PostgreSQL Data Access Components
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
© 2018 Devart
Reference 262
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
© 2018 Devart
263 PostgreSQL Data Access Components
Name Description
AddWhere Adds condition to the WHERE clause of SELECT
statement in the SQL property.
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 264
© 2018 Devart
265 PostgreSQL Data Access Components
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
© 2018 Devart
Reference 266
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute Occurs after a component has executed a query to
database.
© 2018 Devart
267 PostgreSQL Data Access Components
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.9.1.5.2 Properties
Public
Name Description
Used to return SQL text without any changes
BaseSQL performed by AddWhere, SetOrderBy, and
FilterSQL.
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
© 2018 Devart
Reference 268
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
© 2018 Devart
269 PostgreSQL Data Access Components
© 2018 Devart
Reference 270
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
See Also
TCustomDADataSet Class
TCustomDADataSet Class Members
Used to return SQL text without any changes performed by AddWhere, SetOrderBy, and
FilterSQL.
Class
TCustomDADataSet
Syntax
property BaseSQL: string;
Remarks
Use the BaseSQL property to return SQL text without any changes performed by AddWhere,
SetOrderBy, and FilterSQL, only macros are expanded. SQL text with all these changes can
be returned by FinalSQL.
See Also
FinalSQL
AddWhere
SaveSQL
SQLSaved
RestoreSQL
© 2018 Devart
271 PostgreSQL Data Access Components
Class
TCustomDADataSet
Syntax
property Conditions: TDAConditions stored False;
See Also
TDAConditions
Class
TCustomDADataSet
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify a connection object that will be used to connect to a
data store.
Set at design-time by selecting from the list of provided TCustomDAConnection or its
descendant class objects.
At runtime, link an instance of a TCustomDAConnection descendant to the Connection
property.
5.9.1.5.2.4 DataTypeMap Property
Class
TCustomDADataSet
Syntax
property DataTypeMap: TDAMapRules stored IsMapRulesStored;
© 2018 Devart
Reference 272
See Also
TDAMapRules
Used to display executing statement, all its parameters' values, and the type of parameters.
Class
TCustomDADataSet
Syntax
property Debug: boolean default False;
Remarks
Set the Debug property to True to display executing statement and all its parameters' values.
Also displays the type of parameters.
You should add the PgDacVcl unit to the uses clause of any unit in your project to make the
Debug property work.
Note: If TPgSQLMonitor is used in the project and the TPgSQLMonitor.Active property is set
to False, the debug window is not displayed.
See Also
TCustomDASQL.Debug
Used to specify the fields that correspond to the foreign key fields from MasterFields when
building master/detail relationship.
Class
TCustomDADataSet
Syntax
property DetailFields: string;
Remarks
Use the DetailFields property to specify the fields that correspond to the foreign key fields
from MasterFields when building master/detail relationship. DetailFields is a string containing
one or more field names in the detail table. Separate field names with semicolons.
© 2018 Devart
273 PostgreSQL Data Access Components
See Also
MasterFields
MasterSource
Class
TCustomDADataSet
Syntax
property Disconnected: boolean;
Remarks
Set the Disconnected property to True to keep dataset opened after connection is closed.
5.9.1.5.2.8 FetchRow s Property
Used to define the number of rows to be transferred across the network at the same time.
Class
TCustomDADataSet
Syntax
property FetchRows: integer default 25;
Remarks
The number of rows that will be transferred across the network at the same time. This
property can have a great impact on performance. So it is preferable to choose the optimal
value of the FetchRows property for each SQL statement and software/hardware
configuration experimentally.
The default value is 25.
5.9.1.5.2.9 FilterSQL Property
Used to change the WHERE clause of SELECT statement and reopen a query.
Class
© 2018 Devart
Reference 274
TCustomDADataSet
Syntax
property FilterSQL: string;
Remarks
The FilterSQL property is similar to the Filter property, but it changes the WHERE clause of
SELECT statement and reopens query. Syntax is the same to the WHERE clause.
Note: the FilterSQL property adds a value to the WHERE condition as is. If you expect this
value to be enclosed in brackets, you should bracket it explicitly.
Example
Query1.FilterSQL := 'Dept >= 20 and DName LIKE ''M%''';
See Also
AddWhere
Used to return SQL text with all changes performed by AddWhere, SetOrderBy, and
FilterSQL, and with expanded macros.
Class
TCustomDADataSet
Syntax
property FinalSQL: string;
Remarks
Use FinalSQL to return SQL text with all changes performed by AddWhere, SetOrderBy, and
FilterSQL, and with expanded macros. This is the exact statement that will be passed on to
the database server.
See Also
FinalSQL
AddWhere
SaveSQL
SQLSaved
© 2018 Devart
275 PostgreSQL Data Access Components
RestoreSQL
BaseSQL
Class
TCustomDADataSet
Syntax
property IsQuery: boolean;
Remarks
After the TCustomDADataSet component is prepared, the IsQuery property returns True if
SQL statement is a SELECT query.
Use the IsQuery property to check whether the SQL statement returns rows or not.
IsQuery is a read-only property. Reading IsQuery on unprepared dataset raises an exception.
5.9.1.5.2.12 KeyFields Property
Used to build SQL statements for the SQLDelete, SQLInsert, and SQLUpdate properties if
they were empty before updating the database.
Class
TCustomDADataSet
Syntax
property KeyFields: string;
Remarks
TCustomDADataset uses the KeyFields property to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were empty before updating the database. For
this feature KeyFields may hold a list of semicolon-delimited field names. If KeyFields is not
defined before opening dataset, TCustomDADataset .
See Also
SQLDelete
SQLInsert
SQLRefresh
© 2018 Devart
Reference 276
SQLUpdate
Used to get the number of macros associated with the Macros property.
Class
TCustomDADataSet
Syntax
property MacroCount: word;
Remarks
Use the MacroCount property to get the number of macros associated with the Macros
property.
See Also
Macros
Class
TCustomDADataSet
Syntax
property Macros: TMacros stored False;
Remarks
With the help of macros you can easily change SQL query text at design- or runtime. Marcos
extend abilities of parameters and allow to change conditions in a WHERE clause or sort
order in an ORDER BY clause. You just insert &MacroName in the SQL query text and
change value of macro in the Macro property editor at design time or call the MacroByName
function at run time. At the time of opening the query macro is replaced by its value.
Example
PgQuery.SQL:= 'SELECT * FROM Dept ORDER BY &Order';
PgQuery.MacroByName('Order').Value:= 'DeptNo';
PgQuery.Open;
© 2018 Devart
277 PostgreSQL Data Access Components
See Also
TMacro
MacroByName
Params
Used to specify the names of one or more fields that are used as foreign keys for dataset
when establishing detail/master relationship between it and the dataset specified in
MasterSource.
Class
TCustomDADataSet
Syntax
property MasterFields: string;
Remarks
Use the MasterFields property after setting the MasterSource property to specify the names of
one or more fields that are used as foreign keys for this dataset when establishing detail/
master relationship between it and the dataset specified in MasterSource.
MasterFields is a string containing one or more field names in the master table. Separate field
names with semicolons.
Each time the current record in the master table changes, the new values in these fields are
used to select corresponding records in this table for display.
Use Field Link Designer to set the values at design time after setting the MasterSource
property.
See Also
DetailFields
MasterSource
Master/Detail Relationships
Used to specify the data source component which binds current dataset to the master one.
Class
TCustomDADataSet
© 2018 Devart
Reference 278
Syntax
property MasterSource: TDataSource;
Remarks
The MasterSource property specifies the data source component which binds current dataset
to the master one.
TCustomDADataset uses MasterSource to extract foreign key fields values from the master
dataset when building master/detail relationship between two datasets. MasterSource must
point to another dataset; it cannot point to this dataset component.
When MasterSource is not nil dataset fills parameter values with corresponding field values
from the current record of the master dataset.
Note: Do not set the DataSource property when building master/detail relationships. Although
it points to the same object as the MasterSource property, it may lead to undesirable results.
See Also
MasterFields
DetailFields
Master/Detail Relationships
Class
TCustomDADataSet
Syntax
property Options: TDADataSetOptions;
Remarks
Set the properties of Options to specify the behaviour of a TCustomDADataSet object.
Descriptions of all options are in the table below.
© 2018 Devart
279 PostgreSQL Data Access Components
fields.
CompressBlobMode Used to store values of the BLOB fields in
compressed form.
Used to request default values/expressions
DefaultValues from the server and assign them to the
DefaultExpression property.
Used to get or set a delay in milliseconds
DetailDelay before refreshing detail dataset while
navigating master dataset.
Used for TCustomDADataSet to fill the
FieldsOrigin Origin property of the TField objects by
appropriate value when opening a dataset.
FlatBuffers Used to control how a dataset treats data
of the ftString and ftVarBytes fields.
InsertAllSetFields Used to include all set dataset fields in the
generated INSERT statement
Used for TCustomDADataSet to use local
LocalMasterDetail filtering to establish master/detail
relationship for detail dataset and does not
refer to the server.
Used to represent string fields with the
LongStrings length that is greater than 255 as
TStringField.
Allows to use NULL values in the fields by
which the relation is built, when generating
MasterFieldsNullable the query for the Detail tables (when this
option is enabled, the performance can get
worse).
Used to set the MaxValue and MinValue
NumberRange properties of TIntegerField and TFloatField
to appropriate values.
Used for TCustomDADataSet to perform
QueryRecCount additional query to get the record count for
this SELECT, so the RecordCount property
reflects the actual number of records.
Used for TCustomDADataSet to quote all
QuoteNames database object names in autogenerated
SQL statements such as update SQL.
RemoveOnRefresh Used for a dataset to locally remove a
record that can not be found on the server.
Used for TCustomDADataSet to set the
RequiredFields Required property of the TField objects for
the NOT NULL fields.
ReturnParams Used to return the new value of fields to
© 2018 Devart
Reference 280
See Also
Master/Detail Relationships
TMemDataSet.CachedUpdates
Used to specify whether parameters for the Params property are generated automatically
after the SQL property was changed.
Class
TCustomDADataSet
Syntax
property ParamCheck: boolean default True;
Remarks
Use the ParamCheck property to specify whether parameters for the Params property are
generated automatically after the SQL property was changed.
Set ParamCheck to True to let dataset automatically generate the Params property for the
dataset based on a SQL statement.
Setting ParamCheck to False can be used if the dataset component passes to a server the
DDL statements that contain, for example, declarations of stored procedures which
themselves will accept parameterized values. The default value is True.
© 2018 Devart
281 PostgreSQL Data Access Components
See Also
Params
Used to indicate how many parameters are there in the Params property.
Class
TCustomDADataSet
Syntax
property ParamCount: word;
Remarks
Use the ParamCount property to determine how many parameters are there in the Params
property.
See Also
Params
Used to view and set parameter names, values, and data types dynamically.
Class
TCustomDADataSet
Syntax
property Params: TDAParams stored False;
Remarks
Contains the parameters for a query's SQL statement.
Access Params at runtime to view and set parameter names, values, and data types
dynamically (at design time use the Parameters editor to set the parameter information).
Params is a zero-based array of parameter records. Index specifies the array element to
access.
An easier way to set and retrieve parameter values when the name of each parameter is
known is to call ParamByName.
© 2018 Devart
Reference 282
See Also
ParamByName
Macros
Used to prevent users from updating, inserting, or deleting data in the dataset.
Class
TCustomDADataSet
Syntax
property ReadOnly: boolean default False;
Remarks
Use the ReadOnly property to prevent users from updating, inserting, or deleting data in the
dataset. By default, ReadOnly is False, meaning that users can potentially alter data stored in
the dataset.
To guarantee that users cannot modify or add data to a dataset, set ReadOnly to True.
When ReadOnly is True, the dataset's CanModify property is False.
5.9.1.5.2.22 RefreshOptions Property
Class
TCustomDADataSet
Syntax
property RefreshOptions: TRefreshOptions default [];
Remarks
Use the RefreshOptions property to determine when the editing record is refreshed.
Refresh is performed by the RefreshRecord method.
It queries the current record and replaces one in the dataset. Refresh record is useful when
the table has triggers or the table fields have default values. Use roBeforeEdit to get actual
data before editing.
The default value is [].
© 2018 Devart
283 PostgreSQL Data Access Components
See Also
RefreshRecord
Used to indicate the number of rows which were inserted, updated, or deleted during the last
query operation.
Class
TCustomDADataSet
Syntax
property RowsAffected: integer;
Remarks
Check RowsAffected to determine how many rows were inserted, updated, or deleted during
the last query operation. If RowsAffected is -1, the query has not inserted, updated, or deleted
any rows.
5.9.1.5.2.24 SQL Property
Used to provide a SQL statement that a query component executes when its Open method is
called.
Class
TCustomDADataSet
Syntax
property SQL: TStrings;
Remarks
Use the SQL property to provide a SQL statement that a query component executes when its
Open method is called. At the design time the SQL property can be edited by invoking the
String List editor in Object Inspector.
When SQL is changed, TCustomDADataSet calls Close and UnPrepare.
See Also
SQLInsert
SQLUpdate
© 2018 Devart
Reference 284
SQLDelete
SQLRefresh
Used to specify a SQL statement that will be used when applying a deletion to a record.
Class
TCustomDADataSet
Syntax
property SQLDelete: TStrings;
Remarks
Use the SQLDelete property to specify the SQL statement that will be used when applying a
deletion to a record. Statements can be parameterized queries.
To create a SQLDelete statement at design-time, use the query statements editor.
Example
DELETE FROM Orders
WHERE
OrderID = :Old_OrderID
See Also
SQL
SQLInsert
SQLUpdate
SQLRefresh
Used to specify the SQL statement that will be used when applying an insertion to a dataset.
Class
TCustomDADataSet
Syntax
property SQLInsert: TStrings;
Remarks
© 2018 Devart
285 PostgreSQL Data Access Components
Use the SQLInsert property to specify the SQL statement that will be used when applying an
insertion to a dataset. Statements can be parameterized queries. Names of the parameters
should be the same as field names. Parameters prefixed with OLD_ allow using current
values of fields prior to the actual operation.
Use ReturnParam to return OUT parameters back to dataset.
To create a SQLInsert statement at design-time, use the query statements editor.
See Also
SQL
SQLUpdate
SQLDelete
SQLRefresh
Used to specify a SQL statement that will be used to perform a record lock.
Class
TCustomDADataSet
Syntax
property SQLLock: TStrings;
Remarks
Use the SQLLock property to specify a SQL statement that will be used to perform a record
lock. Statements can be parameterized queries. Names of the parameters should be the
same as field names. The parameters prefixed with OLD_ allow to use current values of
fields prior to the actual operation.
To create a SQLLock statement at design-time, the use query statement editor.
See Also
SQL
SQLInsert
SQLUpdate
SQLDelete
SQLRefresh
© 2018 Devart
Reference 286
Used to specify the SQL statement that is used to get the record count when opening a
dataset.
Class
TCustomDADataSet
Syntax
property SQLRecCount: TStrings;
Remarks
Use the SQLRecCount property to specify the SQL statement that is used to get the record
count when opening a dataset. The SQL statement is used if the
TDADataSetOptions.QueryRecCount property is True, and the TCustomDADataSet.FetchAll
property is False. Is not used if the FetchAll property is True.
To create a SQLRecCount statement at design-time, use the query statements editor.
See Also
SQLInsert
SQLUpdate
SQLDelete
SQLRefresh
TDADataSetOptions
M:Devart.Dac.TCustomDADataSet.FetchingAll
Used to specify a SQL statement that will be used to refresh current record by calling the
RefreshRecord procedure.
Class
TCustomDADataSet
Syntax
property SQLRefresh: TStrings;
Remarks
Use the SQLRefresh property to specify a SQL statement that will be used to refresh current
© 2018 Devart
287 PostgreSQL Data Access Components
Example
SELECT Shipname FROM Orders
WHERE
OrderID = :OrderID
See Also
RefreshRecord
SQL
SQLInsert
SQLUpdate
SQLDelete
Used to specify a SQL statement that will be used when applying an update to a dataset.
Class
TCustomDADataSet
Syntax
property SQLUpdate: TStrings;
Remarks
Use the SQLUpdate property to specify a SQL statement that will be used when applying an
update to a dataset. Statements can be parameterized queries. Names of the parameters
should be the same as field names. The parameters prefixed with OLD_ allow to use current
values of fields prior to the actual operation.
Use ReturnParam to return OUT parameters back to the dataset.
To create a SQLUpdate statement at design-time, use the query statement editor.
Example
UPDATE Orders
© 2018 Devart
Reference 288
set
ShipName = :ShipName
WHERE
OrderID = :Old_OrderID
See Also
SQL
SQLInsert
SQLDelete
SQLRefresh
Used if an application does not need bidirectional access to records in the result set.
Class
TCustomDADataSet
Syntax
property UniDirectional: boolean default False;
Remarks
Traditionally SQL cursors are unidirectional. They can travel only forward through a dataset.
TCustomDADataset, however, permits bidirectional travelling by caching records. If an
application does not need bidirectional access to the records in the result set, set
UniDirectional to True. When UniDirectional is True, an application requires less memory and
performance is improved. However, UniDirectional datasets cannot be modified. In
FetchAll=False mode data is fetched on demand. When UniDirectional is set to True, data is
fetched on demand as well, but obtained rows are not cached except for the current row. In
case if the Unidirectional property is True, the FetchAll property will be automatically set to
False. And if the FetchAll property is True, the Unidirectional property will be automatically set
to False. The default value of UniDirectional is False, enabling forward and backward
navigation.
Note: Pay attention to the specificity of using the FetchAll property=False
See Also
TPgQuery.FetchAll
5.9.1.5.3 Methods
© 2018 Devart
289 PostgreSQL Data Access Components
For a complete list of the TCustomDADataSet class members, see the TCustomDADataSet
Members topic.
Public
Name Description
AddWhere Adds condition to the WHERE clause of SELECT
statement in the SQL property.
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 290
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
291 PostgreSQL Data Access Components
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
© 2018 Devart
Reference 292
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
See Also
TCustomDADataSet Class
TCustomDADataSet Class Members
Adds condition to the WHERE clause of SELECT statement in the SQL property.
Class
TCustomDADataSet
© 2018 Devart
293 PostgreSQL Data Access Components
Syntax
procedure AddWhere(const Condition: string);
Parameters
Condition
Holds the condition that will be added to the WHERE clause.
Remarks
Call the AddWhere method to add a condition to the WHERE clause of SELECT statement in
the SQL property.
If SELECT has no WHERE clause, AddWhere creates it.
Note: the AddWhere method is implicitly called by RefreshRecord. The AddWhere method
works for the SELECT statements only.
Note: the AddWhere method adds a value to the WHERE condition as is. If you expect this
value to be enclosed in brackets, you should bracket it explicitly.
See Also
DeleteWhere
Class
TCustomDADataSet
Syntax
procedure BreakExec; virtual;
Remarks
Call the BreakExec method to break execution of the SQL statement on the server. It makes
sense to call BreakExec only from another thread.
5.9.1.5.3.3 CreateBlobStream Method
Used to obtain a stream for reading data from or writing data to a BLOB field, specified by the
Field parameter.
Class
© 2018 Devart
Reference 294
TCustomDADataSet
Syntax
function CreateBlobStream(Field: TField; Mode: TBlobStreamMode):
TStream; override;
Parameters
Field
Holds the BLOB field for reading data from or writing data to from a stream.
Mode
Holds the stream mode, for which the stream will be used.
Return Value
The BLOB Stream.
Remarks
Call the CreateBlobStream method to obtain a stream for reading data from or writing data to
a BLOB field, specified by the Field parameter. It must be a TBlobField component. You can
specify whether the stream will be used for reading, writing, or updating the contents of the
field with the Mode parameter.
5.9.1.5.3.4 DeleteWhere Method
Removes WHERE clause from the SQL property and assigns the BaseSQL property.
Class
TCustomDADataSet
Syntax
procedure DeleteWhere;
Remarks
Call the DeleteWhere method to remove WHERE clause from the the SQL property and
assign BaseSQL.
See Also
AddWhere
BaseSQL
© 2018 Devart
295 PostgreSQL Data Access Components
Class
TCustomDADataSet
Overload List
Name Description
Execute Executes a SQL statement on the server.
Execute(Iters: integer; Offset: integer) Used to perform Batch operations .
Executes a SQL statement on the server.
Class
TCustomDADataSet
Syntax
procedure Execute; overload; virtual;
Remarks
Call the Execute method to execute an SQL statement on the server. If SQL statement is a
SELECT query, Execute calls the Open method.
Execute implicitly prepares SQL statement by calling the TCustomDADataSet.Prepare
method if the TCustomDADataSet.Options option is set to True and the statement has not
been prepared yet. To speed up the performance in case of multiple Execute calls, an
application should call Prepare before calling the Execute method for the first time.
See Also
TCustomDADataSet.AfterExecute
TCustomDADataSet.Executing
TCustomDADataSet.Prepare
Class
TCustomDADataSet
Syntax
© 2018 Devart
Reference 296
Parameters
Iters
Specifies the number of inserted rows.
Offset
Points the array element, which the Batch operation starts from. 0 by default.
Remarks
The Execute method executes the specified batch SQL query. See the Batch operations
article for samples.
See Also
Batch operations
Class
TCustomDADataSet
Syntax
function Executing: boolean;
Return Value
True, if SQL statement is still being executed.
Remarks
Check Executing to learn whether TCustomDADataSet is still executing SQL statement.
5.9.1.5.3.7 Fetched Method
Class
TCustomDADataSet
Syntax
function Fetched: boolean; virtual;
© 2018 Devart
297 PostgreSQL Data Access Components
Return Value
True, if all rows are fetched.
Remarks
Check Fetched to learn whether TCustomDADataSet has already fetched all rows.
See Also
Fetching
Class
TCustomDADataSet
Syntax
function Fetching: boolean;
Return Value
True, if TCustomDADataSet is still fetching rows.
Remarks
Check Fetching to learn whether TCustomDADataSet is still fetching rows. Use the Fetching
method if NonBlocking is True.
See Also
Executing
Class
TCustomDADataSet
Syntax
function FetchingAll: boolean;
Return Value
True, if TCustomDADataSet is fetching all rows to the end.
© 2018 Devart
Reference 298
Remarks
Check FetchingAll to learn whether TCustomDADataSet is fetching all rows to the end.
See Also
Executing
Class
TCustomDADataSet
Syntax
function FindKey(const KeyValues: array of System.TVarRec):
Boolean;
Parameters
KeyValues
Holds a key.
Remarks
Call the FindKey method to search for a specific record in a dataset. KeyValues holds a
comma-delimited array of field values, that is called a key.
This function is provided for BDE compatibility only. It is recommended to use functions
TMemDataSet.Locate and TMemDataSet.LocateEx for the record search.
5.9.1.5.3.11 FindMacro Method
Class
TCustomDADataSet
Syntax
function FindMacro(const Value: string): TMacro;
Parameters
Value
See Also
© 2018 Devart
299 PostgreSQL Data Access Components
TMacro
Macros
MacroByName
Moves the cursor to a specific record or to the first record in the dataset that matches or is
greater than the values specified in the KeyValues parameter.
Class
TCustomDADataSet
Syntax
procedure FindNearest(const KeyValues: array of System.TVarRec);
Parameters
KeyValues
Holds the values of the record key fields to which the cursor should be moved.
Remarks
Call the FindNearest method to move the cursor to a specific record or to the first record in
the dataset that matches or is greater than the values specified in the KeyValues parameter. If
there are no records that match or exceed the specified criteria, the cursor will not move.
This function is provided for BDE compatibility only. It is recommended to use functions
TMemDataSet.Locate and TMemDataSet.LocateEx for the record search.
See Also
TMemDataSet.Locate
TMemDataSet.LocateEx
FindKey
Class
TCustomDADataSet
Syntax
function FindParam(const Value: string): TDAParam;
© 2018 Devart
Reference 300
Parameters
Value
Holds the name of the param for which to search.
Return Value
the TDAParam object for the specified Name. Otherwise it returns nil.
Remarks
Call the FindParam method to determine if a specified param component exists in a dataset.
Name is the name of the param for which to search. If FindParam finds a param with a
matching name, it returns a TDAParam object for the specified Name. Otherwise it returns
nil.
See Also
Params
ParamByName
Returns internal field types defined in the MemData and accompanying modules.
Class
TCustomDADataSet
Syntax
function GetDataType(const FieldName: string): integer; virtual;
Parameters
FieldName
Holds the name of the field.
Return Value
internal field types defined in MemData and accompanying modules.
Remarks
Call the GetDataType method to return internal field types defined in the MemData and
accompanying modules. Internal field data types extend the TFieldType type of VCL by
specific database server data types. For example, ftString, ftFile, ftObject.
© 2018 Devart
301 PostgreSQL Data Access Components
Class
TCustomDADataSet
Syntax
function GetFieldObject(Field: TField): TSharedObject;
overload;function GetFieldObject(Field: TField; RecBuf:
TRecordBuffer): TSharedObject; overload;function
GetFieldObject(FieldDesc: TFieldDesc): TSharedObject;
overload;function GetFieldObject(FieldDesc: TFieldDesc; RecBuf:
TRecordBuffer): TSharedObject; overload;function
GetFieldObject(const FieldName: string): TSharedObject; overload;
Parameters
FieldName
Holds the field name.
Return Value
multireference shared object.
Remarks
Call the GetFieldObject method to return a multireference shared object from field. If field
does not hold one of the TSharedObject descendants, GetFieldObject raises an exception.
5.9.1.5.3.16 GetFieldPrecision Method
Class
TCustomDADataSet
Syntax
function GetFieldPrecision(const FieldName: string): integer;
Parameters
FieldName
Holds the existing field name.
Return Value
precision of number field.
© 2018 Devart
Reference 302
Remarks
Call the GetFieldPrecision method to retrieve the precision of a number field. FieldName is the
name of an existing field.
See Also
GetFieldScale
Class
TCustomDADataSet
Syntax
function GetFieldScale(const FieldName: string): integer;
Parameters
FieldName
Holds the existing field name.
Return Value
the scale of the number field.
Remarks
Call the GetFieldScale method to retrieve the scale of a number field. FieldName is the name
of an existing field.
See Also
GetFieldPrecision
Class
TCustomDADataSet
Syntax
procedure GetKeyFieldNames(List: TStrings);
© 2018 Devart
303 PostgreSQL Data Access Components
Parameters
List
The list of available key field names
Return Value
Key field name
Remarks
Call the GetKeyFieldNames method to get the names of available key fields. Populates a
string list with the names of key fields in tables.
See Also
TCustomDAConnection.GetTableNames
TCustomDAConnection.GetStoredProcNames
Class
TCustomDADataSet
Syntax
function GetOrderBy: string;
Return Value
an ORDER BY clause from the SQL statement.
Remarks
Call the GetOrderBy method to retrieve an ORDER BY clause from a SQL statement.
Note: GetOrderBy and SetOrderBy methods serve to process only quite simple queries and
don't support, for example, subqueries.
See Also
SetOrderBy
Sets the current record in this dataset similar to the current record in another dataset.
Class
© 2018 Devart
Reference 304
TCustomDADataSet
Syntax
procedure GotoCurrent(DataSet: TCustomDADataSet);
Parameters
DataSet
Holds the TCustomDADataSet descendant to synchronize the record position with.
Remarks
Call the GotoCurrent method to set the current record in this dataset similar to the current
record in another dataset. The key fields in both these DataSets must be coincident.
See Also
TMemDataSet.Locate
TMemDataSet.LocateEx
Class
TCustomDADataSet
Syntax
procedure Lock; virtual;
Remarks
Call the Lock method to lock the current record by executing the statement that is defined in
the SQLLock property.
The Lock method sets the savepoint with the name LOCK_ + <component_name>.
See Also
UnLock
Class
© 2018 Devart
305 PostgreSQL Data Access Components
TCustomDADataSet
Syntax
function MacroByName(const Value: string): TMacro;
Parameters
Value
Holds the name of the Macro to search for.
Return Value
the Macro, if a match was found.
Remarks
Call the MacroByName method to find a Macro with the name passed in Name. If a match
was found, MacroByName returns the Macro. Otherwise, an exception is raised. Use this
method rather than a direct reference to the Items property to avoid depending on the order of
the entries.
To locate a parameter by name without raising an exception if the parameter is not found, use
the FindMacro method.
To assign the value of macro use the TMacro.Value property.
Example
PgQuery.SQL:= 'SELECT * FROM Scott.Dept ORDER BY &Order';
PgQuery.MacroByName('Order').Value:= 'DeptNo';
PgQuery.Open;
See Also
TMacro
Macros
FindMacro
Sets or uses parameter information for a specific parameter based on its name.
Class
TCustomDADataSet
Syntax
function ParamByName(const Value: string): TDAParam;
© 2018 Devart
Reference 306
Parameters
Value
Holds the name of the parameter for which to retrieve information.
Return Value
a TDAParam object.
Remarks
Call the ParamByName method to set or use parameter information for a specific parameter
based on its name. Name is the name of the parameter for which to retrieve information.
ParamByName is used to set a parameter's value at runtime and returns a TDAParam
object.
Example
The following statement retrieves the current value of a parameter called "Contact" into an
edit box:
Edit1.Text := Query1.ParamsByName('Contact').AsString;
See Also
Params
FindParam
Class
TCustomDADataSet
Syntax
procedure Prepare; override;
Remarks
Call the Prepare method to allocate, open, and parse cursor for a query. Calling Prepare
before executing a query improves application performance.
The UnPrepare method unprepares a query.
Note: When you change the text of a query at runtime, the query is automatically closed and
unprepared.
© 2018 Devart
307 PostgreSQL Data Access Components
See Also
TMemDataSet.Prepared
TMemDataSet.UnPrepare
Options
Class
TCustomDADataSet
Syntax
procedure RefreshRecord;
Remarks
Call the RefreshRecord method to actualize field values for the current record.
RefreshRecord performs query to database and refetches new field values from the returned
cursor.
See Also
RefreshOptions
SQLRefresh
Class
TCustomDADataSet
Syntax
procedure RestoreSQL;
Remarks
Call the RestoreSQL method to restore the SQL property modified by AddWhere and
SetOrderBy.
See Also
© 2018 Devart
Reference 308
AddWhere
SetOrderBy
SaveSQL
SQLSaved
Class
TCustomDADataSet
Syntax
procedure SaveSQL;
Remarks
Call the SaveSQL method to save the SQL property value to the BaseSQL property.
See Also
SQLSaved
RestoreSQL
BaseSQL
Class
TCustomDADataSet
Syntax
procedure SetOrderBy(const Fields: string);
Parameters
Fields
Holds the names of the fields which will be added to the ORDER BY clause.
Remarks
Call the SetOrderBy method to build an ORDER BY clause of a SELECT statement. The
fields are identified by the comma-delimited field names.
© 2018 Devart
309 PostgreSQL Data Access Components
Note: The GetOrderBy and SetOrderBy methods serve to process only quite simple queries
and don't support, for example, subqueries.
Example
Query1.SetOrderBy('DeptNo;DName');
See Also
GetOrderBy
Determines if the SQL property value was saved to the BaseSQL property.
Class
TCustomDADataSet
Syntax
function SQLSaved: boolean;
Return Value
True, if the SQL property value was saved to the BaseSQL property.
Remarks
Call the SQLSaved method to know whether the SQL property value was saved to the
BaseSQL property.
5.9.1.5.3.30 UnLock Method
Class
TCustomDADataSet
Syntax
procedure UnLock;
Remarks
Call the Unlock method to release the record lock made by the Lock method before.
Unlock is performed by rolling back to the savepoint set by the Lock method.
See Also
© 2018 Devart
Reference 310
Lock
5.9.1.5.4 Events
Public
Name Description
AfterExecute Occurs after a component has executed a query to
database.
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
See Also
TCustomDADataSet Class
TCustomDADataSet Class Members
Class
TCustomDADataSet
© 2018 Devart
311 PostgreSQL Data Access Components
Syntax
property AfterExecute: TAfterExecuteEvent;
Remarks
Occurs after a component has executed a query to database.
See Also
TCustomDADataSet.Execute
Class
TCustomDADataSet
Syntax
property AfterFetch: TAfterFetchEvent;
Remarks
The AfterFetch event occurs after dataset finishes fetching data from server.
See Also
BeforeFetch
Occurs after executing insert, delete, update, lock and refresh operations.
Class
TCustomDADataSet
Syntax
property AfterUpdateExecute: TUpdateExecuteEvent;
Remarks
Occurs after executing insert, delete, update, lock, and refresh operations. You can use
AfterUpdateExecute to set the parameters of corresponding statements.
© 2018 Devart
Reference 312
Occurs before dataset is going to fetch block of records from the server.
Class
TCustomDADataSet
Syntax
property BeforeFetch: TBeforeFetchEvent;
Remarks
The BeforeFetch event occurs every time before dataset is going to fetch a block of records
from the server. Set Cancel to True to abort current fetch operation.
See Also
AfterFetch
Occurs before executing insert, delete, update, lock, and refresh operations.
Class
TCustomDADataSet
Syntax
property BeforeUpdateExecute: TUpdateExecuteEvent;
Remarks
Occurs before executing insert, delete, update, lock, and refresh operations. You can use
BeforeUpdateExecute to set the parameters of corresponding statements.
See Also
AfterUpdateExecute
A base class for components executing SQL statements that do not return result sets.
For a list of all members of this type, see TCustomDASQL members.
Unit
DBAccess
© 2018 Devart
313 PostgreSQL Data Access Components
Syntax
TCustomDASQL = class(TComponent);
Remarks
TCustomDASQL is a base class that defines functionality for descendant classes which
access database using SQL statements. Applications never use TCustomDASQL objects
directly. Instead they use descendants of TCustomDASQL.
Use TCustomDASQL when client application must execute SQL statement or call stored
procedure on the database server. The SQL statement should not retrieve rows from the
database.
5.9.1.6.1 Members
Properties
Name Description
ChangeCursor Enables or disables changing screen cursor when
executing commands in the NonBlocking mode.
© 2018 Devart
Reference 314
Methods
Name Description
Execute Overloaded. Executes a SQL statement on the
server.
Events
Name Description
© 2018 Devart
315 PostgreSQL Data Access Components
5.9.1.6.2 Properties
Public
Name Description
ChangeCursor Enables or disables changing screen cursor when
executing commands in the NonBlocking mode.
© 2018 Devart
Reference 316
See Also
TCustomDASQL Class
TCustomDASQL Class Members
Enables or disables changing screen cursor when executing commands in the NonBlocking
mode.
Class
TCustomDASQL
Syntax
property ChangeCursor: boolean;
Remarks
Set the ChangeCursor property to False to prevent the screen cursor from changing to
crSQLArrow when executing commands in the NonBlocking mode. The default value is True.
5.9.1.6.2.2 Connection Property
Class
TCustomDASQL
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify a connection object that will be used to connect to a
data store.
Set at design-time by selecting from the list of provided TCustomDAConnection or its
descendant class objects.
At runtime, link an instance of a TCustomDAConnection descendant to the Connection
© 2018 Devart
317 PostgreSQL Data Access Components
property.
5.9.1.6.2.3 Debug Property
Used to display executing statement, all its parameters' values, and the type of parameters.
Class
TCustomDASQL
Syntax
property Debug: boolean default False;
Remarks
Set the Debug property to True to display executing statement and all its parameters' values.
Also displays the type of parameters.
You should add the PgDacVcl unit to the uses clause of any unit in your project to make the
Debug property work.
Note: If TPgSQLMonitor is used in the project and the TPgSQLMonitor.Active property is set
to False, the debug window is not displayed.
See Also
TCustomDADataSet.Debug
Class
TCustomDASQL
Syntax
property FinalSQL: string;
Remarks
Read the FinalSQL property to return a SQL statement with expanded macros. This is the
exact statement that will be passed on to the database server.
© 2018 Devart
Reference 318
Used to get the number of macros associated with the Macros property.
Class
TCustomDASQL
Syntax
property MacroCount: word;
Remarks
Use the MacroCount property to get the number of macros associated with the Macros
property.
See Also
Macros
Class
TCustomDASQL
Syntax
property Macros: TMacros stored False;
Remarks
With the help of macros you can easily change SQL query text at design- or runtime. Marcos
extend abilities of parameters and allow to change conditions in a WHERE clause or sort
order in an ORDER BY clause. You just insert &MacroName in the SQL query text and
change value of macro in the Macro property editor at design time or call the MacroByName
function at run time. At the time of opening the query macro is replaced by its value.
See Also
TMacro
MacroByName
Params
© 2018 Devart
319 PostgreSQL Data Access Components
Used to specify whether parameters for the Params property are implicitly generated when
the SQL property is being changed.
Class
TCustomDASQL
Syntax
property ParamCheck: boolean default True;
Remarks
Use the ParamCheck property to specify whether parameters for the Params property are
implicitly generated when the SQL property is being changed.
Set ParamCheck to True to let TCustomDASQL generate the Params property for the
dataset based on a SQL statement automatically.
Setting ParamCheck to False can be used if the dataset component passes to a server the
DDL statements that contain, for example, declarations of the stored procedures that will
accept parameterized values themselves. The default value is True.
See Also
Params
Class
TCustomDASQL
Syntax
property ParamCount: word;
Remarks
Use the ParamCount property to determine how many parameters are there in the Params
property.
© 2018 Devart
Reference 320
Class
TCustomDASQL
Syntax
property Params: TDAParams stored False;
Remarks
Access the Params property at runtime to view and set parameter names, values, and data
types dynamically (at design-time use the Parameters editor to set parameter properties).
Params is a zero-based array of parameter records. Index specifies the array element to
access. An easier way to set and retrieve parameter values when the name of each
parameter is known is to call ParamByName.
Example
Setting parameters at runtime:
See Also
TDAParam
FindParam
Macros
Used to get or set the values of individual field parameters that are identified by name.
Class
TCustomDASQL
© 2018 Devart
321 PostgreSQL Data Access Components
Syntax
property ParamValues[const ParamName: string]: Variant; default;
Parameters
ParamName
Holds parameter names separated by semicolon.
Remarks
Use the ParamValues property to get or set the values of individual field parameters that are
identified by name.
Setting ParamValues sets the Value property for each parameter listed in the ParamName
string. Specify the values as Variants.
Getting ParamValues retrieves an array of variants, each of which represents the value of one
of the named parameters.
Note: The Params array is generated implicitly if ParamCheck property is set to True. If
ParamName includes a name that does not match any of the parameters in Items, an
exception is raised.
5.9.1.6.2.11 Prepared Property
Class
TCustomDASQL
Syntax
property Prepared: boolean;
Remarks
Check the Prepared property to determine if a query is already prepared for execution. True
means that the query has already been prepared. As a rule prepared queries are executed
faster, but the preparation itself also takes some time. One of the proper cases for using
preparation is parametrized queries that are executed several times.
See Also
Prepare
© 2018 Devart
Reference 322
Used to indicate the number of rows which were inserted, updated, or deleted during the last
query operation.
Class
TCustomDASQL
Syntax
property RowsAffected: integer;
Remarks
Check RowsAffected to determine how many rows were inserted, updated, or deleted during
the last query operation. If RowsAffected is -1, the query has not inserted, updated, or deleted
any rows.
5.9.1.6.2.13 SQL Property
Used to provide a SQL statement that a TCustomDASQL component executes when the
Execute method is called.
Class
TCustomDASQL
Syntax
property SQL: TStrings;
Remarks
Use the SQL property to provide a SQL statement that a TCustomDASQL component
executes when the Execute method is called. At design time the SQL property can be edited
by invoking the String List editor in Object Inspector.
See Also
FinalSQL
TCustomDASQL.Execute
5.9.1.6.3 Methods
© 2018 Devart
323 PostgreSQL Data Access Components
Members topic.
Public
Name Description
Execute Overloaded. Executes a SQL statement on the
server.
See Also
TCustomDASQL Class
TCustomDASQL Class Members
Class
TCustomDASQL
Overload List
Name Description
© 2018 Devart
Reference 324
Class
TCustomDASQL
Syntax
procedure Execute; overload; virtual;
Remarks
Call the Execute method to execute a SQL statement on the server. If the SQL statement has
OUT parameters, use the TCustomDASQL.ParamByName method or the
TCustomDASQL.Params property to get their values. Iters argument specifies the number of
times this statement is executed for the DML array operations.
Class
TCustomDASQL
Syntax
procedure Execute(Iters: integer; Offset: integer = 0); overload;
virtual;
Parameters
Iters
Specifies the number of inserted rows.
Offset
Points the array element, which the Batch operation starts from. 0 by default.
Remarks
The Execute method executes the specified batch SQL query. See the Batch operations
article for samples.
See Also
Batch operations
© 2018 Devart
325 PostgreSQL Data Access Components
Class
TCustomDASQL
Syntax
function Executing: boolean;
Return Value
True, if a SQL statement is still being executed by TCustomDASQL.
Remarks
Check Executing to find out whether TCustomDASQL still executes a SQL statement.
5.9.1.6.3.3 FindMacro Method
Class
TCustomDASQL
Syntax
function FindMacro(const Value: string): TMacro;
Parameters
Value
Holds the name of a macro to search for.
Return Value
the TMacro object, if a macro with the specified name has been found. If it has not, returns
nil.
Remarks
Call the FindMacro method to find a macro with the specified name in a dataset.
See Also
TMacro
Macros
MacroByName
© 2018 Devart
Reference 326
Class
TCustomDASQL
Syntax
function FindParam(const Value: string): TDAParam;
Parameters
Value
Holds the parameter name to search for.
Return Value
a TDAParm object, if a parameter with the specified name has been found. If it has not,
returns nil.
Remarks
Call the FindParam method to find a parameter with the specified name in a dataset.
See Also
ParamByName
Class
TCustomDASQL
Syntax
function MacroByName(const Value: string): TMacro;
Parameters
Value
Holds the name of the Macro to search for.
Return Value
the Macro, if a match was found.
Remarks
Call the MacroByName method to find a Macro with the name passed in Name. If a match
© 2018 Devart
327 PostgreSQL Data Access Components
was found, MacroByName returns the Macro. Otherwise, an exception is raised. Use this
method rather than a direct reference to the Items property to avoid depending on the order of
the entries.
To locate a parameter by name without raising an exception if the parameter is not found, use
the FindMacro method.
To assign the value of macro use the TMacro.Value property.
See Also
TMacro
Macros
FindMacro
Class
TCustomDASQL
Syntax
function ParamByName(const Value: string): TDAParam;
Parameters
Value
Holds the name of the parameter to search for.
Return Value
a TDAParam object, if a match was found. Otherwise, an exception is raised.
Remarks
Use the ParamByName method to find a parameter with the specified name. If no parameter
with the specified name found, an exception is raised.
Example
PgSQL.Execute;
Edit1.Text := PgSQL.ParamsByName('Contact').AsString;
See Also
FindParam
© 2018 Devart
Reference 328
Class
TCustomDASQL
Syntax
procedure Prepare; virtual;
Remarks
Call the Prepare method to allocate, open, and parse cursor for a query. Calling Prepare
before executing a query improves application performance.
The UnPrepare method unprepares a query.
Note: When you change the text of a query at runtime, the query is automatically closed and
unprepared.
See Also
Prepared
UnPrepare
Frees the resources allocated for a previously prepared query on the server and client sides.
Class
TCustomDASQL
Syntax
procedure UnPrepare; virtual;
Remarks
Call the UnPrepare method to free resources allocated for a previously prepared query on the
server and client sides.
See Also
Prepare
© 2018 Devart
329 PostgreSQL Data Access Components
Class
TCustomDASQL
Syntax
function WaitExecuting(TimeOut: integer = 0): boolean;
Parameters
TimeOut
Holds the time in seconds to wait while TCustomDASQL executes the SQL statement. Zero
means infinite time.
Return Value
True, if the execution of a SQL statement was completed in the preset time.
Remarks
Call the WaitExecuting method to wait until TCustomDASQL executes a SQL statement.
See Also
Executing
5.9.1.6.4 Events
Public
Name Description
AfterExecute Occurs after a SQL statement has been executed.
See Also
TCustomDASQL Class
TCustomDASQL Class Members
© 2018 Devart
Reference 330
Class
TCustomDASQL
Syntax
property AfterExecute: TAfterExecuteEvent;
Remarks
Occurs after a SQL statement has been executed. This event may be used for descendant
components which use multithreaded environment.
See Also
TCustomDASQL.Execute
A base class for components that provide DML statements for more flexible control over data
modifications.
For a list of all members of this type, see TCustomDAUpdateSQL members.
Unit
DBAccess
Syntax
TCustomDAUpdateSQL = class(TComponent);
Remarks
TCustomDAUpdateSQL is a base class for components that provide DML statements for
more flexible control over data modifications. Besides providing BDE compatibility, this
component allows to associate a separate component for each update command.
See Also
TCustomPgDataSet.UpdateObject
© 2018 Devart
331 PostgreSQL Data Access Components
5.9.1.7.1 Members
Properties
Name Description
DataSet Used to hold a reference to the
TCustomDADataSet object that is being updated.
Methods
Name Description
Apply Sets parameters for a SQL statement and
executes it to update a record.
© 2018 Devart
Reference 332
5.9.1.7.2 Properties
Public
Name Description
DataSet Used to hold a reference to the
TCustomDADataSet object that is being updated.
Published
Name Description
DeleteObject Provides ability to perform advanced adjustment
of the delete operations.
© 2018 Devart
333 PostgreSQL Data Access Components
See Also
TCustomDAUpdateSQL Class
TCustomDAUpdateSQL Class Members
Class
TCustomDAUpdateSQL
Syntax
property DataSet: TCustomDADataSet;
Remarks
The DataSet property holds a reference to the TCustomDADataSet object that is being
updated. Generally it is not used directly.
5.9.1.7.2.2 DeleteObject Property
Class
TCustomDAUpdateSQL
Syntax
property DeleteObject: TComponent;
Remarks
Assign SQL component or a TCustomPgDataSet descendant to this property to perform
advanced adjustment of the delete operations. In some cases this can give some additional
performance. Use the same principle to set the SQL property of an object as for setting the
DeleteSQL property.
© 2018 Devart
Reference 334
See Also
DeleteSQL
Class
TCustomDAUpdateSQL
Syntax
property DeleteSQL: TStrings;
Remarks
Set the DeleteSQL property to a DELETE statement to use when deleting a record.
Statements can be parameterized queries with parameter names corresponding to the
dataset field names.
5.9.1.7.2.4 InsertObject Property
Class
TCustomDAUpdateSQL
Syntax
property InsertObject: TComponent;
Remarks
Assign SQL component or TCustomPgDataSet descendant to this property to perform
advanced adjustment of insert operations. In some cases this can give some additional
performance. Set the SQL property of the object in the same way as used for the InsertSQL
property.
See Also
InsertSQL
© 2018 Devart
335 PostgreSQL Data Access Components
Class
TCustomDAUpdateSQL
Syntax
property InsertSQL: TStrings;
Remarks
Set the InsertSQL property to an INSERT INTO statement to use when inserting a record.
Statements can be parameterized queries with parameter names corresponding to the
dataset field names.
5.9.1.7.2.6 LockObject Property
Class
TCustomDAUpdateSQL
Syntax
property LockObject: TComponent;
Remarks
Assign a SQL component or TCustomPgDataSet descendant to this property to perform
advanced adjustment of lock operations. In some cases that can give some additional
performance. Set the SQL property of an object in the same way as used for the LockSQL
property.
See Also
LockSQL
Class
TCustomDAUpdateSQL
© 2018 Devart
Reference 336
Syntax
property LockSQL: TStrings;
Remarks
Use the LockSQL property to lock the current record. Statements can be parameterized
queries with parameter names corresponding to the dataset field names.
5.9.1.7.2.8 ModifyObject Property
Class
TCustomDAUpdateSQL
Syntax
property ModifyObject: TComponent;
Remarks
Assign a SQL component or TCustomPgDataSet descendant to this property to perform
advanced adjustment of modify operations. In some cases this can give some additional
performance. Set the SQL property of the object in the same way as used for the ModifySQL
property.
See Also
ModifySQL
Class
TCustomDAUpdateSQL
Syntax
property ModifySQL: TStrings;
Remarks
Set ModifySQL to an UPDATE statement to use when updating a record. Statements can be
parameterized queries with parameter names corresponding to the dataset field names.
© 2018 Devart
337 PostgreSQL Data Access Components
Class
TCustomDAUpdateSQL
Syntax
property RefreshObject: TComponent;
Remarks
Assign a SQL component or TCustomPgDataSet descendant to this property to perform
advanced adjustment of refresh operations. In some cases that can give some additional
performance. Set the SQL property of the object in the same way as used for the
RefreshSQL property.
See Also
RefreshSQL
Used to specify an SQL statement that will be used for refreshing the current record by
TCustomDADataSet.RefreshRecord procedure.
Class
TCustomDAUpdateSQL
Syntax
property RefreshSQL: TStrings;
Remarks
Use the RefreshSQL property to specify a SQL statement that will be used for refreshing the
current record by the TCustomDADataSet.RefreshRecord procedure.
You can assign to SQLRefresh a WHERE clause only. In such a case it is added to SELECT
defined by the SQL property by TCustomDADataSet.AddWhere.
To create a RefreshSQL statement at design time, use the query statements editor.
See Also
TCustomDADataSet.RefreshRecord
© 2018 Devart
Reference 338
Used to return a SQL statement for one of the ModifySQL, InsertSQL, or DeleteSQL
properties.
Class
TCustomDAUpdateSQL
Syntax
property SQL[UpdateKind: TUpdateKind]: TStrings;
Parameters
UpdateKind
Specifies which of update SQL statements to return.
Remarks
Returns a SQL statement for one of the ModifySQL, InsertSQL, or DeleteSQL properties,
depending on the value of the UpdateKind index.
5.9.1.7.3 Methods
Public
Name Description
See Also
TCustomDAUpdateSQL Class
TCustomDAUpdateSQL Class Members
Class
© 2018 Devart
339 PostgreSQL Data Access Components
TCustomDAUpdateSQL
Syntax
procedure Apply(UpdateKind: TUpdateKind); virtual;
Parameters
UpdateKind
Specifies which of update SQL statements to execute.
Remarks
Call the Apply method to set parameters for a SQL statement and execute it to update a
record. UpdateKind indicates which SQL statement to bind and execute.
Apply is primarily intended for manually executing update statements from an
OnUpdateRecord event handler.
Note: If a SQL statement does not contain parameters, it is more efficient to call ExecSQL
instead of Apply.
See Also
ExecSQL
Class
TCustomDAUpdateSQL
Syntax
procedure ExecSQL(UpdateKind: TUpdateKind);
Parameters
UpdateKind
Specifies the kind of update statement to be executed.
Remarks
Call the ExecSQL method to execute a SQL statement, necessary for updating the records
belonging to a read-only result set when cached updates is enabled. UpdateKind specifies the
statement to execute.
ExecSQL is primarily intended for manually executing update statements from the
OnUpdateRecord event handler.
© 2018 Devart
Reference 340
See Also
Apply
Unit
DBAccess
Syntax
TDACondition = class(TCollectionItem);
Remarks
Manipulate conditions using TDAConditions.
See Also
TDAConditions
5.9.1.8.1 Members
Properties
Name Description
Enabled Indicates whether the condition is enabled or not
Methods
Name Description
© 2018 Devart
341 PostgreSQL Data Access Components
5.9.1.8.2 Properties
Published
Name Description
Enabled Indicates whether the condition is enabled or not
See Also
TDACondition Class
TDACondition Class Members
Class
TDACondition
Syntax
property Enabled: Boolean default True;
5.9.1.8.2.2 Name Property
Class
© 2018 Devart
Reference 342
TDACondition
Syntax
property Name: string;
5.9.1.8.2.3 Value Property
Class
TDACondition
Syntax
property Value: string;
5.9.1.8.3 Methods
Public
Name Description
See Also
TDACondition Class
TDACondition Class Members
Class
TDACondition
Syntax
© 2018 Devart
343 PostgreSQL Data Access Components
procedure Disable;
5.9.1.8.3.2 Enable Method
Class
TDACondition
Syntax
procedure Enable;
Unit
DBAccess
Syntax
TDAConditions = class(TCollection);
Remarks
The given example code
UniTable1.Conditions.Add('1','JOB="MANAGER"');
UniTable1.Conditions.Add('2','SAL>2500');
UniTable1.Conditions.Enable;
UniTable1.Open;
will return the following SQL:
SELECT * FROM EMP
WHERE (JOB="MANAGER")
and
(SAL<2500)
5.9.1.9.1 Members
Properties
Name Description
© 2018 Devart
Reference 344
Methods
Name Description
Add Overloaded. Adds a condition to the WHERE
clause of the query.
5.9.1.9.2 Properties
© 2018 Devart
345 PostgreSQL Data Access Components
topic.
Public
Name Description
Condition Used to iterate through all the conditions.
See Also
TDAConditions Class
TDAConditions Class Members
Class
TDAConditions
Syntax
property Condition[Index: Integer]: TDACondition;
Parameters
Index
5.9.1.9.2.2 Enabled Property
Class
TDAConditions
© 2018 Devart
Reference 346
Syntax
property Enabled: Boolean;
5.9.1.9.2.3 Items Property(Indexer)
Class
TDAConditions
Syntax
property Items[Index: Integer]: TDACondition; default;
Parameters
Index
Holds an index in the range 0..Count - 1.
Remarks
Use the Items property to iterate through all conditions. Index identifies the index in the range
0..Count - 1. Items can reference a particular condition by its index, but the Condition property
is preferred in order to avoid depending on the order of the conditions.
5.9.1.9.2.4 Text Property
Class
TDAConditions
Syntax
property Text: string;
5.9.1.9.2.5 WhereSQL Property
Class
TDAConditions
Syntax
© 2018 Devart
347 PostgreSQL Data Access Components
Public
Name Description
Add Overloaded. Adds a condition to the WHERE
clause of the query.
See Also
TDAConditions Class
TDAConditions Class Members
Class
TDAConditions
© 2018 Devart
Reference 348
Overload List
Name Description
Add(const Value: string; Enabled: Adds a condition to the WHERE clause of
Boolean) the query.
Add(const Name: string; const Value: Adds a condition to the WHERE clause of
string; Enabled: Boolean) the query.
Class
TDAConditions
Syntax
function Add(const Value: string; Enabled: Boolean = True):
TDACondition; overload;
Parameters
Value
The value of the condition
Enabled
Indicates that the condition is enabled
Remarks
If you want then to access the condition, you should use Add and its name in the Name
parameter.
The given example code will return the following SQL:
SELECT * FROM EMP
WHERE (JOB="MANAGER")
and
(SAL<2500)
Adds a condition to the WHERE clause of the query.
Class
TDAConditions
Syntax
function Add(const Name: string; const Value: string; Enabled:
Boolean = True): TDACondition; overload;
© 2018 Devart
349 PostgreSQL Data Access Components
Parameters
Name
Sets the name of the condition
Value
The value of the condition
Enabled
Indicates that the condition is enabled
Remarks
The given example code will return the following SQL:
SELECT * FROM EMP
WHERE (JOB="MANAGER")
and
(SAL<2500)
5.9.1.9.3.2 Delete Method
Class
TDAConditions
Syntax
procedure Delete(Index: integer);
Parameters
Index
Index of the condition
5.9.1.9.3.3 Disable Method
Class
TDAConditions
Syntax
procedure Disable;
© 2018 Devart
Reference 350
Class
TDAConditions
Syntax
procedure Enable;
5.9.1.9.3.5 Find Method
Search for TDACondition (the condition) by its name. If found, the TDACondition object is
returned, otherwise - nil.
Class
TDAConditions
Syntax
function Find(const Name: string): TDACondition;
Parameters
Name
5.9.1.9.3.6 Get Method
Retrieving a TDACondition object by its name. If found, the TDACondition object is returned,
otherwise - an exception is raised.
Class
TDAConditions
Syntax
function Get(const Name: string): TDACondition;
Parameters
Name
5.9.1.9.3.7 IndexOf Method
Retrieving condition index by its name. If found, this condition index is returned, otherwise -
the method returns -1.
© 2018 Devart
351 PostgreSQL Data Access Components
Class
TDAConditions
Syntax
function IndexOf(const Name: string): Integer;
Parameters
Name
5.9.1.9.3.8 Remove Method
Class
TDAConditions
Syntax
procedure Remove(const Name: string);
Parameters
Name
Specifies the name of the removed condition
5.9.1.10 TDAConnectionOptions Class
Unit
DBAccess
Syntax
TDAConnectionOptions = class(TPersistent);
5.9.1.10.1 Members
Properties
Name Description
© 2018 Devart
Reference 352
Public
Name Description
Used to determine the default type of local sorting
for string fields. It is used when a sort type is not
DefaultSortType specified explicitly after the field name in the
TMemDataSet.IndexFieldNames property of a
dataset.
Used to open a connection only when needed for
DisconnectedMode performing a server call and closes after
performing the operation.
KeepDesignConnected Used to prevent an application from establishing a
connection at the time of startup.
If True, the
LocalFailover TCustomDAConnection.OnConnectionLost event
occurs and a failover operation can be performed
after connection breaks.
Published
© 2018 Devart
353 PostgreSQL Data Access Components
Name Description
AllowImplicitConnect Specifies whether to allow or not implicit
connection opening.
See Also
TDAConnectionOptions Class
TDAConnectionOptions Class Members
Class
TDAConnectionOptions
Syntax
property AllowImplicitConnect: boolean default True;
Remarks
Use the AllowImplicitConnect property to specify whether allow or not implicit connection
opening.
If a closed connection has AllowImplicitConnect set to True and a dataset that uses the
connection is opened, the connection is opened implicitly to allow opening the dataset.
If a closed connection has AllowImplicitConnect set to False and a dataset that uses the
connection is opened, an exception is raised.
The default value is True.
5.9.1.10.2.2 DefaultSortType Property
Used to determine the default type of local sorting for string fields. It is used when a sort type
is not specified explicitly after the field name in the TMemDataSet.IndexFieldNames property
of a dataset.
Class
TDAConnectionOptions
Syntax
property DefaultSortType: TSortType default stCaseSensitive;
© 2018 Devart
Reference 354
Remarks
Use the DefaultSortType property to determine the default type of local sorting for string fields.
It is used when a sort type is not specified explicitly after the field name in the
TMemDataSet.IndexFieldNames property of a dataset.
5.9.1.10.2.3 DisconnectedMode Property
Used to open a connection only when needed for performing a server call and closes after
performing the operation.
Class
TDAConnectionOptions
Syntax
property DisconnectedMode: boolean default False;
Remarks
If True, connection opens only when needed for performing a server call and closes after
performing the operation. Datasets remain opened when connection closes. May be useful to
save server resources and operate in unstable or expensive network. Drawback of using
disconnect mode is that each connection establishing requires some time for authorization. If
connection is often closed and opened it can slow down the application work. See the
Disconnected Mode topic for more information.
5.9.1.10.2.4 KeepDesignConnected Property
Class
TDAConnectionOptions
Syntax
property KeepDesignConnected: boolean default True;
Remarks
At the time of startup prevents application from establishing a connection even if the
Connected property was set to True at design-time. Set KeepDesignConnected to False to
initialize the connected property to False, even if it was True at design-time.
© 2018 Devart
355 PostgreSQL Data Access Components
Class
TDAConnectionOptions
Syntax
property LocalFailover: boolean default False;
Remarks
If True, the TCustomDAConnection.OnConnectionLost event occurs and a failover operation
can be performed after connection breaks. Read the Working in an Unstable Network topic for
more information about using failover.
Unit
DBAccess
Syntax
TDADataSetOptions = class(TPersistent);
5.9.1.11.1 Members
Properties
Name Description
Used to execute automatic
AutoPrepare TCustomDADataSet.Prepare on the query
execution.
CacheCalcFields Used to enable caching of the TField.Calculated
and TField.Lookup fields.
© 2018 Devart
Reference 356
© 2018 Devart
357 PostgreSQL Data Access Components
Public
Name Description
Used to execute automatic
AutoPrepare TCustomDADataSet.Prepare on the query
execution.
CacheCalcFields Used to enable caching of the TField.Calculated
and TField.Lookup fields.
© 2018 Devart
Reference 358
See Also
© 2018 Devart
359 PostgreSQL Data Access Components
TDADataSetOptions Class
TDADataSetOptions Class Members
Class
TDADataSetOptions
Syntax
property AutoPrepare: boolean default False;
Remarks
Use the AutoPrepare property to execute automatic TCustomDADataSet.Prepare on the
query execution. Makes sense for cases when a query will be executed several times, for
example, in Master/Detail relationships.
5.9.1.11.2.2 CacheCalcFields Property
Class
TDADataSetOptions
Syntax
property CacheCalcFields: boolean default False;
Remarks
Use the CacheCalcFields property to enable caching of the TField.Calculated and
TField.Lookup fields. It can be useful for reducing CPU usage for calculated fields. Using
caching of calculated and lookup fields increases memory usage on the client side.
5.9.1.11.2.3 CompressBlobMode Property
Class
TDADataSetOptions
Syntax
© 2018 Devart
Reference 360
Remarks
Use the CompressBlobMode property to store values of the BLOB fields in compressed form.
Add the MemData unit to uses list to use this option. Compression rate greatly depends on
stored data, for example, usually graphic data compresses badly unlike text.
5.9.1.11.2.4 DefaultValues Property
Used to request default values/expressions from the server and assign them to the
DefaultExpression property.
Class
TDADataSetOptions
Syntax
property DefaultValues: boolean default False;
Remarks
If True, the default values/expressions are requested from the server and assigned to the
DefaultExpression property of TField objects replacing already existent values.
5.9.1.11.2.5 DetailDelay Property
Used to get or set a delay in milliseconds before refreshing detail dataset while navigating
master dataset.
Class
TDADataSetOptions
Syntax
property DetailDelay: integer default 0;
Remarks
Use the DetailDelay property to get or set a delay in milliseconds before refreshing detail
dataset while navigating master dataset. If DetailDelay is 0 (the default value) then refreshing
of detail dataset occurs immediately. The DetailDelay option should be used for detail dataset.
© 2018 Devart
361 PostgreSQL Data Access Components
Used for TCustomDADataSet to fill the Origin property of the TField objects by appropriate
value when opening a dataset.
Class
TDADataSetOptions
Syntax
property FieldsOrigin: boolean;
Remarks
If True, TCustomDADataSet fills the Origin property of the TField objects by appropriate value
when opening a dataset.
5.9.1.11.2.7 FlatBuffers Property
Used to control how a dataset treats data of the ftString and ftVarBytes fields.
Class
TDADataSetOptions
Syntax
property FlatBuffers: boolean default False;
Remarks
Use the FlatBuffers property to control how a dataset treats data of the ftString and ftVarBytes
fields. When set to True, all data fetched from the server is stored in record pdata without
unused tails.
5.9.1.11.2.8 InsertAllSetFields Property
Used to include all set dataset fields in the generated INSERT statement
Class
TDADataSetOptions
Syntax
property InsertAllSetFields: boolean default False;
© 2018 Devart
Reference 362
Remarks
If True, all set dataset fields, including those set to NULL explicitly, will be included in the
generated INSERT statements. Otherwise, only set fields containing not NULL values will be
included to the generated INSERT statement.
5.9.1.11.2.9 LocalMasterDetail Property
Used for TCustomDADataSet to use local filtering to establish master/detail relationship for
detail dataset and does not refer to the server.
Class
TDADataSetOptions
Syntax
property LocalMasterDetail: boolean default False;
Remarks
If True, for detail dataset in master-detail relationship TCustomDADataSet uses local filtering
for establishing master/detail relationship and does not refer to the server. Otherwise detail
dataset performs query each time a record is selected in master dataset. This option is useful
for reducing server calls number, server resources economy. It can be useful for slow
connection. The TMemDataSet.CachedUpdates mode can be used for detail dataset only
when this option is set to true. Setting the LocalMasterDetail option to True is not
recommended when detail table contains too many rows, because when it is set to False,
only records that correspond to the current record in master dataset are fetched.
5.9.1.11.2.10 LongStrings Property
Used to represent string fields with the length that is greater than 255 as TStringField.
Class
TDADataSetOptions
Syntax
property LongStrings: boolean default True;
Remarks
Use the LongStrings property to represent string fields with the length that is greater than 255
as TStringField, not as TMemoField.
© 2018 Devart
363 PostgreSQL Data Access Components
Allows to use NULL values in the fields by which the relation is built, when generating the
query for the Detail tables (when this option is enabled, the performance can get worse).
Class
TDADataSetOptions
Syntax
property MasterFieldsNullable: boolean default False;
5.9.1.11.2.12 NumberRange Property
Used to set the MaxValue and MinValue properties of TIntegerField and TFloatField to
appropriate values.
Class
TDADataSetOptions
Syntax
property NumberRange: boolean default False;
Remarks
Use the NumberRange property to set the MaxValue and MinValue properties of TIntegerField
and TFloatField to appropriate values.
5.9.1.11.2.13 QueryRecCount Property
Used for TCustomDADataSet to perform additional query to get the record count for this
SELECT, so the RecordCount property reflects the actual number of records.
Class
TDADataSetOptions
Syntax
property QueryRecCount: boolean default False;
Remarks
If True, and the FetchAll property is False, TCustomDADataSet performs additional query to
get the record count for this SELECT, so the RecordCount property reflects the actual
© 2018 Devart
Reference 364
number of records. Does not have any effect if the FetchAll property is True.
5.9.1.11.2.14 QuoteNames Property
Used for TCustomDADataSet to quote all database object names in autogenerated SQL
statements such as update SQL.
Class
TDADataSetOptions
Syntax
property QuoteNames: boolean default False;
Remarks
If True, TCustomDADataSet quotes all database object names in autogenerated SQL
statements such as update SQL.
5.9.1.11.2.15 RemoveOnRefresh Property
Used for a dataset to locally remove a record that can not be found on the server.
Class
TDADataSetOptions
Syntax
property RemoveOnRefresh: boolean default True;
Remarks
When the RefreshRecord procedure can't find necessary record on the server and
RemoveOnRefresh is set to True, dataset removes the record locally. Usually
RefreshRecord can't find necessary record when someone else dropped the record or
changed the key value of it.
This option makes sense only if the StrictUpdate option is set to False. If the StrictUpdate
option is True, error will be generated regardless of the RemoveOnRefresh option value.
5.9.1.11.2.16 RequiredFields Property
Used for TCustomDADataSet to set the Required property of the TField objects for the NOT
NULL fields.
Class
© 2018 Devart
365 PostgreSQL Data Access Components
TDADataSetOptions
Syntax
property RequiredFields: boolean default True;
Remarks
If True, TCustomDADataSet sets the Required property of the TField objects for the NOT
NULL fields. It is useful when table has a trigger which updates the NOT NULL fields.
5.9.1.11.2.17 ReturnParams Property
Used to return the new value of fields to dataset after insert or update.
Class
TDADataSetOptions
Syntax
property ReturnParams: boolean default False;
Remarks
Use the ReturnParams property to return the new value of fields to dataset after insert or
update. The actual value of field after insert or update may be different from the value stored
in the local memory if the table has a trigger. When ReturnParams is True, OUT parameters
of the SQLInsert and SQLUpdate statements is assigned to the corresponding fields.
5.9.1.11.2.18 SetFieldsReadOnly Property
Used for a dataset to set the ReadOnly property to True for all fields that do not belong to
UpdatingTable or can not be updated.
Class
TDADataSetOptions
Syntax
property SetFieldsReadOnly: boolean default True;
Remarks
If True, dataset sets the ReadOnly property to True for all fields that do not belong to
UpdatingTable or can not be updated. Set this option for datasets that use automatic
© 2018 Devart
Reference 366
Used for TCustomDADataSet to raise an exception when the number of updated or deleted
records is not equal 1.
Class
TDADataSetOptions
Syntax
property StrictUpdate: boolean default True;
Remarks
If True, TCustomDADataSet raises an exception when the number of updated or deleted
records is not equal 1. Setting this option also causes the exception if the RefreshRecord
procedure returns more than one record. The exception does not occur when you execute
SQL query, that doesn't return resultset.
Note: There can be problems if this option is set to True and triggers for UPDATE, DELETE,
REFRESH commands that are defined for the table. So it is recommended to disable (set to
False) this option with triggers.
TrimFixedChar specifies whether to discard all trailing spaces in the string fields of a dataset.
5.9.1.11.2.20 TrimFixedChar Property
Specifies whether to discard all trailing spaces in the string fields of a dataset.
Class
TDADataSetOptions
Syntax
property TrimFixedChar: boolean default True;
Remarks
Specifies whether to discard all trailing spaces in the string fields of a dataset.
5.9.1.11.2.21 UpdateAllFields Property
Used to include all dataset fields in the generated UPDATE and INSERT statements.
Class
© 2018 Devart
367 PostgreSQL Data Access Components
TDADataSetOptions
Syntax
property UpdateAllFields: boolean default False;
Remarks
If True, all dataset fields will be included in the generated UPDATE and INSERT statements.
Unspecified fields will have NULL value in the INSERT statements. Otherwise, only updated
fields will be included to the generated update statements.
5.9.1.11.2.22 UpdateBatchSize Property
Used to get or set a value that enables or disables batch processing support, and specifies
the number of commands that can be executed in a batch.
Class
TDADataSetOptions
Syntax
property UpdateBatchSize: Integer default 1;
Remarks
Use the UpdateBatchSize property to get or set a value that enables or disables batch
processing support, and specifies the number of commands that can be executed in a batch.
Takes effect only when updating dataset in the TMemDataSet.CachedUpdates mode. The
default value is 1.
Unit
DBAccess
Syntax
TDAEncryption = class(TPersistent);
Remarks
© 2018 Devart
Reference 368
Set the properties of Encryption to specify the options of the data encryption in a dataset.
5.9.1.12.1 Members
Properties
Name Description
Encryptor Used to specify the encryptor class that will
perform the data encryption.
5.9.1.12.2 Properties
Public
Name Description
Published
Name Description
Fields Used to set field names for which encryption will
be performed.
See Also
TDAEncryption Class
TDAEncryption Class Members
Used to specify the encryptor class that will perform the data encryption.
Class
© 2018 Devart
369 PostgreSQL Data Access Components
TDAEncryption
Syntax
property Encryptor: TCREncryptor;
Remarks
Use the Encryptor property to specify the encryptor class that will perform the data
encryption.
5.9.1.12.2.2 Fields Property
Class
TDAEncryption
Syntax
property Fields: string;
Remarks
Used to set field names for which encryption will be performed. Field names must be
separated by semicolons.
Unit
DBAccess
Syntax
TDAMapRule = class(TMapRule);
Remarks
Using properties of this class, it is possible to change parameter values of the specified rules
from the TDAMapRules set.
Inheritance Hierarchy
© 2018 Devart
Reference 370
TMapRule
TDAMapRule
5.9.1.13.1 Members
Properties
Name Description
DBLengthMax Maximum DB field length, until which the rule is
applied.
5.9.1.13.2 Properties
Published
© 2018 Devart
371 PostgreSQL Data Access Components
Name Description
DBLengthMax Maximum DB field length, until which the rule is
applied.
See Also
TDAMapRule Class
TDAMapRule Class Members
Class
TDAMapRule
Syntax
property DBLengthMax: Integer default rlAny;
Remarks
© 2018 Devart
Reference 372
Setting maximum DB field length, until which the rule is applied to the specified DB field.
5.9.1.13.2.2 DBLengthMin Property
Class
TDAMapRule
Syntax
property DBLengthMin: Integer default rlAny;
Remarks
Setting minimum DB field length, starting from which the rule is applied to the specified DB
field.
5.9.1.13.2.3 DBScaleMax Property
Maximum DB field scale, until which the rule is applied to the specified DB field.
Class
TDAMapRule
Syntax
property DBScaleMax: Integer default rlAny;
Remarks
Setting maximum DB field scale, until which the rule is applied to the specified DB field.
5.9.1.13.2.4 DBScaleMin Property
Minimum DB field Scale, starting from which the rule is applied to the specified DB field.
Class
TDAMapRule
Syntax
property DBScaleMin: Integer default rlAny;
Remarks
© 2018 Devart
373 PostgreSQL Data Access Components
Setting minimum DB field Scale, starting from which the rule is applied to the specified DB
field.
5.9.1.13.2.5 DBType Property
Class
TDAMapRule
Syntax
property DBType: Word default dtUnknown;
Remarks
Setting DB field type, that the rule is applied to. If the current rule is set for Connection, the
rule will be applied to all fields of the specified type in all DataSets related to this Connection.
5.9.1.13.2.6 FieldLength Property
Class
TDAMapRule
Syntax
property FieldLength: Integer default rlAny;
Remarks
Setting the Delphi field length after conversion.
5.9.1.13.2.7 FieldName Property
Class
TDAMapRule
Syntax
property FieldName: string;
Remarks
© 2018 Devart
Reference 374
Specifies the DataSet field name, that the rule is applied to. If the current rule is set for
Connection, the rule will be applied to all fields with such name in DataSets related to this
Connection.
5.9.1.13.2.8 FieldScale Property
Class
TDAMapRule
Syntax
property FieldScale: Integer default rlAny;
Remarks
Setting the Delphi field Scale after conversion.
5.9.1.13.2.9 FieldType Property
Delphi field type, that the specified DB type or DataSet field will be mapped to.
Class
TDAMapRule
Syntax
property FieldType: TFieldType stored IsFieldTypeStored default
ftUnknown;
Remarks
Setting Delphi field type, that the specified DB type or DataSet field will be mapped to.
5.9.1.13.2.10 IgnoreErrors Property
Class
TDAMapRule
Syntax
property IgnoreErrors: Boolean default False;
© 2018 Devart
375 PostgreSQL Data Access Components
Remarks
Allows to ignore errors while data conversion in case if data or DB data format cannot be
recorded to the specified Delphi field type. The default value is false.
Used for adding rules for DataSet fields mapping with both identifying by field name and by
field type and Delphi field types.
For a list of all members of this type, see TDAMapRules members.
Unit
DBAccess
Syntax
TDAMapRules = class(TMapRules);
Inheritance Hierarchy
TMapRules
TDAMapRules
5.9.1.14.1 Members
Properties
Name Description
IgnoreInvalidRules Used to avoid raising exception on mapping rules
that can't be applied.
5.9.1.14.2 Properties
Published
Name Description
© 2018 Devart
Reference 376
See Also
TDAMapRules Class
TDAMapRules Class Members
Class
TDAMapRules
Syntax
property IgnoreInvalidRules: boolean default False;
Remarks
Allows to ignore errors (not to raise exception) during data conversion in case if the data or
DB data format cannot be recorded to the specified Delphi field type. The default value is
false.
Note: In order to ignore errors occurring during data conversion, use the
TDAMapRule.IgnoreErrors property
See Also
TDAMapRule.IgnoreErrors
A class for retrieving metainformation of the specified database objects in the form of dataset.
For a list of all members of this type, see TDAMetaData members.
Unit
DBAccess
Syntax
TDAMetaData = class(TMemDataSet);
Remarks
© 2018 Devart
377 PostgreSQL Data Access Components
Example
The code below demonstrates how to get information about columns of the 'emp' table:
MetaData.Connection := Connection;
MetaData.MetaDataKind := 'Columns';
MetaData.Restrictions.Values['TABLE_NAME'] := 'Emp';
MetaData.Open;
Inheritance Hierarchy
TMemDataSet
TDAMetaData
See Also
TDAMetaData.MetaDataKind
TDAMetaData.Restrictions
TDAMetaData.GetMetaDataKinds
TDAMetaData.GetRestrictions
5.9.1.15.1 Members
Properties
Name Description
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
© 2018 Devart
Reference 378
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
© 2018 Devart
379 PostgreSQL Data Access Components
TMemDataSet)
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 380
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
© 2018 Devart
381 PostgreSQL Data Access Components
Events
Name Description
OnUpdateError (inherited from Occurs when an exception is generated while
TMemDataSet) cached updates are applied to a database.
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.9.1.15.2 Properties
Public
Name Description
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
© 2018 Devart
Reference 382
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
See Also
TDAMetaData Class
TDAMetaData Class Members
Class
TDAMetaData
Syntax
property Connection: TCustomDAConnection;
Remarks
Use the Connection property to specify a connection object to use to connect to a data store.
Set at design-time by selecting from the list of provided TCustomDAConnection or its
descendant class objects.
At runtime, set the Connection property to reference an instanciated TCustomDAConnection
object.
© 2018 Devart
383 PostgreSQL Data Access Components
Class
TDAMetaData
Syntax
property MetaDataKind: string;
Remarks
This string property specifies which kind of metainformation to show. The value of this
property should be assigned before activating the component. If MetaDataKind equals to an
empty string (the default value), the full value list that this property accepts will be shown.
They are described in the table below:
MetaDataKind Description
Columns show metainformation about columns of existing tables
Constraints show metainformation about the constraints defined in the database
IndexColumns show metainformation about indexed columns
Indexes show metainformation about indexes in a database
show the acceptable values of this property. You will get the same
MetaDataKinds
result if the MetadataKind property is an empty string
ProcedurePara
show metainformation about parameters of existing procedures
meters
Procedures show metainformation about existing procedures
generates a dataset that describes which restrictions are applicable
Restrictions
to each MetaDataKind
Tables show metainformation about existing tables
Databases show metainformation about existing databases
If you provide a value that equals neither of the values described in the table, an error will be
raised.
See Also
Restrictions
Used to provide one or more conditions restricting the list of objects to be described.
Class
© 2018 Devart
Reference 384
TDAMetaData
Syntax
property Restrictions: TStrings;
Remarks
Use the Restriction list to provide one or more conditions restricting the list of objects to be
described. To see the full list of restrictions and to which metadata kinds they are applicable,
you should assign the Restrictions value to the MetaDataKind property and view the result.
See Also
MetaDataKind
5.9.1.15.3 Methods
Public
Name Description
ApplyRange (inherited from
Applies a range to the dataset.
TMemDataSet)
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
© 2018 Devart
385 PostgreSQL Data Access Components
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
© 2018 Devart
Reference 386
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
See Also
TDAMetaData Class
TDAMetaData Class Members
Class
TDAMetaData
Syntax
procedure GetMetaDataKinds(List: TStrings);
Parameters
List
Holds the object that will be filled with metadata kinds (restrictions).
© 2018 Devart
387 PostgreSQL Data Access Components
Remarks
Call the GetMetaDataKinds method to get values acceptable in the MetaDataKind property.
The List parameter will be cleared and then filled with values.
See Also
MetaDataKind
Class
TDAMetaData
Syntax
procedure GetRestrictions(List: TStrings; const MetaDataKind:
string);
Parameters
List
Holds the object that will be filled with metadata kinds (restrictions).
MetaDataKind
Holds the metadata kind for which restrictions are returned.
Remarks
Call the GetRestrictions method to find out which restrictions are applicable to a certain
MetaDataKind. The List parameter will be cleared and then filled with values.
See Also
Restrictions
GetMetaDataKinds
A class that forms objects to represent the values of the parameters set.
For a list of all members of this type, see TDAParam members.
Unit
DBAccess
© 2018 Devart
Reference 388
Syntax
TDAParam = class(TParam);
Remarks
Use the properties of TDAParam to set the value of a parameter. Objects that use
parameters create TDAParam objects to represent these parameters. For example,
TDAParam objects are used by TCustomDASQL, TCustomDADataSet.
TDAParam shares many properties with TField, as both describe the value of a field in a
dataset. However, a TField object has several properties to describe the field binding and the
way the field is displayed, edited, or calculated, that are not needed in a TDAParam object.
Conversely, TDAParam includes properties that indicate how the field value is passed as a
parameter.
See Also
TCustomDADataSet
TCustomDASQL
TDAParams
5.9.1.16.1 Members
Properties
Name Description
AsBlob Used to set and read the value of the BLOB
parameter as string.
© 2018 Devart
389 PostgreSQL Data Access Components
Methods
Name Description
AssignField Assigns field name and field value to a param.
5.9.1.16.2 Properties
© 2018 Devart
Reference 390
Public
Name Description
AsBlob Used to set and read the value of the BLOB
parameter as string.
Published
Name Description
DataType Indicates the data type of the parameter.
© 2018 Devart
391 PostgreSQL Data Access Components
See Also
TDAParam Class
TDAParam Class Members
Used to set and read the value of the BLOB parameter as string.
Class
TDAParam
Syntax
property AsBlob: TBlobData;
Remarks
Use the AsBlob property to set and read the value of the BLOB parameter as string. Setting
AsBlob will set the DataType property to ftBlob.
5.9.1.16.2.2 AsBlobRef Property
Used to set and read the value of the BLOB parameter as a TBlob object.
Class
TDAParam
Syntax
property AsBlobRef: TBlob;
Remarks
Use the AsBlobRef property to set and read the value of the BLOB parameter as a TBlob
object. Setting AsBlobRef will set the DataType property to ftBlob.
5.9.1.16.2.3 AsFloat Property
Class
© 2018 Devart
Reference 392
TDAParam
Syntax
property AsFloat: double;
Remarks
Use the AsFloat property to assign the value for a float field to the parameter. Setting AsFloat
will set the DataType property to dtFloat.
Read the AsFloat property to determine the value that was assigned to an output parameter,
represented as Double. The value of the parameter will be converted to the Double value if
possible.
5.9.1.16.2.4 AsInteger Property
Class
TDAParam
Syntax
property AsInteger: LongInt;
Remarks
Use the AsInteger property to assign the value for an integer field to the parameter. Setting
AsInteger will set the DataType property to dtInteger.
Read the AsInteger property to determine the value that was assigned to an output parameter,
represented as a 32-bit integer. The value of the parameter will be converted to the Integer
value if possible.
5.9.1.16.2.5 AsLargeInt Property
Class
TDAParam
Syntax
property AsLargeInt: Int64;
© 2018 Devart
393 PostgreSQL Data Access Components
Remarks
Set the AsLargeInt property to assign the value for an Int64 field to the parameter. Setting
AsLargeInt will set the DataType property to dtLargeint.
Read the AsLargeInt property to determine the value that was assigned to an output
parameter, represented as a 64-bit integer. The value of the parameter will be converted to
the Int64 value if possible.
5.9.1.16.2.6 AsMemo Property
Class
TDAParam
Syntax
property AsMemo: string;
Remarks
Use the AsMemo property to assign the value for a memo field to the parameter. Setting
AsMemo will set the DataType property to ftMemo.
5.9.1.16.2.7 AsMemoRef Property
Used to set and read the value of the memo parameter as a TBlob object.
Class
TDAParam
Syntax
property AsMemoRef: TBlob;
Remarks
Use the AsMemoRef property to set and read the value of the memo parameter as a TBlob
object. Setting AsMemoRef will set the DataType property to ftMemo.
5.9.1.16.2.8 AsSQLTimeStamp Property
Used to specify the value of the parameter when it represents a SQL timestamp field.
Class
© 2018 Devart
Reference 394
TDAParam
Syntax
property AsSQLTimeStamp: TSQLTimeStamp;
Remarks
Set the AsSQLTimeStamp property to assign the value for a SQL timestamp field to the
parameter. Setting AsSQLTimeStamp sets the DataType property to ftTimeStamp.
5.9.1.16.2.9 AsString Property
Class
TDAParam
Syntax
property AsString: string;
Remarks
Use the AsString property to assign the string value to the parameter. Setting AsString will set
the DataType property to ftString.
Read the AsString property to determine the value that was assigned to an output parameter
represented as a string. The value of the parameter will be converted to a string.
5.9.1.16.2.10 AsWideString Property
Class
TDAParam
Syntax
property AsWideString: string;
Remarks
Set AsWideString to assign the Unicode string value to the parameter. Setting AsWideString
will set the DataType property to ftWideString.
Read the AsWideString property to determine the value that was assigned to an output
© 2018 Devart
395 PostgreSQL Data Access Components
parameter, represented as a Unicode string. The value of the parameter will be converted to a
Unicode string.
Class
TDAParam
Syntax
property DataType: TFieldType stored IsDataTypeStored;
Remarks
DataType is set automatically when a value is assigned to a parameter. Do not set DataType
for bound fields, as this may cause the assigned value to be misinterpreted.
Read DataType to learn the type of data that was assigned to the parameter. Every possible
value of DataType corresponds to the type of a database field.
5.9.1.16.2.12 IsNull Property
Class
TDAParam
Syntax
property IsNull: boolean;
Remarks
Use the IsNull property to indicate whether the value assigned to a parameter is NULL.
5.9.1.16.2.13 ParamType Property
Class
TDAParam
Syntax
property ParamType default DB . ptUnknown;
© 2018 Devart
Reference 396
Remarks
Objects that use TDAParam objects to represent field parameters set ParamType to indicate
the type of use for a parameter.
To learn the description of TParamType refer to Delphi Help.
5.9.1.16.2.14 Size Property
Class
TDAParam
Syntax
property Size: integer default 0;
Remarks
Use the Size property to indicate the maximum number of characters the parameter may
contain. Use the Size property only for Output parameters of the ftString, ftFixedChar,
ftBytes, ftVarBytes, or ftWideString type.
Class
TDAParam
Syntax
property Value: variant stored IsValueStored;
Remarks
The Value property represents the value of the parameter as Variant.
Use Value in generic code that manipulates the values of parameters without the need to
know the field type the parameter represent.
5.9.1.16.3 Methods
© 2018 Devart
397 PostgreSQL Data Access Components
Public
Name Description
AssignField Assigns field name and field value to a param.
See Also
TDAParam Class
TDAParam Class Members
Class
TDAParam
Syntax
procedure AssignField(Field: TField);
Parameters
Field
Holds the field which name and value should be assigned to the param.
Remarks
Call the AssignField method to assign field name and field value to a param.
© 2018 Devart
Reference 398
Class
TDAParam
Syntax
procedure AssignFieldValue(Field: TField; const Value: Variant);
virtual;
Parameters
Field
Holds the field the properties of which will be assigned to the parameter.
Value
Holds the value for the parameter.
Remarks
Call the AssignFieldValue method to assign the specified field properties and value to a
parameter.
5.9.1.16.3.3 LoadFromFile Method
Class
TDAParam
Syntax
procedure LoadFromFile(const FileName: string; BlobType:
TBlobType);
Parameters
FileName
Holds the name of the file.
BlobType
Holds a value that modifies the DataType property so that this TDAParam object now holds
the BLOB value.
Remarks
Use the LoadFromFile method to place the content of a file specified by FileName into a
© 2018 Devart
399 PostgreSQL Data Access Components
TDAParam object. The BlobType value modifies the DataType property so that this
TDAParam object now holds the BLOB value.
See Also
LoadFromStream
Class
TDAParam
Syntax
procedure LoadFromStream(Stream: TStream; BlobType: TBlobType);
virtual;
Parameters
Stream
Holds the stream to copy content from.
BlobType
Holds a value that modifies the DataType property so that this TDAParam object now holds
the BLOB value.
Remarks
Call the LoadFromStream method to place the content from a stream into a TDAParam
object. The BlobType value modifies the DataType property so that this TDAParam object
now holds the BLOB value.
See Also
LoadFromFile
Class
TDAParam
Overload List
© 2018 Devart
Reference 400
Name Description
SetBlobData(Buffer: TValueBuffer) Writes the data from a specified buffer to
BLOB.
SetBlobData(Buffer: IntPtr; Size: Integer) Writes the data from a specified buffer to
BLOB.
Writes the data from a specified buffer to BLOB.
Class
TDAParam
Syntax
procedure SetBlobData(Buffer: TValueBuffer); overload;
Parameters
Buffer
Holds the pointer to the data.
Writes the data from a specified buffer to BLOB.
Class
TDAParam
Syntax
procedure SetBlobData(Buffer: IntPtr; Size: Integer); overload;
Parameters
Buffer
Holds the pointer to data.
Size
Holds the number of bytes to read from the buffer.
Remarks
Call the SetBlobData method to write data from a specified buffer to BLOB.
This class is used to manage a list of TDAParam objects for an object that uses field
parameters.
For a list of all members of this type, see TDAParams members.
© 2018 Devart
401 PostgreSQL Data Access Components
Unit
DBAccess
Syntax
TDAParams = class(TParams);
Remarks
Use TDAParams to manage a list of TDAParam objects for an object that uses field
parameters. For example, TCustomDADataSet objects and TCustomDASQL objects use
TDAParams objects to create and access their parameters.
See Also
TCustomDADataSet.Params
TCustomDASQL.Params
TDAParam
5.9.1.17.1 Members
Properties
Name Description
Items Used to interate through all parameters.
Methods
Name Description
FindParam Searches for a parameter with the specified
name.
5.9.1.17.2 Properties
© 2018 Devart
Reference 402
Public
Name Description
Items Used to interate through all parameters.
See Also
TDAParams Class
TDAParams Class Members
Class
TDAParams
Syntax
property Items[Index: integer]: TDAParam; default;
Parameters
Index
Holds an index in the range 0..Count - 1.
Remarks
Use the Items property to iterate through all parameters. Index identifies the index in the range
0..Count - 1. Items can reference a particular parameter by its index, but the ParamByName
method is preferred in order to avoid depending on the order of the parameters.
5.9.1.17.3 Methods
Public
Name Description
FindParam Searches for a parameter with the specified
name.
© 2018 Devart
403 PostgreSQL Data Access Components
See Also
TDAParams Class
TDAParams Class Members
Class
TDAParams
Syntax
function FindParam(const Value: string): TDAParam;
Parameters
Value
Holds the parameter name.
Return Value
a parameter, if a match was found. Nil otherwise.
Remarks
Use the FindParam method to find a parameter with the name passed in Value. If a match is
found, FindParam returns the parameter. Otherwise, it returns nil. Use this method rather
than a direct reference to the Items property to avoid depending on the order of the entries.
To locate more than one parameter at a time by name, use the GetParamList method
instead. To get only the value of a named parameter, use the ParamValues property.
5.9.1.17.3.2 ParamByName Method
Class
TDAParams
Syntax
function ParamByName(const Value: string): TDAParam;
© 2018 Devart
Reference 404
Parameters
Value
Holds the parameter name.
Return Value
a parameter, if the match was found. otherwise an exception is raised.
Remarks
Use the ParamByName method to find a parameter with the name passed in Value. If a
match was found, ParamByName returns the parameter. Otherwise, an exception is raised.
Use this method rather than a direct reference to the Items property to avoid depending on the
order of the entries.
To locate a parameter by name without raising an exception if the parameter is not found, use
the FindParam method.
Unit
DBAccess
Syntax
TDATransaction = class(TComponent);
Remarks
TDATransaction is a base class for components implementing functionality for managing
transactions.
Do not create instances of TDATransaction. Use descendants of the TDATransaction class
instead.
5.9.1.18.1 Members
Properties
Name Description
Active Used to determine if the transaction is active.
© 2018 Devart
405 PostgreSQL Data Access Components
Methods
Name Description
Events
Name Description
OnCommit Occurs after the transaction has been successfully
committed.
5.9.1.18.2 Properties
Public
Name Description
© 2018 Devart
Reference 406
See Also
TDATransaction Class
TDATransaction Class Members
Class
TDATransaction
Syntax
property Active: boolean;
Remarks
Indicates whether the transaction is active. This property is read-only.
5.9.1.18.2.2 DefaultCloseAction Property
Used to specify the transaction behaviour when it is destroyed while being active, or when
one of its connections is closed with the active transaction.
Class
TDATransaction
Syntax
property DefaultCloseAction: TCRTransactionAction default
taRollback;
Remarks
Use DefaultCloseAction to specify the transaction behaviour when it is destroyed while being
active, or when one of its connections is closed with the active transaction.
© 2018 Devart
407 PostgreSQL Data Access Components
5.9.1.18.3 Methods
Public
Name Description
See Also
TDATransaction Class
TDATransaction Class Members
Class
TDATransaction
Syntax
procedure Commit; virtual;
Remarks
Call the Commit method to commit the current transaction. On commit server writes
permanently all pending data updates associated with the current transaction to the database,
and then finishes the transaction.
See Also
Rollback
StartTransaction
© 2018 Devart
Reference 408
Discards all modifications of data associated with the current transaction and ends the
transaction.
Class
TDATransaction
Syntax
procedure Rollback; virtual;
Remarks
Call Rollback to cancel all data modifications made within the current transaction to the
database server, and finish the transaction.
See Also
Commit
StartTransaction
Class
TDATransaction
Syntax
procedure StartTransaction; virtual;
Remarks
Call the StartTransaction method to begin a new transaction against the database server.
Before calling StartTransaction, an application should check the Active property. If
TDATransaction.Active is True, indicating that a transaction is already in progress, a
subsequent call to StartTransaction will raise EDatabaseError. An active transaction must be
finished by call to Commit or Rollback before call to StartTransaction. Call to StartTransaction
when connection is closed also will raise EDatabaseError.
Updates, insertions, and deletions that take place after a call to StartTransaction are held by
the server until the application calls Commit to save the changes, or Rollback to cancel them.
© 2018 Devart
409 PostgreSQL Data Access Components
See Also
Commit
Rollback
5.9.1.18.4 Events
Public
Name Description
OnCommit Occurs after the transaction has been successfully
committed.
See Also
TDATransaction Class
TDATransaction Class Members
Class
TDATransaction
Syntax
property OnCommit: TNotifyEvent;
Remarks
© 2018 Devart
Reference 410
See Also
Commit
M:Devart.PgDac.TPgTransaction.CommitRetaining()
OnCommitRetaining
OnError
Class
TDATransaction
Syntax
property OnCommitRetaining: TNotifyEvent;
Remarks
The OnCommitRetaining event fires when the
M:Devart.PgDac.TPgTransaction.CommitRetaining() method is executed, just after the
transaction is successfully committed. In order to respond to the
M:Devart.Dac.TDATransaction.Commit method execution, the OnCommit event is used.
When an error occurs during commit, the OnError event fired.
See Also
M:Devart.PgDac.TPgTransaction.CommitRetaining()
Commit
OnCommit
OnError
Class
© 2018 Devart
411 PostgreSQL Data Access Components
TDATransaction
Syntax
property OnError: TDATransactionErrorEvent;
Remarks
Add a handler to the OnError event to process errors that occur during executing a
transaction control statements such as Commit, Rollback. Check the E parameter to get the
error code.
See Also
Commit
Rollback
StartTransaction
Class
TDATransaction
Syntax
property OnRollback: TNotifyEvent;
Remarks
The OnRollback event fires when the M:Devart.Dac.TDATransaction.Rollback method is
executed, just after the transaction is successfully rolled back. In order to respond to the
M:Devart.PgDac.TPgTransaction.RollbackRetaining() method execution, the
OnRollbackRetaining event is used.
When an error occurs during rollback, the OnError event fired.
See Also
Rollback
M:Devart.PgDac.TPgTransaction.RollbackRetaining()
OnRollbackRetaining
OnError
© 2018 Devart
Reference 412
Class
TDATransaction
Syntax
property OnRollbackRetaining: TNotifyEvent;
Remarks
The OnRollbackRetaining event fires when the
M:Devart.PgDac.TPgTransaction.RollbackRetaining() method is executed, just after the
transaction is successfully rolled back. In order to respond to the
M:Devart.Dac.TDATransaction.Rollback method execution, the OnRollback event is used.
When an error occurs during rollback, the OnError event fired.
See Also
Rollback
M:Devart.PgDac.TPgTransaction.RollbackRetaining()
OnRollback
OnError
Unit
DBAccess
Syntax
TMacro = class(TCollectionItem);
Remarks
TMacro object represents the value of a macro. Macro is a variable that holds string value.
You just insert & MacroName in a SQL query text and change the value of macro by the
Macro property editor at design time or the Value property at run time. At the time of opening
query macro is replaced by its value.
© 2018 Devart
413 PostgreSQL Data Access Components
If by any reason it is not convenient for you to use the ' & ' symbol as a character of macro
replacement, change the value of the MacroChar variable.
See Also
TMacros
5.9.1.19.1 Members
Properties
Name Description
Active Used to determine if the macro should be
expanded.
5.9.1.19.2 Properties
Public
Name Description
AsDateTime Used to set the TDataTime value to a macro.
© 2018 Devart
Reference 414
Published
Name Description
Active Used to determine if the macro should be
expanded.
See Also
TMacro Class
TMacro Class Members
Class
TMacro
Syntax
property Active: boolean default True;
Remarks
When set to True, the macro will be expanded, otherwise macro definition is replaced by null
string. You can use the Active property to modify the SQL property.
The default value is True.
Example
PgQuery.SQL.Text := 'SELECT * FROM Dept WHERE DeptNo > 20 &Cond1';
PgQuery.Macros[0].Value := 'and DName is NULL';
PgQuery.Macros[0].Active:= False;
© 2018 Devart
415 PostgreSQL Data Access Components
Class
TMacro
Syntax
property AsDateTime: TDateTime;
Remarks
Use the AsDataTime property to set the TDataTime value to a macro.
5.9.1.19.2.3 AsFloat Property
Class
TMacro
Syntax
property AsFloat: double;
Remarks
Use the AsFloat property to set the float value to a macro.
5.9.1.19.2.4 AsInteger Property
Class
TMacro
Syntax
property AsInteger: integer;
Remarks
Use the AsInteger property to set the integer value to a macro.
© 2018 Devart
Reference 416
Class
TMacro
Syntax
property AsString: string;
Remarks
Use the AsString property to assign the string value to a macro. Read the AsString property to
determine the value of macro represented as a string.
5.9.1.19.2.6 Name Property
Class
TMacro
Syntax
property Name: string;
Remarks
Use the Name property to identify a particular macro.
5.9.1.19.2.7 Value Property
Class
TMacro
Syntax
property Value: string;
Remarks
Use the Value property to set the value to a macro.
© 2018 Devart
417 PostgreSQL Data Access Components
Unit
DBAccess
Syntax
TMacros = class(TCollection);
Remarks
Use TMacros to manage a list of TMacro objects for the TCustomDASQL or
TCustomDADataSet components.
See Also
TMacro
5.9.1.20.1 Members
Properties
Name Description
Items Used to iterate through all the macros parameters.
Methods
Name Description
AssignValues Copies the macros values and properties from the
specified source.
© 2018 Devart
Reference 418
Public
Name Description
Items Used to iterate through all the macros parameters.
See Also
TMacros Class
TMacros Class Members
Class
TMacros
Syntax
property Items[Index: integer]: TMacro; default;
Parameters
Index
Holds the index in the range 0..Count - 1.
Remarks
Use the Items property to iterate through all macros parameters. Index identifies the index in
the range 0..Count - 1.
© 2018 Devart
419 PostgreSQL Data Access Components
5.9.1.20.3 Methods
Public
Name Description
AssignValues Copies the macros values and properties from the
specified source.
See Also
TMacros Class
TMacros Class Members
Copies the macros values and properties from the specified source.
Class
TMacros
Syntax
procedure AssignValues(Value: TMacros);
Parameters
Value
Holds the source to copy the macros values and properties from.
Remarks
© 2018 Devart
Reference 420
The Assign method copies the macros values and properties from the specified source.
Macros are not recreated. Only the values of macros with matching names are assigned.
5.9.1.20.3.2 Expand Method
Class
TMacros
Syntax
procedure Expand(var SQL: string);
Parameters
SQL
Holds the passed SQL statement.
Remarks
Call the Expand method to change the macros in the passed SQL statement to their values.
5.9.1.20.3.3 FindMacro Method
Class
TMacros
Syntax
function FindMacro(const Value: string): TMacro;
Parameters
Value
Holds the value of a macro to search for.
Return Value
TMacro object if a match was found, nil otherwise.
Remarks
Call the FindMacro method to find a macro with the name passed in Value. If a match is
found, FindMacro returns the macro. Otherwise, it returns nil. Use this method rather than a
direct reference to the Items property to avoid depending on the order of the entries.
© 2018 Devart
421 PostgreSQL Data Access Components
Class
TMacros
Syntax
function IsEqual(Value: TMacros): boolean;
Parameters
Value
Holds the values of TMacro objects.
Return Value
True, if the number of TMacro objects and the values of all TMacro objects are equal.
Remarks
Call the IsEqual method to compare itself with another TMacro object. Returns True if the
number of TMacro objects and the values of all TMacro objects are equal.
5.9.1.20.3.5 MacroByName Method
Class
TMacros
Syntax
function MacroByName(const Value: string): TMacro;
Parameters
Value
Holds a name of the macro to search for.
Return Value
TMacro object, if a macro with specified name was found.
Remarks
Call the MacroByName method to find a Macro with the name passed in Value. If a match is
found, MacroByName returns the Macro. Otherwise, an exception is raised. Use this method
rather than a direct reference to the Items property to avoid depending on the order of the
entries.
© 2018 Devart
Reference 422
To locate a macro by name without raising an exception if the parameter is not found, use the
FindMacro method.
Class
TMacros
Syntax
procedure Scan(const SQL: string);
Parameters
SQL
Holds the passed SQL statement.
Remarks
Call the Scan method to create a macros from the passed SQL statement. On that all
existing TMacro objects are cleared.
Unit
DBAccess
Syntax
TPoolingOptions = class(TPersistent);
5.9.1.21.1 Members
Properties
Name Description
Used to specify the maximum time during which an
ConnectionLifetime opened connection can be used by connection
pool.
© 2018 Devart
423 PostgreSQL Data Access Components
Published
Name Description
Used to specify the maximum time during which an
ConnectionLifetime opened connection can be used by connection
pool.
Used to specify the maximum number of
MaxPoolSize connections that can be opened in connection
pool.
Used to specify the minimum number of
MinPoolSize connections that can be opened in the connection
pool.
Validate Used for a connection to be validated when it is
returned from the pool.
See Also
TPoolingOptions Class
TPoolingOptions Class Members
Used to specify the maximum time during which an opened connection can be used by
connection pool.
Class
TPoolingOptions
© 2018 Devart
Reference 424
Syntax
property ConnectionLifetime: integer default
DefValConnectionLifetime;
Remarks
Use the ConnectionLifeTime property to specify the maximum time during which an opened
connection can be used by connection pool. Measured in milliseconds. Pool deletes
connections with exceeded connection lifetime when TCustomDAConnection is about to
close. If the ConnectionLifetime property is set to 0 (by default), then the lifetime of connection
is infinity. ConnectionLifetime concerns only inactive connections in the pool.
5.9.1.21.2.2 MaxPoolSize Property
Used to specify the maximum number of connections that can be opened in connection pool.
Class
TPoolingOptions
Syntax
property MaxPoolSize: integer default DefValMaxPoolSize;
Remarks
Specifies the maximum number of connections that can be opened in connection pool. Once
this value is reached, no more connections are opened. The valid values are 1 and higher.
5.9.1.21.2.3 MinPoolSize Property
Used to specify the minimum number of connections that can be opened in the connection
pool.
Class
TPoolingOptions
Syntax
property MinPoolSize: integer default DefValMinPoolSize;
Remarks
Use the MinPoolSize property to specify the minimum number of connections that can be
opened in the connection pool.
© 2018 Devart
425 PostgreSQL Data Access Components
Class
TPoolingOptions
Syntax
property Validate: boolean default DefValValidate;
Remarks
If the Validate property is set to True, connection will be validated when it is returned from the
pool. By default this option is set to False and pool does not validate connection when it is
returned to be used by a TCustomDAConnection component.
Smart fetch options are used to set up the behavior of the SmartFetch mode.
For a list of all members of this type, see TSmartFetchOptions members.
Unit
DBAccess
Syntax
TSmartFetchOptions = class(TPersistent);
5.9.1.22.1 Members
Properties
Name Description
Enabled Sets SmartFetch mode enabled or not.
© 2018 Devart
Reference 426
SQLGetKeyValues SQL query for the read key and prefetched fields
from the database.
5.9.1.22.2 Properties
Published
Name Description
Enabled Sets SmartFetch mode enabled or not.
SQLGetKeyValues SQL query for the read key and prefetched fields
from the database.
See Also
TSmartFetchOptions Class
TSmartFetchOptions Class Members
Class
TSmartFetchOptions
Syntax
property Enabled: Boolean default False;
5.9.1.22.2.2 LiveBlock Property
Class
© 2018 Devart
427 PostgreSQL Data Access Components
TSmartFetchOptions
Syntax
property LiveBlock: Boolean default True;
Remarks
If LiveBlock is True, then on navigating through a dataset forward or backward, memory will
be allocated for records count defined in the the FetchRows propety, and no additional
memory will be allocated. But if you return records that were read from the database before,
they will be read from the database again, because when you left block with these records,
memory was free. So the LiveBlock mode minimizes memory consumption, but can
decrease performance, because it can lead to repeated data reading from the database.
The default value of LiveBlock is False.
5.9.1.22.2.3 PrefetchedFields Property
List of fields additional to key fields that will be read from the database on dataset open.
Class
TSmartFetchOptions
Syntax
property PrefetchedFields: string;
Remarks
If you are going to use locate, filter or sort by some fields, then these fields should be added to
the prefetched fields list to avoid excessive reading from the database.
5.9.1.22.2.4 SQLGetKeyValues Property
SQL query for the read key and prefetched fields from the database.
Class
TSmartFetchOptions
Syntax
property SQLGetKeyValues: TStrings;
Remarks
© 2018 Devart
Reference 428
SQLGetKeyValues is used when the basic SQL query is complex and the query for reading
the key and prefetched fields can't be generated automatically.
5.9.2 Types
Types in the DBAccess unit.
Types
Name Description
This type is used for the
TAfterExecuteEvent TCustomDADataSet.AfterExecute and
TCustomDASQL.AfterExecute events.
TAfterFetchEvent This type is used for the
TCustomDADataSet.AfterFetch event.
Unit
DBAccess
Syntax
TAfterExecuteEvent = procedure (Sender: TObject; Result: boolean)
© 2018 Devart
429 PostgreSQL Data Access Components
of object;
Parameters
Sender
An object that raised the event.
Result
The result is True if SQL statement is executed successfully. False otherwise.
5.9.2.2 TAfterFetchEvent Procedure Reference
Unit
DBAccess
Syntax
TAfterFetchEvent = procedure (DataSet: TCustomDADataSet) of
object;
Parameters
DataSet
Holds the TCustomDADataSet descendant to synchronize the record position with.
5.9.2.3 TBeforeFetchEvent Procedure Reference
Unit
DBAccess
Syntax
TBeforeFetchEvent = procedure (DataSet: TCustomDADataSet; var
Cancel: boolean) of object;
Parameters
DataSet
Holds the TCustomDADataSet descendant to synchronize the record position with.
Cancel
True, if the current fetch operation should be aborted.
© 2018 Devart
Reference 430
Unit
DBAccess
Syntax
TConnectionLostEvent = procedure (Sender: TObject; Component:
TComponent; ConnLostCause: TConnLostCause; var RetryMode:
TRetryMode) of object;
Parameters
Sender
An object that raised the event.
Component
ConnLostCause
The reason of the connection loss.
RetryMode
The application behavior when connection is lost.
5.9.2.5 TDAConnectionErrorEvent Procedure Reference
Unit
DBAccess
Syntax
TDAConnectionErrorEvent = procedure (Sender: TObject; E: EDAError;
var Fail: boolean) of object;
Parameters
Sender
An object that raised the event.
E
The error information.
Fail
False, if an error dialog should be prevented from being displayed and EAbort exception
should be raised to cancel current operation .
© 2018 Devart
431 PostgreSQL Data Access Components
Unit
DBAccess
Syntax
TDATransactionErrorEvent = procedure (Sender: TObject; E:
EDAError; var Fail: boolean) of object;
Parameters
Sender
An object that raised the event.
E
The error code.
Fail
False, if an error dialog should be prevented from being displayed and EAbort exception to
cancel the current operation should be raised.
5.9.2.7 TRefreshOptions Set
Unit
DBAccess
Syntax
TRefreshOptions = set of TRefreshOption;
Unit
DBAccess
Syntax
TUpdateExecuteEvent = procedure (Sender: TDataSet; StatementTypes:
TStatementTypes; Params: TDAParams) of object;
© 2018 Devart
Reference 432
Parameters
Sender
An object that raised the event.
StatementTypes
Holds the type of the SQL statement being executed.
Params
Holds the parameters with which the SQL statement will be executed.
5.9.3 Enumerations
Enumerations in the DBAccess unit.
Enumerations
Name Description
TLabelSet Sets the languauge of labels in the connect dialog.
Unit
DBAccess
Syntax
TLabelSet = (lsCustom, lsEnglish, lsFrench, lsGerman, lsItalian,
lsPolish, lsPortuguese, lsRussian, lsSpanish);
Values
Value Meaning
lsCustom Set the language of labels in the connect dialog manually.
lsEnglish Set English as the language of labels in the connect dialog.
lsFrench Set French as the language of labels in the connect dialog.
lsGerman Set German as the language of labels in the connect dialog.
© 2018 Devart
433 PostgreSQL Data Access Components
Unit
DBAccess
Syntax
TRefreshOption = (roAfterInsert, roAfterUpdate, roBeforeEdit);
Values
Value Meaning
roAfterInsert Refresh is performed after inserting.
roAfterUpdate Refresh is performed after updating.
roBeforeEdit Refresh is performed by Edit method.
Unit
DBAccess
Syntax
TRetryMode = (rmRaise, rmReconnect, rmReconnectExecute);
Values
Value Meaning
rmRaise An exception is raised.
rmReconnect Reconnect is performed and then exception is raised.
rmReconnectExec Reconnect is performed and abortive operation is reexecuted.
ute Exception is not raised.
© 2018 Devart
Reference 434
5.9.4 Variables
Variables in the DBAccess unit.
Variables
Name Description
After assigning SQL text and modifying it by
BaseSQLOldBehavior AddWhere, DeleteWhere, and SetOrderBy, all
subsequent changes of the SQL property will not
be reflected in the BaseSQL property.
ChangeCursor When set to True allows data access components
to change screen cursor for the execution time.
The value of the TCustomDADataSet.BaseSQL
property is used to complete the refresh SQL
SQLGeneratorCompatibility statement, if the manually assigned
TCustomDAUpdateSQL.RefreshSQL property
contains only WHERE clause.
5.9.4.1 BaseSQLOldBehavior Variable
After assigning SQL text and modifying it by AddWhere, DeleteWhere, and SetOrderBy, all
subsequent changes of the SQL property will not be reflected in the BaseSQL property.
Unit
DBAccess
Syntax
BaseSQLOldBehavior: boolean = False;
Remarks
The BaseSQL property is similar to the SQL property, but it does not store changes made by
the AddWhere, DeleteWhere, and SetOrderBy methods. After assigning SQL text and
modifying it by one of these methods, all subsequent changes of the SQL property will not be
reflected in the BaseSQL property. This behavior was changed in PgDAC . To restore old
behavior, set the BaseSQLOldBehavior variable to True.
When set to True allows data access components to change screen cursor for the execution
time.
Unit
© 2018 Devart
435 PostgreSQL Data Access Components
DBAccess
Syntax
ChangeCursor: boolean = True;
The value of the TCustomDADataSet.BaseSQL property is used to complete the refresh SQL
statement, if the manually assigned TCustomDAUpdateSQL.RefreshSQL property contains
only WHERE clause.
Unit
DBAccess
Syntax
SQLGeneratorCompatibility: boolean = False;
Remarks
If the manually assigned TCustomDAUpdateSQL.RefreshSQL property contains only
WHERE clause, PgDAC uses the value of the TCustomDADataSet.BaseSQL property to
complete the refresh SQL statement. In this situation all modifications applied to the SELECT
query by functions TCustomDADataSet.AddWhere, TCustomDADataSet.DeleteWhere are
not taken into account. This behavior was changed in PgDAC . To restore the old behavior,
set the BaseSQLOldBehavior variable to True.
5.10 MemData
This unit contains classes for storing data in memory.
Classes
Name Description
TAttribute TAttribute is not used in PgDAC.
© 2018 Devart
Reference 436
Types
Name Description
TLocateExOptions Represents the set of TLocateExOption.
Enumerations
Name Description
TCompressBlobMode Specifies when the values should be compressed
and the way they should be stored.
© 2018 Devart
437 PostgreSQL Data Access Components
5.10.1 Classes
Classes in the MemData unit.
Classes
Name Description
TAttribute TAttribute is not used in PgDAC.
Unit
MemData
Syntax
TAttribute = class(System.TObject);
5.10.1.1.1 Members
Properties
© 2018 Devart
Reference 438
Name Description
AttributeNo Returns an attribute's ordinal position in object.
Public
Name Description
AttributeNo Returns an attribute's ordinal position in object.
© 2018 Devart
439 PostgreSQL Data Access Components
See Also
TAttribute Class
TAttribute Class Members
Class
TAttribute
Syntax
property AttributeNo: Word;
Remarks
Use the AttributeNo property to learn an attribute's ordinal position in object, where 1 is the
first field.
See Also
TObjectType.Attributes
Class
TAttribute
© 2018 Devart
Reference 440
Syntax
property DataSize: Integer;
Remarks
Use the DataSize property to learn the size of an attribute value in internal representation.
5.10.1.1.2.3 DataType Property
Class
TAttribute
Syntax
property DataType: Word;
Remarks
Use the DataType property to discover the type of data that was assigned to the Attribute.
Possible values: dtDate, dtFloat, dtInteger, dtString, dtObject.
5.10.1.1.2.4 Length Property
Returns the length of the string for dtString attribute and precision for dtInteger and dtFloat
attribute.
Class
TAttribute
Syntax
property Length: Word;
Remarks
Use the Length property to learn the length of the string for dtString attribute and precision for
dtInteger and dtFloat attribute.
See Also
Scale
© 2018 Devart
441 PostgreSQL Data Access Components
Class
TAttribute
Syntax
property ObjectType: TObjectType;
Remarks
Use the ObjectType property to return a TObjectType object for an object attribute.
5.10.1.1.2.6 Offset Property
Class
TAttribute
Syntax
property Offset: Integer;
Remarks
Use the DataSize property to learn an offset of the attribute value in internal representation.
5.10.1.1.2.7 Ow ner Property
Indicates TObjectType that uses the attribute to represent one of its attributes.
Class
TAttribute
Syntax
property Owner: TObjectType;
Remarks
Check the value of the Owner property to determine TObjectType that uses the attribute to
represent one of its attributes. Applications should not assign the Owner property directly.
© 2018 Devart
Reference 442
Class
TAttribute
Syntax
property Scale: Word;
Remarks
Use the Scale property to learn the scale of dtFloat and dtInteger attributes.
See Also
Length
Class
TAttribute
Syntax
property Size: Integer;
Remarks
Read Size to learn the size of an attribute value in external representation.
For example:
8
dtDate (sizeof(TDateTi
me)
8
dtFloat
(sizeof(Double))
4
dtInteger
(sizeof(Integer))
See Also
DataSize
© 2018 Devart
443 PostgreSQL Data Access Components
Holds large object value for field and parameter dtBlob, dtMemo data types.
For a list of all members of this type, see TBlob members.
Unit
MemData
Syntax
TBlob = class(TSharedObject);
Remarks
Object TBlob holds large object value for the field and parameter dtBlob, dtMemo,
dtWideMemo data types.
Inheritance Hierarchy
TSharedObject
TBlob
See Also
TMemDataSet.GetBlob
5.10.1.2.1 Members
Properties
Name Description
AsString Used to manipulate BLOB value as string.
© 2018 Devart
Reference 444
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Truncate Sets new TBlob size and discards all data over it.
5.10.1.2.2 Properties
© 2018 Devart
445 PostgreSQL Data Access Components
Public
Name Description
AsString Used to manipulate BLOB value as string.
See Also
TBlob Class
TBlob Class Members
Class
TBlob
Syntax
property AsString: string;
Remarks
Use the AsString property to manipulate BLOB value as string.
See Also
Assign
AsWideString
© 2018 Devart
Reference 446
Class
TBlob
Syntax
property AsWideString: string;
Remarks
Use the AsWideString property to manipulate BLOB value as Unicode string.
See Also
Assign
AsString
Gives choice of making TBlob store and process data in Unicode format or not.
Class
TBlob
Syntax
property IsUnicode: boolean;
Remarks
Set IsUnicode to True if you want TBlob to store and process data in Unicode format.
Note: changing this property raises an exception if TBlob is not empty.
Class
TBlob
Syntax
property Size: Cardinal;
© 2018 Devart
447 PostgreSQL Data Access Components
Remarks
Use the Size property to find out the size of the TBlob value in bytes.
5.10.1.2.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Truncate Sets new TBlob size and discards all data over it.
© 2018 Devart
Reference 448
See Also
TBlob Class
TBlob Class Members
Class
TBlob
Syntax
procedure Assign(Source: TBlob);
Parameters
Source
Holds the BLOB from which the value to the current object will be assigned.
Remarks
Call the Assign method to set BLOB value from another TBlob object.
See Also
LoadFromStream
AsString
AsWideString
Class
TBlob
Syntax
procedure Clear; virtual;
Remarks
Call the Clear method to delete the current value in TBlob object.
© 2018 Devart
449 PostgreSQL Data Access Components
Class
TBlob
Syntax
procedure LoadFromFile(const FileName: string);
Parameters
FileName
Holds the name of the file from which the TBlob value is loaded.
Remarks
Call the LoadFromFile method to load the contents of a file into a TBlob object. Specify the
name of the file to load into the field as the value of the FileName parameter.
See Also
SaveToFile
Class
TBlob
Syntax
procedure LoadFromStream(Stream: TStream); virtual;
Parameters
Stream
Holds the specified stream from which the field's value is copied.
Remarks
Call the LoadFromStream method to copy the contents of a stream into the TBlob object.
Specify the stream from which the field's value is copied as the value of the Stream
parameter.
See Also
© 2018 Devart
Reference 450
SaveToStream
Class
TBlob
Syntax
function Read(Position: Cardinal; Count: Cardinal; Dest: IntPtr):
Cardinal; virtual;
Parameters
Position
Holds the starting point of the byte sequence.
Count
Holds the size of the sequence in bytes.
Dest
Holds a pointer to the memory area where to store the sequence.
Return Value
Actually read byte count if the sequence crosses object size limit.
Remarks
Call the Read method to acquire a raw sequence of bytes from the data stored in TBlob.
The Position parameter is the starting point of byte sequence which lasts Count number of
bytes. The Dest parameter is a pointer to the memory area where to store the sequence.
If the sequence crosses object size limit, function will return actually read byte count.
See Also
Write
Class
TBlob
Syntax
procedure SaveToFile(const FileName: string);
© 2018 Devart
451 PostgreSQL Data Access Components
Parameters
FileName
Holds a string that contains the name of the file.
Remarks
Call the SaveToFile method to save the contents of the TBlob object to a file. Specify the
name of the file as the value of the FileName parameter.
See Also
LoadFromFile
Class
TBlob
Syntax
procedure SaveToStream(Stream: TStream); virtual;
Parameters
Stream
Holds the name of the stream.
Remarks
Call the SaveToStream method to copy the contents of a TBlob object to a stream. Specify
the name of the stream to which the field's value is saved as the value of the Stream
parameter.
See Also
LoadFromStream
Sets new TBlob size and discards all data over it.
Class
TBlob
Syntax
© 2018 Devart
Reference 452
Parameters
NewSize
Holds the new size of TBlob.
Remarks
Call the Truncate method to set new TBlob size and discard all data over it. If NewSize is
greater or equal TBlob.Size, it does nothing.
5.10.1.2.3.9 Write Method
Class
TBlob
Syntax
procedure Write(Position: Cardinal; Count: Cardinal; Source:
IntPtr); virtual;
Parameters
Position
Holds the starting point of the byte sequence.
Count
Holds the size of the sequence in bytes.
Source
Holds a pointer to a source memory area.
Remarks
Call the Write method to store a raw sequence of bytes into a TBlob object.
The Position parameter is the starting point of byte sequence which lasts Count number of
bytes. The Source parameter is a pointer to a source memory area.
If the value of the Position parameter crosses current size limit of TBlob object, source data
will be appended to the object data.
See Also
Read
© 2018 Devart
453 PostgreSQL Data Access Components
Holds large object value for field and parameter dtBlob, dtMemo data types and can
compress its data.
For a list of all members of this type, see TCompressedBlob members.
Unit
MemData
Syntax
TCompressedBlob = class(TBlob);
Remarks
TCompressedBlob is a descendant of the TBlob class. It holds large object value for field and
parameter dtBlob, dtMemo data types and can compress its data. For more information about
using BLOB compression see TCustomDADataSet.Options.
Note: Internal compression functions are available in CodeGear Delphi 2007 for Win32,
Borland Developer Studio 2006, Borland Delphi 2005, and Borland Delphi 7. To use BLOB
compression under Borland Delphi 6 and Borland C++ Builder you should use your own
compression functions. To use them set the CompressProc and UncompressProc variables
declared in the MemUtils unit.
Example
type
TCompressProc = function(dest: IntPtr; destLen: IntPtr; const source: In
TUncompressProc = function(dest: IntPtr; destlen: IntPtr; source: IntPtr
var
CompressProc: TCompressProc;
UncompressProc: TUncompressProc;
Inheritance Hierarchy
TSharedObject
TBlob
TCompressedBlob
See Also
TBlob
TMemDataSet.GetBlob
TCustomDADataSet.Options
© 2018 Devart
Reference 454
5.10.1.3.1 Members
Properties
Name Description
AsString (inherited from TBlob) Used to manipulate BLOB value as string.
IsUnicode (inherited from TBlob) Gives choice of making TBlob store and process
data in Unicode format or not.
Size (inherited from TBlob) Used to learn the size of the TBlob value in bytes.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Assign (inherited from TBlob) Sets BLOB value from another TBlob object.
Clear (inherited from TBlob) Deletes the current value in TBlob object.
© 2018 Devart
455 PostgreSQL Data Access Components
Read (inherited from TBlob) Acquires a raw sequence of bytes from the data
stored in TBlob.
Truncate (inherited from TBlob) Sets new TBlob size and discards all data over it.
Write (inherited from TBlob) Stores a raw sequence of bytes into a TBlob
object.
5.10.1.3.2 Properties
Public
Name Description
AsString (inherited from TBlob) Used to manipulate BLOB value as string.
© 2018 Devart
Reference 456
IsUnicode (inherited from TBlob) Gives choice of making TBlob store and process
data in Unicode format or not.
Size (inherited from TBlob) Used to learn the size of the TBlob value in bytes.
See Also
TCompressedBlob Class
TCompressedBlob Class Members
Class
TCompressedBlob
Syntax
property Compressed: boolean;
Remarks
Indicates whether the Blob is compressed. Set this property to True or False to compress or
decompress the Blob.
5.10.1.3.2.2 CompressedSize Property
Class
TCompressedBlob
Syntax
property CompressedSize: Cardinal;
© 2018 Devart
457 PostgreSQL Data Access Components
Remarks
Indicates compressed size of the Blob data.
A base class for classes that work with user-defined data types that have attributes.
For a list of all members of this type, see TDBObject members.
Unit
MemData
Syntax
TDBObject = class(TSharedObject);
Remarks
TDBObject is a base class for classes that work with user-defined data types that have
attributes.
Inheritance Hierarchy
TSharedObject
TDBObject
5.10.1.4.1 Members
Properties
Name Description
RefCount (inherited from Used to return the count of reference to a
TSharedObject) TSharedObject object.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
Reference 458
Unit
MemData
Syntax
TMemData = class(TData);
Inheritance Hierarchy
TData
TMemData
5.10.1.5.1 Members
Unit
MemData
Syntax
TObjectType = class(TSharedObject);
Inheritance Hierarchy
TSharedObject
TObjectType
© 2018 Devart
459 PostgreSQL Data Access Components
5.10.1.6.1 Members
Properties
Name Description
AttributeCount Used to indicate the number of attributes of type.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.10.1.6.2 Properties
Public
© 2018 Devart
Reference 460
Name Description
AttributeCount Used to indicate the number of attributes of type.
See Also
TObjectType Class
TObjectType Class Members
Class
TObjectType
Syntax
property AttributeCount: Integer;
Remarks
Use the AttributeCount property to determine the number of attributes of type.
5.10.1.6.2.2 Attributes Property(Indexer)
Class
TObjectType
Syntax
© 2018 Devart
461 PostgreSQL Data Access Components
Parameters
Index
Holds the attribute's ordinal position.
Remarks
Use the Attributes property to access individual attributes. The value of the Index parameter
corresponds to the AttributeNo property of TAttribute.
See Also
TAttribute
FindAttribute
Class
TObjectType
Syntax
property DataType: Word;
Remarks
Use the DataType property to determine the type of object dtObject, dtArray or dtTable.
See Also
T:Devart.Dac.Units.MemData
Class
TObjectType
Syntax
property Size: Integer;
© 2018 Devart
Reference 462
Remarks
Use the Size property to find out the size of an object instance. Size is a sum of all attribute
sizes.
See Also
TAttribute.Size
5.10.1.6.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
See Also
TObjectType Class
TObjectType Class Members
Class
TObjectType
Syntax
function FindAttribute(const Name: string): TAttribute; virtual;
© 2018 Devart
463 PostgreSQL Data Access Components
Parameters
Name
Holds the name of the attribute to search for.
Return Value
TAttribute, if an attribute with a matching name was found. Nil Otherwise.
Remarks
Call FindAttribute to determine if a specified Attribute component is referenced in the
TAttributes object. Name is the name of the Attribute for which to search. If FindAttribute finds
an Attribute with a matching name, it returns the TAttribute. Otherwise it returns nil.
See Also
TAttribute
M:Devart.Dac.TObjectType.AttributeByName(System.String)
Attributes
A base class that allows to simplify memory management for object referenced by several
other objects.
For a list of all members of this type, see TSharedObject members.
Unit
MemData
Syntax
TSharedObject = class(System.TObject);
Remarks
TSharedObject allows to simplify memory management for object referenced by several
other objects. TSharedObject holds a count of references to itself. When any object (referer
object) is going to use TSharedObject, it calls the TSharedObject.AddRef method. Referer
object has to call the TSharedObject.Release method after using TSharedObject.
See Also
TBlob
TObjectType
© 2018 Devart
Reference 464
5.10.1.7.1 Members
Properties
Name Description
RefCount Used to return the count of reference to a
TSharedObject object.
Methods
Name Description
Increments the reference count for the number of
AddRef references dependent on the TSharedObject
object.
Release Decrements the reference count.
5.10.1.7.2 Properties
Public
Name Description
See Also
TSharedObject Class
TSharedObject Class Members
Class
TSharedObject
© 2018 Devart
465 PostgreSQL Data Access Components
Syntax
property RefCount: Integer;
Remarks
Returns the count of reference to a TSharedObject object.
5.10.1.7.3 Methods
Public
Name Description
Increments the reference count for the number of
AddRef references dependent on the TSharedObject
object.
Release Decrements the reference count.
See Also
TSharedObject Class
TSharedObject Class Members
Increments the reference count for the number of references dependent on the
TSharedObject object.
Class
TSharedObject
Syntax
procedure AddRef;
Remarks
Increments the reference count for the number of references dependent on the
TSharedObject object.
© 2018 Devart
Reference 466
See Also
Release
Class
TSharedObject
Syntax
procedure Release;
Remarks
Call the Release method to decrement the reference count. When RefCount is 1,
TSharedObject is deleted from memory.
See Also
AddRef
5.10.2 Types
Types in the MemData unit.
Types
Name Description
TLocateExOptions Represents the set of TLocateExOption.
Unit
MemData
Syntax
© 2018 Devart
467 PostgreSQL Data Access Components
Unit
MemData
Syntax
TUpdateRecKinds = set of TUpdateRecKind;
5.10.3 Enumerations
Enumerations in the MemData unit.
Enumerations
Name Description
TCompressBlobMode Specifies when the values should be compressed
and the way they should be stored.
Specifies when the values should be compressed and the way they should be stored.
Unit
MemData
Syntax
© 2018 Devart
Reference 468
Values
Value Meaning
Values are compressed and stored as compressed data at the
client side. Before posting data to the server decompression is
performed and data at the server side stored in the original form.
cbClient
Allows to reduce used client memory due to increase access
time to field values. The time spent on the opening DataSet and
executing Post increases.
Values are compressed and stored in compressed form. Allows
to decrease the volume of used memory at client and server
sides. Access time to the field values increases as for cbClient.
The time spent on opening DataSet and executing Post
decreases.Note: On using cbServer or cbClientServer data on
cbClientServer the server is stored as compressed. Other applications can add
records in uncompressed format but can't read and write already
compressed data. If compressed BLOB is partially changed by
another application (if signature was not changed), DAC will
consider its value as NULL.Blob compression is not applied to
Memo fields because of possible cutting.
cbNone Values not compressed. The default value.
Values are compressed before passing to the server and store at
the server in compressed form. Allows to decrease database
cbServer size on the server. Access time to the field values does not
change. The time spent on opening DataSet and executing Post
usually decreases.
Unit
MemData
Syntax
TConnLostCause = (clUnknown, clExecute, clOpen, clRefresh, clApply,
clServiceQuery, clTransStart, clConnectionApply, clConnect);
Values
Value Meaning
© 2018 Devart
469 PostgreSQL Data Access Components
Specifies the format of storing and representing of the NUMERIC (DECIMAL) fields.
Unit
MemData
Syntax
TDANumericType = (ntFloat, ntBCD, ntFmtBCD);
Values
Value Meaning
Data is stored on the client side as currency and represented as
ntBCD TBCDField. This format allows storing data with precision up to
0,0001.
ntFloat Data stored on the client side is in double format and
represented as TFloatField. The default value.
ntFmtBCD Data is represented as TFMTBCDField. TFMTBCDField gives
greater precision and accuracy than TBCDField, but it is slower.
© 2018 Devart
Reference 470
Allows to set additional search parameters which will be used by the LocateEx method.
Unit
MemData
Syntax
TLocateExOption = (lxCaseInsensitive, lxPartialKey, lxNearest,
lxNext, lxUp, lxPartialCompare);
Values
Value Meaning
lxCaseInsensitive Similar to loCaseInsensitive. Key fields and key values are
matched without regard to the case.
LocateEx moves the cursor to a specific record in a dataset or to
the first record in the dataset that is greater than the values
lxNearest specified in the KeyValues parameter. For this option to work
correctly dataset should be sorted by the fields the search is
performed in. If dataset is not sorted, the function may return a
line that is not connected with the search condition.
lxNext LocateEx searches from the current record.
Similar to lxPartialKey, but the difference is that it can process
lxPartialCompare value entries in any position. For example, 'HAM' would match
both 'HAMM', 'HAMMER.', and also 'MR HAMMER'.
Similar to loPartialKey. Key values can include only a part of the
lxPartialKey matching key field value. For example, 'HAM' would match both
'HAMM' and 'HAMMER.', but not 'MR HAMMER'.
lxUp LocateEx searches from the current record to the first record.
Unit
MemData
Syntax
TSortType = (stCaseSensitive, stCaseInsensitive, stBinary);
Values
© 2018 Devart
471 PostgreSQL Data Access Components
Value Meaning
stBinary Sorting by character ordinal values (this comparison is also case
sensitive).
stCaseInsensitive Sorting without case sensitivity.
stCaseSensitive Sorting with case sensitivity.
5.10.3.6 TUpdateRecKind Enumeration
Unit
MemData
Syntax
TUpdateRecKind = (ukUpdate, ukInsert, ukDelete);
Values
Value Meaning
ukDelete ApplyUpdates will be performed for deleted records.
ukInsert ApplyUpdates will be performed for inserted records.
ukUpdate ApplyUpdates will be performed for updated records.
5.11 MemDS
This unit contains implementation of the TMemDataSet class.
Classes
Name Description
TMemDataSet A base class for working with data and
manipulating data in memory.
Variables
Name Description
DoNotRaiseExcetionOnUaFail An exception will be raised if the value of the
UpdateAction parameter is uaFail.
© 2018 Devart
Reference 472
5.11.1 Classes
Classes in the MemDS unit.
Classes
Name Description
TMemDataSet A base class for working with data and
manipulating data in memory.
A base class for working with data and manipulating data in memory.
For a list of all members of this type, see TMemDataSet members.
Unit
MemDS
Syntax
TMemDataSet = class(TDataSet);
Remarks
TMemDataSet derives from the TDataSet database-engine independent set of properties,
events, and methods for working with data and introduces additional techniques to store and
manipulate data in memory.
5.11.1.1.1 Members
Properties
Name Description
CachedUpdates Used to enable or disable the use of cached
updates for a dataset.
© 2018 Devart
473 PostgreSQL Data Access Components
Methods
Name Description
ApplyRange Applies a range to the dataset.
© 2018 Devart
Reference 474
Events
Name Description
OnUpdateError Occurs when an exception is generated while
cached updates are applied to a database.
© 2018 Devart
475 PostgreSQL Data Access Components
Public
Name Description
CachedUpdates Used to enable or disable the use of cached
updates for a dataset.
See Also
TMemDataSet Class
TMemDataSet Class Members
© 2018 Devart
Reference 476
Class
TMemDataSet
Syntax
property CachedUpdates: boolean default False;
Remarks
Use the CachedUpdates property to enable or disable the use of cached updates for a
dataset. Setting CachedUpdates to True enables updates to a dataset (such as posting
changes, inserting new records, or deleting records) to be stored in an internal cache on the
client side instead of being written directly to the dataset's underlying database tables. When
changes are completed, an application writes all cached changes to the database in the
context of a single transaction.
Cached updates are especially useful for client applications working with remote database
servers. Enabling cached updates brings up the following benefits:
Fewer transactions and shorter transaction times.
Minimized network traffic.
The potential drawbacks of enabling cached updates are:
Other applications can access and change the actual data on the server while users are
editing local copies of data, resulting in an update conflict when cached updates are applied
to the database.
Other applications cannot access data changes made by an application until its cached
updates are applied to the database.
The default value is False.
Note: When establishing master/detail relationship the CachedUpdates property of detail
dataset works properly only when TDADataSetOptions.LocalMasterDetail is set to True.
See Also
UpdatesPending
TMemDataSet.ApplyUpdates
RestoreUpdates
CommitUpdates
CancelUpdates
UpdateStatus
© 2018 Devart
477 PostgreSQL Data Access Components
TCustomDADataSet.Options
Used to get or set the list of fields on which the recordset is sorted.
Class
TMemDataSet
Syntax
property IndexFieldNames: string;
Remarks
Use the IndexFieldNames property to get or set the list of fields on which the recordset is
sorted. Specify the name of each column in IndexFieldNames to use as an index for a table.
Ordering of column names is significant. Separate names with semicolon. The specified
columns don't need to be indexed. Set IndexFieldNames to an empty string to reset the
recordset to the sort order originally used when the recordset's data was first retrieved.
Each field may optionally be followed by the keyword ASC / DESC or CIS / CS / BIN.
Use ASC, DESC keywords to specify a sort direction for the field. If one of these keywords is
not used, the default sort direction for the field is ascending.
Use CIS, CS or BIN keywords to specify a sort type for string fields:
CIS - compare without case sensitivity;
CS - compare with case sensitivity;
BIN - compare by character ordinal values (this comparison is also case sensitive).
If a dataset uses a TCustomDAConnection component, the default value of sort type depends
on the TCustomDAConnection.Options option of the connection. If a dataset does not use a
connection (TVirtualTable dataset), the default is CS.
Read IndexFieldNames to determine the field (or fields) on which the recordset is sorted.
Ordering is processed locally.
Note: You cannot process ordering by BLOB fields.
Example
The following procedure illustrates how to set IndexFieldNames in response to a button click:
© 2018 Devart
Reference 478
Class
TMemDataSet
Syntax
property KeyExclusive: Boolean;
Remarks
Use KeyExclusive to specify whether a range includes or excludes the records that match its
specified starting and ending values.
By default, KeyExclusive is False, meaning that matching values are included.
To restrict a range to those records that are greater than the specified starting value and less
than the specified ending value, set KeyExclusive to True.
See Also
SetRange
SetRangeEnd
SetRangeStart
Used to avoid setting the Required property of a TField component for NOT NULL fields at the
time of opening TMemDataSet.
Class
TMemDataSet
Syntax
property LocalConstraints: boolean default True;
Remarks
Use the LocalConstraints property to avoid setting the Required property of a TField
component for NOT NULL fields at the time of opening TMemDataSet. When LocalConstrains
is True, TMemDataSet ignores NOT NULL server constraints. It is useful for tables that have
fields updated by triggers.
LocalConstraints is obsolete, and is only included for backward compatibility.
© 2018 Devart
479 PostgreSQL Data Access Components
Class
TMemDataSet
Syntax
property LocalUpdate: boolean default False;
Remarks
Set the LocalUpdate property to True to prevent implicit update of rows on database server.
Data changes are cached locally in client memory.
5.11.1.1.2.6 Prepared Property
Class
TMemDataSet
Syntax
property Prepared: boolean;
Remarks
Determines whether a query is prepared for execution or not.
See Also
Prepare
Class
TMemDataSet
Syntax
property Ranged: Boolean;
© 2018 Devart
Reference 480
Remarks
Use the Ranged property to detect whether a range is applied to a dataset.
See Also
SetRange
SetRangeEnd
SetRangeStart
Used to indicate the update status for the current record when cached updates are enabled.
Class
TMemDataSet
Syntax
property UpdateRecordTypes: TUpdateRecordTypes default
[rtModified, rtInserted, rtUnmodified];
Remarks
Use the UpdateRecordTypes property to determine the update status for the current record
when cached updates are enabled. Update status can change frequently as records are
edited, inserted, or deleted. UpdateRecordTypes offers a convenient method for applications
to assess the current status before undertaking or completing operations that depend on the
update status of records.
See Also
CachedUpdates
Class
TMemDataSet
Syntax
property UpdatesPending: boolean;
© 2018 Devart
481 PostgreSQL Data Access Components
Remarks
Use the UpdatesPending property to check the status of the cached updates buffer. If
UpdatesPending is True, then there are edited, deleted, or inserted records remaining in local
cache and not yet applied to the database. If UpdatesPending is False, there are no such
records in the cache.
See Also
CachedUpdates
5.11.1.1.3 Methods
Public
Name Description
ApplyRange Applies a range to the dataset.
© 2018 Devart
Reference 482
See Also
TMemDataSet Class
TMemDataSet Class Members
Class
TMemDataSet
© 2018 Devart
483 PostgreSQL Data Access Components
Syntax
procedure ApplyRange;
Remarks
Call ApplyRange to cause a range established with SetRangeStart and SetRangeEnd, or
EditRangeStart and EditRangeEnd, to take effect.
When a range is in effect, only those records that fall within the range are available to the
application for viewing and editing.
After a call to ApplyRange, the cursor is left on the first record in the range.
See Also
CancelRange
EditRangeEnd
EditRangeStart
IndexFieldNames
SetRange
SetRangeEnd
SetRangeStart
Class
TMemDataSet
Overload List
Name Description
ApplyUpdates Writes dataset's pending cached updates
to a database.
ApplyUpdates(const UpdateRecKinds: Writes dataset's pending cached updates
TUpdateRecKinds) of specified records to a database.
Class
TMemDataSet
© 2018 Devart
Reference 484
Syntax
procedure ApplyUpdates; overload; virtual;
Remarks
Call the ApplyUpdates method to write a dataset's pending cached updates to a database.
This method passes cached data to the database, but the changes are not committed to the
database if there is an active transaction. An application must explicitly call the database
component's Commit method to commit the changes to the database if the write is
successful, or call the database's Rollback method to undo the changes if there is an error.
Following a successful write to the database, and following a successful call to a
connection's Commit method, an application should call the CommitUpdates method to clear
the cached update buffer.
Note: The preferred method for updating datasets is to call a connection component's
ApplyUpdates method rather than to call each individual dataset's ApplyUpdates method. The
connection component's ApplyUpdates method takes care of committing and rolling back
transactions and clearing the cache when the operation is successful.
Example
The following procedure illustrates how to apply a dataset's cached updates to a database in
response to a button click:
See Also
TMemDataSet.CachedUpdates
TMemDataSet.CancelUpdates
TMemDataSet.CommitUpdates
© 2018 Devart
485 PostgreSQL Data Access Components
TMemDataSet.UpdateStatus
Class
TMemDataSet
Syntax
procedure ApplyUpdates(const UpdateRecKinds: TUpdateRecKinds);
overload; virtual;
Parameters
UpdateRecKinds
Indicates records for which the ApplyUpdates method will be performed.
Remarks
Call the ApplyUpdates method to write a dataset's pending cached updates of specified
records to a database. This method passes cached data to the database, but the changes
are not committed to the database if there is an active transaction. An application must
explicitly call the database component's Commit method to commit the changes to the
database if the write is successful, or call the database's Rollback method to undo the
changes if there is an error.
Following a successful write to the database, and following a successful call to a
connection's Commit method, an application should call the CommitUpdates method to clear
the cached update buffer.
Note: The preferred method for updating datasets is to call a connection component's
ApplyUpdates method rather than to call each individual dataset's ApplyUpdates method. The
connection component's ApplyUpdates method takes care of committing and rolling back
transactions and clearing the cache when the operation is successful.
5.11.1.1.3.3 CancelRange Method
Class
TMemDataSet
Syntax
procedure CancelRange;
© 2018 Devart
Reference 486
Remarks
Call CancelRange to remove a range currently applied to a dataset. Canceling a range
reenables access to all records in the dataset.
See Also
ApplyRange
EditRangeEnd
EditRangeStart
IndexFieldNames
SetRange
SetRangeEnd
SetRangeStart
Clears all pending cached updates from cache and restores dataset in its prior state.
Class
TMemDataSet
Syntax
procedure CancelUpdates;
Remarks
Call the CancelUpdates method to clear all pending cached updates from cache and restore
dataset in its prior state.
It restores the dataset to the state it was in when the table was opened, cached updates were
last enabled, or updates were last successfully applied to the database.
When a dataset is closed, or the CachedUpdates property is set to False, CancelUpdates is
called automatically.
See Also
CachedUpdates
TMemDataSet.ApplyUpdates
UpdateStatus
© 2018 Devart
487 PostgreSQL Data Access Components
Class
TMemDataSet
Syntax
procedure CommitUpdates;
Remarks
Call the CommitUpdates method to clear the cached updates buffer after both a successful
call to ApplyUpdates and a database component's Commit method. Clearing the cache after
applying updates ensures that the cache is empty except for records that could not be
processed and were skipped by the OnUpdateRecord or OnUpdateError event handlers. An
application can attempt to modify the records still in cache.
CommitUpdates also checks wether there are pending updates in dataset. And if there are, it
calls ApplyUpdates.
Record modifications made after a call to CommitUpdates repopulate the cached update
buffer and require a subsequent call to ApplyUpdates to move them to the database.
See Also
CachedUpdates
TMemDataSet.ApplyUpdates
UpdateStatus
Class
TMemDataSet
Syntax
procedure DeferredPost;
Remarks
Call DeferredPost to make permanent changes to the database server while retaining dataset
in its state whether it is dsEdit or dsInsert.
© 2018 Devart
Reference 488
Explicit call to the Cancel method after DeferredPost has been applied does not abandon
modifications to a dataset already fixed in database.
Class
TMemDataSet
Syntax
procedure EditRangeEnd;
Remarks
Call EditRangeEnd to change the ending value for an existing range.
To specify an end range value, call FieldByName after calling EditRangeEnd.
After assigning a new ending value, call ApplyRange to activate the modified range.
See Also
ApplyRange
CancelRange
EditRangeStart
IndexFieldNames
SetRange
SetRangeEnd
SetRangeStart
Class
TMemDataSet
Syntax
procedure EditRangeStart;
Remarks
Call EditRangeStart to change the starting value for an existing range.
© 2018 Devart
489 PostgreSQL Data Access Components
See Also
ApplyRange
CancelRange
EditRangeEnd
IndexFieldNames
SetRange
SetRangeEnd
SetRangeStart
Retrieves TBlob object for a field or current record when only its name or the field itself is
known.
Class
TMemDataSet
Overload List
Name Description
GetBlob(Field: TField) Retrieves TBlob object for a field or current
record when the field itself is known.
GetBlob(const FieldName: string) Retrieves TBlob object for a field or current
record when its name is known.
Retrieves TBlob object for a field or current record when the field itself is known.
Class
TMemDataSet
Syntax
function GetBlob(Field: TField): TBlob; overload;
Parameters
Field
Holds an existing TField object.
Return Value
© 2018 Devart
Reference 490
Remarks
Call the GetBlob method to retrieve TBlob object for a field or current record when only its
name or the field itself is known. FieldName is the name of an existing field. The field should
have MEMO or BLOB type.
Retrieves TBlob object for a field or current record when its name is known.
Class
TMemDataSet
Syntax
function GetBlob(const FieldName: string): TBlob; overload;
Parameters
FieldName
Holds the name of an existing field.
Return Value
TBlob object that was retrieved.
Example
PgQuery1.GetBlob('Comment').SaveToFile('Comment.txt');
See Also
TBlob
Searches a dataset for a specific record and positions the cursor on it.
Class
TMemDataSet
Overload List
Name Description
Locate(const KeyFields: array of TField; Searches a dataset by the specified fields
const KeyValues: variant; Options: for a specific record and positions cursor
TLocateOptions) on it.
Locate(const KeyFields: string; const Searches a dataset by the fields specified
© 2018 Devart
491 PostgreSQL Data Access Components
Class
TMemDataSet
Syntax
function Locate(const KeyFields: array of TField; const
KeyValues: variant; Options: TLocateOptions): boolean;
reintroduce; overload;
Parameters
KeyFields
Holds TField objects in which to search.
KeyValues
Holds the variant that specifies the values to match in the key fields.
Options
Holds additional search latitude when searching in string fields.
Return Value
True if it finds a matching record, and makes this record the current one. Otherwise it
returns False.
Searches a dataset by the fields specified by name for a specific record and positions the
cursor on it.
Class
TMemDataSet
Syntax
function Locate(const KeyFields: string; const KeyValues:
variant; Options: TLocateOptions): boolean; overload; override;
Parameters
KeyFields
Holds a semicolon-delimited list of field names in which to search.
KeyValues
Holds the variant that specifies the values to match in the key fields.
Options
© 2018 Devart
Reference 492
Remarks
Call the Locate method to search a dataset for a specific record and position cursor on it.
KeyFields is a string containing a semicolon-delimited list of field names on which to search.
KeyValues is a variant that specifies the values to match in the key fields. If KeyFields lists a
single field, KeyValues specifies the value for that field on the desired record. To specify
multiple search values, pass a variant array as KeyValues, or construct a variant array on the
fly using the VarArrayOf routine. An example is provided below.
Options is a set that optionally specifies additional search latitude when searching in string
fields. If Options contains the loCaseInsensitive setting, then Locate ignores case when
matching fields. If Options contains the loPartialKey setting, then Locate allows partial-string
matching on strings in KeyValues. If Options is an empty set, or if KeyFields does not include
any string fields, Options is ignored.
Locate returns True if it finds a matching record, and makes this record the current one.
Otherwise it returns False.
The Locate function works faster when dataset is locally sorted on the KeyFields fields. Local
dataset sorting can be set with the TMemDataSet.IndexFieldNames property.
Example
An example of specifying multiple search values:
with CustTable do
Locate('Company;Contact;Phone', VarArrayOf(['Sight Diver', 'P',
'408-431-1000']), [loPartialKey]);
See Also
TMemDataSet.IndexFieldNames
TMemDataSet.LocateEx
Class
TMemDataSet
© 2018 Devart
493 PostgreSQL Data Access Components
Overload List
Name Description
LocateEx(const KeyFields: array of Excludes features that don't need to be
included to the TMemDataSet.Locate
TField; const KeyValues: variant; Options:
TLocateExOptions) method of TDataSet by the specified fields.
LocateEx(const KeyFields: string; const Excludes features that don't need to be
included to the TMemDataSet.Locate
KeyValues: variant; Options:
method of TDataSet by the specified field
TLocateExOptions)
names.
Excludes features that don't need to be included to the TMemDataSet.Locate method of
TDataSet by the specified fields.
Class
TMemDataSet
Syntax
function LocateEx(const KeyFields: array of TField; const
KeyValues: variant; Options: TLocateExOptions): boolean; overload;
Parameters
KeyFields
Holds TField objects to search in.
KeyValues
Holds the values of the fields to search for.
Options
Holds additional search parameters which will be used by the LocateEx method.
Return Value
True, if a matching record was found. Otherwise returns False.
Excludes features that don't need to be included to the TMemDataSet.Locate method of
TDataSet by the specified field names.
Class
TMemDataSet
Syntax
function LocateEx(const KeyFields: string; const KeyValues:
variant; Options: TLocateExOptions): boolean; overload;
© 2018 Devart
Reference 494
Parameters
KeyFields
Holds the fields to search in.
KeyValues
Holds the values of the fields to search for.
Options
Holds additional search parameters which will be used by the LocateEx method.
Return Value
True, if a matching record was found. Otherwise returns False.
Remarks
Call the LocateEx method when you need some features not to be included to the
TMemDataSet.Locate method of TDataSet.
LocateEx returns True if it finds a matching record, and makes that record the current one.
Otherwise LocateEx returns False.
The LocateEx function works faster when dataset is locally sorted on the KeyFields fields.
Local dataset sorting can be set with the TMemDataSet.IndexFieldNames property.
Note: Please add the MemData unit to the "uses" list to use the TLocalExOption
enumeration.
See Also
TMemDataSet.IndexFieldNames
TMemDataSet.Locate
Class
TMemDataSet
Syntax
procedure Prepare; virtual;
Remarks
Call the Prepare method to allocate resources and create field components for a dataset. To
learn whether dataset is prepared or not use the Prepared property.
The UnPrepare method unprepares a query.
Note: When you change the text of a query at runtime, the query is automatically closed and
© 2018 Devart
495 PostgreSQL Data Access Components
unprepared.
See Also
Prepared
UnPrepare
Class
TMemDataSet
Syntax
procedure RestoreUpdates;
Remarks
Call the RestoreUpdates method to return the cache of updates to its state before calling
ApplyUpdates. RestoreUpdates marks all records in the cache of updates as unapplied. It is
useful when ApplyUpdates fails.
See Also
CachedUpdates
TMemDataSet.ApplyUpdates
CancelUpdates
UpdateStatus
Cancels changes made to the current record when cached updates are enabled.
Class
TMemDataSet
Syntax
procedure RevertRecord;
Remarks
Call the RevertRecord method to undo changes made to the current record when cached
updates are enabled.
© 2018 Devart
Reference 496
See Also
CachedUpdates
CancelUpdates
Saves the current dataset data to a file or a stream in the XML format compatible with ADO
format.
Class
TMemDataSet
Overload List
Name Description
Saves the current dataset data to a stream
SaveToXML(Destination: TStream) in the XML format compatible with ADO
format.
Saves the current dataset data to a file in
SaveToXML(const FileName: string) the XML format compatible with ADO
format.
Saves the current dataset data to a stream in the XML format compatible with ADO format.
Class
TMemDataSet
Syntax
procedure SaveToXML(Destination: TStream); overload;
Parameters
Destination
Holds a TStream object.
Remarks
Call the SaveToXML method to save the current dataset data to a file or a stream in the XML
format compatible with ADO format.
If the destination file already exists, it is overwritten. It remains open from the first call to
SaveToXML until the dataset is closed. This file can be read by other applications while it is
opened, but they cannot write to the file.
© 2018 Devart
497 PostgreSQL Data Access Components
When saving data to a stream, a TStream object must be created and its position must be
set in a preferable value.
See Also
M:Devart.Dac.TVirtualTable.LoadFromFile(System.String,System.Boolean)
M:Devart.Dac.TVirtualTable.LoadFromStream(Borland.Vcl.TStream,System.Boolean)
Saves the current dataset data to a file in the XML format compatible with ADO format.
Class
TMemDataSet
Syntax
procedure SaveToXML(const FileName: string); overload;
Parameters
FileName
Holds the name of a destination file.
5.11.1.1.3.16 SetRange Method
Sets the starting and ending values of a range, and applies it.
Class
TMemDataSet
Syntax
procedure SetRange(const StartValues: array of System.TVarRec;
const EndValues: array of System.TVarRec; StartExlusive: Boolean
= False; EndExclusive: Boolean = False);
Parameters
StartValues
Indicates the field values that designate the first record in the range. In C++,
StartValues_Size is the index of the last value in the StartValues array.
EndValues
Indicates the field values that designate the last record in the range. In C++,
EndValues_Size is the index of the last value in the EndValues array.
StartExlusive
Iindicates the upper and lower boundaries of the start range.
EndExclusive
Indicates the upper and lower boundaries of the end range.
© 2018 Devart
Reference 498
Remarks
Call SetRange to specify a range and apply it to the dataset. The new range replaces the
currently specified range, if any.
SetRange combines the functionality of SetRangeStart, SetRangeEnd, and ApplyRange in a
single procedure call. SetRange performs the following functions:
1. Puts the dataset into dsSetKey state.
2. Erases any previously specified starting range values and ending range values.
3. Sets the start and end range values.
4. Applies the range to the dataset.
After a call to SetRange, the cursor is left on the first record in the range.
If either StartValues or EndValues has fewer elements than the number of fields in the current
index, then the remaining entries are set to NULL.
See Also
ApplyRange
CancelRange
EditRangeEnd
EditRangeStart
IndexFieldNames
KeyExclusive
SetRangeEnd
SetRangeStart
Indicates that subsequent assignments to field values specify the end of the range of rows to
include in the dataset.
Class
TMemDataSet
Syntax
procedure SetRangeEnd;
Remarks
Call SetRangeEnd to put the dataset into dsSetKey state, erase any previous end range
© 2018 Devart
499 PostgreSQL Data Access Components
See Also
ApplyRange
CancelRange
EditRangeStart
IndexFieldNames
SetRange
SetRangeStart
Indicates that subsequent assignments to field values specify the start of the range of rows to
include in the dataset.
Class
TMemDataSet
Syntax
procedure SetRangeStart;
Remarks
Call SetRangeStart to put the dataset into dsSetKey state, erase any previous start range
values, and set them to NULL.
Subsequent field assignments to FieldByName specify the actual set of starting values for a
range.
After assigning start-range values, call ApplyRange to activate the modified range.
See Also
ApplyRange
CancelRange
EditRangeStart
IndexFieldNames
SetRange
SetRangeEnd
© 2018 Devart
Reference 500
Frees the resources allocated for a previously prepared query on the server and client sides.
Class
TMemDataSet
Syntax
procedure UnPrepare; virtual;
Remarks
Call the UnPrepare method to free the resources allocated for a previously prepared query on
the server and client sides.
Note: When you change the text of a query at runtime, the query is automatically closed and
unprepared.
See Also
Prepare
Reads the status of the latest call to the ApplyUpdates method while cached updates are
enabled.
Class
TMemDataSet
Syntax
function UpdateResult: TUpdateAction;
Return Value
a value of the TUpdateAction enumeration.
Remarks
Call the UpdateResult method to read the status of the latest call to the ApplyUpdates method
while cached updates are enabled. UpdateResult reflects updates made on the records that
have been edited, inserted, or deleted.
UpdateResult works on the record by record basis and is applicable to the current record
only.
© 2018 Devart
501 PostgreSQL Data Access Components
See Also
CachedUpdates
Indicates the current update status for the dataset when cached updates are enabled.
Class
TMemDataSet
Syntax
function UpdateStatus: TUpdateStatus; override;
Return Value
a value of the TUpdateStatus enumeration.
Remarks
Call the UpdateStatus method to determine the current update status for the dataset when
cached updates are enabled. Update status can change frequently as records are edited,
inserted, or deleted. UpdateStatus offers a convenient method for applications to assess the
current status before undertaking or completing operations that depend on the update status
of the dataset.
See Also
CachedUpdates
5.11.1.1.4 Events
Public
Name Description
OnUpdateError Occurs when an exception is generated while
cached updates are applied to a database.
© 2018 Devart
Reference 502
See Also
TMemDataSet Class
TMemDataSet Class Members
Occurs when an exception is generated while cached updates are applied to a database.
Class
TMemDataSet
Syntax
property OnUpdateError: TUpdateErrorEvent;
Remarks
Write the OnUpdateError event handler to respond to exceptions generated when cached
updates are applied to a database.
E is a pointer to an EDatabaseError object from which application can extract an error
message and the actual cause of the error condition. The OnUpdateError handler can use
this information to determine how to respond to the error condition.
UpdateKind describes the type of update that generated the error.
UpdateAction indicates the action to take when the OnUpdateError handler exits. On entry into
the handler, UpdateAction is always set to uaFail. If OnUpdateError can handle or correct the
error, set UpdateAction to uaRetry before exiting the error handler.
The error handler can use the TField.OldValue and TField.NewValue properties to evaluate
error conditions and set TField.NewValue to a new value to reapply. In this case, set
UpdateAction to uaRetry before exiting.
Note: If a call to ApplyUpdates raises an exception and ApplyUpdates is not called within the
context of a try...except block, an error message is displayed. If the OnUpdateError handler
cannot correct the error condition and leaves UpdateAction set to uaFail, the error message is
displayed twice. To prevent redisplay, set UpdateAction to uaAbort in the error handler.
See Also
CachedUpdates
Occurs when a single update component can not handle the updates.
Class
© 2018 Devart
503 PostgreSQL Data Access Components
TMemDataSet
Syntax
property OnUpdateRecord: TUpdateRecordEvent;
Remarks
Write the OnUpdateRecord event handler to process updates that cannot be handled by a
single update component, such as implementation of cascading updates, insertions, or
deletions. This handler is also useful for applications that require additional control over
parameter substitution in update components.
UpdateKind describes the type of update to perform.
UpdateAction indicates the action taken by the OnUpdateRecord handler before it exits. On
entry into the handler, UpdateAction is always set to uaFail. If OnUpdateRecord is successful,
it should set UpdateAction to uaApplied before exiting.
See Also
CachedUpdates
5.11.2 Variables
Variables in the MemDS unit.
Variables
Name Description
DoNotRaiseExcetionOnUaFail An exception will be raised if the value of the
UpdateAction parameter is uaFail.
The DataSetChange event is sent after a dataset
SendDataSetChangeEventAfter gets open. It was necessary to fix a problem with
Open disappeared vertical scrollbar in some types of
DB-aware grids.
5.11.2.1 DoNotRaiseExcetionOnUaFail Variable
Unit
MemDS
Syntax
© 2018 Devart
Reference 504
Remarks
Starting with PgDAC , if the OnUpdateRecord event handler sets the UpdateAction parameter
to uaFail, an exception is raised. The default value of UpdateAction is uaFail. So, the
exception will be raised when the value of this parameter is left unchanged.
To restore the old behaviour, set DoNotRaiseExcetionOnUaFail to True.
The DataSetChange event is sent after a dataset gets open. It was necessary to fix a problem
with disappeared vertical scrollbar in some types of DB-aware grids.
Unit
MemDS
Syntax
SendDataSetChangeEventAfterOpen: boolean = True;
Remarks
Starting with PgDAC , the DataSetChange event is sent after a dataset gets open. It was
necessary to fix a problem with disappeared vertical scrollbar in some types of DB-aware
grids. This problem appears only under Windows XP when visual styles are enabled.
To disable sending this event, change the value of this variable to False.
5.12 PgAccess
This unit contains main components of PgDAC.
Classes
Name Description
TCustomPgDataSet A base class defining functionality for the classes
derived from it.
© 2018 Devart
505 PostgreSQL Data Access Components
© 2018 Devart
Reference 506
Types
Name Description
TPgNoticeEvent This type is used for the TPgConnection.OnNotice
event.
Enumerations
Name Description
TPgIsolationLevel Specifies the way the transactions containing
database modifications are handled.
Constants
Name Description
PgDACVersion The version of PostgreSQL Data Access
Components.
© 2018 Devart
507 PostgreSQL Data Access Components
5.12.1 Classes
Classes in the PgAccess unit.
Classes
Name Description
TCustomPgDataSet A base class defining functionality for the classes
derived from it.
© 2018 Devart
Reference 508
A base class defining functionality for the classes derived from it.
For a list of all members of this type, see TCustomPgDataSet members.
Unit
PgAccess
Syntax
© 2018 Devart
509 PostgreSQL Data Access Components
TCustomPgDataSet = class(TCustomDADataSet);
Remarks
TCustomPgDataSet is a base dataset component that defines functionality for classes
derived from it. Applications never use TCustomPgDataSet objects directly. Instead they use
descendants of TCustomPgDataSet, such as TPgQuery and TPgTable that inherit its
dataset-related properties and methods.
Inheritance Hierarchy
TMemDataSet
TCustomDADataSet
TCustomPgDataSet
5.12.1.1.1 Members
Properties
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
Reference 510
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
© 2018 Devart
511 PostgreSQL Data Access Components
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
Reference 512
TMemDataSet)
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
© 2018 Devart
513 PostgreSQL Data Access Components
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
© 2018 Devart
Reference 514
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
515 PostgreSQL Data Access Components
TCustomDADataSet)
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
© 2018 Devart
Reference 516
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
© 2018 Devart
517 PostgreSQL Data Access Components
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
© 2018 Devart
Reference 518
TMemDataSet)
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute (inherited from Occurs after a component has executed a query to
TCustomDADataSet) database.
AfterFetch (inherited from Occurs after dataset finishes fetching data from
TCustomDADataSet) server.
© 2018 Devart
519 PostgreSQL Data Access Components
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.12.1.1.2 Properties
Public
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
Reference 520
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
© 2018 Devart
521 PostgreSQL Data Access Components
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
Reference 522
TMemDataSet)
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
© 2018 Devart
523 PostgreSQL Data Access Components
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
See Also
TCustomPgDataSet Class
TCustomPgDataSet Class Members
Class
TCustomPgDataSet
Syntax
property Cursor: TPgRefCursor;
Remarks
Use the Cursor property to fetch data from the REFCURSOR parameter or REFCURSOR
field. You can assign the value of TPgParam.AsCursor or TPgCursorField.AsCursor to the
Cursor property. After assigning you can open the dataset once.
Example
PgQuery1.Cursor := PgSQL1.ParamByName('Cur').AsCursor;
PgQuery1.Open;
© 2018 Devart
Reference 524
See Also
TPgRefCursor
P:Devart.PgDac.TPgParam.AsCursor
Class
TCustomPgDataSet
Syntax
property DMLRefresh: boolean;
Remarks
Use the DMLRefresh property to refresh record by RETURNING clause when insert or update
is performed.
The default value is False.
5.12.1.1.2.3 FetchAll Property
Defines whether to request all records of the query from database server when the dataset is
being opened.
Class
TCustomPgDataSet
Syntax
property FetchAll: boolean default True;
Remarks
When set to True, all records of the query are requested from database server when the
dataset is being opened. When set to False, records are retrieved when a data-aware
component or a program requests it. If a query can return a lot of records, set this property to
False if initial response time is important.
Opening a dataset in FetchAll = False mode requires an active transaction. When the
FetchAll property is False, the first call to TMemDataSet.Locate and TMemDataSet.LocateEx
methods may take a lot of time to retrieve additional records to the client side.
© 2018 Devart
525 PostgreSQL Data Access Components
See Also
TCustomDADataSet.FetchRows
Used to specify the name of a sequence that will be used to fill in a key field after a new
record is inserted or posted to a database.
Class
TCustomPgDataSet
Syntax
property KeySequence: string;
Remarks
Use the KeySequence property to specify the name of a sequence that will be used to fill in a
key field after a new record is inserted or posted to a database.
Note: KeySequence is used by TCustomPgDataSet only if the KeyFields property is
assigned.
See Also
TCustomDADataSet.KeyFields
SequenceMode
Returns OID of the record inserted by the last query for table with OIDs.
Class
TCustomPgDataSet
Syntax
property LastInsertOID: Int64;
Remarks
Use the LastInsertOID property to get OID of the record inserted by the last query for table
with OIDs.
© 2018 Devart
Reference 526
Class
TCustomPgDataSet
Syntax
property Options: TPgDataSetOptions;
Remarks
Set the properties of Options to specify the behaviour of a TCustomPgDataSet object.
Descriptions of all options are in the table below.
© 2018 Devart
527 PostgreSQL Data Access Components
Class
TCustomPgDataSet
Syntax
property Params: TPgParams stored False;
Remarks
Contains parameters for a query's SQL statement.
Access Params at runtime to view and set parameter names, values, and data types
dynamically (at design time use the Parameters editor to set the parameter information).
Params is a zero-based array of parameter records. Index specifies the array element to
access.
An easier way to set and retrieve parameter values when the name of each parameter is
known is to call ParamByName.
5.12.1.1.2.8 SequenceMode Property
Class
TCustomPgDataSet
Syntax
property SequenceMode: TSequenceMode default smPost;
Remarks
Set the SequenceMode property to specify which method is used internally to generate a
sequenced field.
© 2018 Devart
Reference 528
See Also
TCustomDADataSet.KeyFields
KeySequence
Used to point to an update object component which provides SQL statements that perform
updates of read-only datasets.
Class
TCustomPgDataSet
Syntax
property UpdateObject: TPgUpdateSQL;
Remarks
The UpdateObject property points to an update object component which provides SQL
statements that perform updates of read-only datasets when cached updates are enabled.
5.12.1.1.3 Methods
Public
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
© 2018 Devart
529 PostgreSQL Data Access Components
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 530
TCustomDADataSet)
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
© 2018 Devart
531 PostgreSQL Data Access Components
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
© 2018 Devart
Reference 532
TCustomDADataSet)
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
© 2018 Devart
533 PostgreSQL Data Access Components
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
See Also
TCustomPgDataSet Class
TCustomPgDataSet Class Members
Class
TCustomPgDataSet
© 2018 Devart
Reference 534
Syntax
procedure CreateProcCall(Name: string; Overload: integer = 0);
Parameters
Name
the name of the stored procedure.
Overload
the numder of the overloaded procedure.
Remarks
Call the CreateProcCall method to assign SQL statement that calls the stored procedure to
the SQL property and fill the Params property. The Overload parameter contains the number
of the overloaded procedure. Retrieves information about the procedure parameters from
PostgreSQL server. After calling CreateProcCall you can execute stored procedure by the
Execute method.
5.12.1.1.3.2 FindParam Method
Class
TCustomPgDataSet
Syntax
function FindParam(const Value: string): TPgParam;
Parameters
Value
Holds the stored procedure name.
Return Value
the parameter, if a match was found. Nil otherwise.
Remarks
Call the FindParam method to find a parameter with the name passed in the Name argument.
If a match was found, FindParam returns the parameter. Otherwise, it returns nil.
See Also
TPgParam
TPgSQL.ParamByName
© 2018 Devart
535 PostgreSQL Data Access Components
Class
TCustomPgDataSet
Syntax
function GetPgCursor(const FieldName: string): TPgRefCursor;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgCursor object for a field with known name.
Remarks
Call the GetPgCursor method to retrieve a TPgCursor object for a field when only its name is
known. FieldName is the name of an existing field.
5.12.1.1.3.4 GetPgDate Method
Class
TCustomPgDataSet
Syntax
function GetPgDate(const FieldName: string): TPgDate;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgDate object for a field with known name.
Remarks
Call the GetPgDate method to retrieve a TPgDate object for a field when only its name is
known. FieldName is the name of an existing field.
© 2018 Devart
Reference 536
Class
TCustomPgDataSet
Syntax
function GetPgInterval(const FieldName: string): TPgInterval;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgInterval object for a field with known name.
Remarks
Call the GetPgInterval method to retrieve a TPgInterval object for a field when only its name is
known. FieldName is the name of an existing field.
See Also
TPgInterval
TPgParam.AsPgInterval
Class
TCustomPgDataSet
Syntax
function GetPgLargeObject(const FieldName: string):
TPgLargeObject;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgLargeObject object for a field with known name.
© 2018 Devart
537 PostgreSQL Data Access Components
Remarks
Call the GetPgLargeObject method to retrieve a TPgLargeObject object for a field when only
its name is known. FieldName is the name of an existing field.
5.12.1.1.3.7 GetPgRow Method
Class
TCustomPgDataSet
Syntax
function GetPgRow(const FieldName: string): TPgRow;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgRow object for a field with known name.
Remarks
Call the GetPgRow method to retrieve a TPgRow object for a field when only its name is
known. FieldName is the name of an existing field.
5.12.1.1.3.8 GetPgTime Method
Class
TCustomPgDataSet
Syntax
function GetPgTime(const FieldName: string): TPgTime;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgTime object for a field with known name.
© 2018 Devart
Reference 538
Remarks
Call the GetPgTime method to retrieve a TPgTime object for a field when only its name is
known. FieldName is the name of an existing field.
5.12.1.1.3.9 GetPgTimeStamp Method
Class
TCustomPgDataSet
Syntax
function GetPgTimeStamp(const FieldName: string): TPgTimeStamp;
Parameters
FieldName
Holds the name of an existing field.
Return Value
a TPgTimeStamp object for a field with known name.
Remarks
Call the GetPgTimeStamp method to retrieve a TPgTimeStamp object for a field when only its
name is known. FieldName is the name of an existing field.
5.12.1.1.3.10 OpenNext Method
Opens the next REFCURSOR for stored procedure that returns more than one cursor.
Class
TCustomPgDataSet
Syntax
function OpenNext: boolean;
Return Value
True, if the next cursor is opened. False, if there are no more cursors.
Remarks
Call the OpenNext method to open next REFCURSOR for stored procedure that returns more
than one cursor. When you execute a stored procedure that has REFCURSOR parameters,
© 2018 Devart
539 PostgreSQL Data Access Components
PgDAC opens a cursor from the first parameter automatically. The OpenNext function closes
current cursor and opens a cursor from the next REFCURSOR parameter.
5.12.1.1.3.11 ParamByName Method
Class
TCustomPgDataSet
Syntax
function ParamByName(const Value: string): TPgParam;
Parameters
Value
Holds the parameter name.
Return Value
the parameter, if a match was found. Otherwise an exception is raised.
Remarks
Call the ParamByName method to find a parameter with the name passed in the Name
argument.
If a match is found, ParamByName returns the parameter. Otherwise, an exception is raised.
See Also
TPgParam
TPgSQL.FindParam
Unit
PgAccess
Syntax
TCustomPgStoredProc = class(TCustomPgDataSet);
Remarks
© 2018 Devart
Reference 540
Inheritance Hierarchy
TMemDataSet
TCustomDADataSet
TCustomPgDataSet
TCustomPgStoredProc
5.12.1.2.1 Members
Properties
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
541 PostgreSQL Data Access Components
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
FetchAll (inherited from Defines whether to request all records of the query
from database server when the dataset is being
TCustomPgDataSet)
opened.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
© 2018 Devart
Reference 542
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
© 2018 Devart
543 PostgreSQL Data Access Components
TCustomDADataSet)
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
used when applying an insertion to a dataset.
© 2018 Devart
Reference 544
TCustomDADataSet)
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
© 2018 Devart
545 PostgreSQL Data Access Components
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 546
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
547 PostgreSQL Data Access Components
TMemDataSet)
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
GetPgDate (inherited from Retrieves a TPgDate object for a field with known
TCustomPgDataSet) name.
GetPgRow (inherited from Retrieves a TPgRow object for a field with known
name.
© 2018 Devart
Reference 548
TCustomPgDataSet)
GetPgTime (inherited from Retrieves a TPgTime object for a field with known
TCustomPgDataSet) name.
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
ParamByName (inherited from Searches for and returns a parameter with the
TCustomPgDataSet) specified name.
© 2018 Devart
549 PostgreSQL Data Access Components
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
© 2018 Devart
Reference 550
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute (inherited from Occurs after a component has executed a query to
TCustomDADataSet) database.
AfterFetch (inherited from Occurs after dataset finishes fetching data from
TCustomDADataSet) server.
© 2018 Devart
551 PostgreSQL Data Access Components
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.12.1.2.2 Properties
Public
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
Reference 552
TCustomDADataSet)
FetchAll (inherited from Defines whether to request all records of the query
from database server when the dataset is being
TCustomPgDataSet)
opened.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
Used to specify the name of a sequence that will
KeySequence (inherited from be used to fill in a key field after a new record is
inserted or posted to a database.
© 2018 Devart
553 PostgreSQL Data Access Components
TCustomPgDataSet)
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
Reference 554
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
© 2018 Devart
555 PostgreSQL Data Access Components
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
See Also
TCustomPgStoredProc Class
TCustomPgStoredProc Class Members
Class
TCustomPgStoredProc
Syntax
property Overload: integer default 0;
© 2018 Devart
Reference 556
Remarks
Set the Overload property to specify the overloading number in case the stored procedure is
overloaded.
5.12.1.2.3 Methods
Public
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
© 2018 Devart
557 PostgreSQL Data Access Components
from TCustomDADataSet)
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 558
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
© 2018 Devart
559 PostgreSQL Data Access Components
GetPgDate (inherited from Retrieves a TPgDate object for a field with known
TCustomPgDataSet) name.
GetPgRow (inherited from Retrieves a TPgRow object for a field with known
TCustomPgDataSet) name.
GetPgTime (inherited from Retrieves a TPgTime object for a field with known
TCustomPgDataSet) name.
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
© 2018 Devart
Reference 560
ParamByName (inherited from Searches for and returns a parameter with the
TCustomPgDataSet) specified name.
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
© 2018 Devart
561 PostgreSQL Data Access Components
TCustomDADataSet)
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
See Also
TCustomPgStoredProc Class
TCustomPgStoredProc Class Members
Class
© 2018 Devart
Reference 562
TCustomPgStoredProc
Syntax
procedure ExecProc;
Remarks
Call the ExecProc method to execute a SQL statement on the server. The ExecProc method
is similar to the TCustomDADataSet.Execute method. It is included for compatibility with
TStoredProc.
5.12.1.2.3.2 PrepareSQL Method
Class
TCustomPgStoredProc
Syntax
procedure PrepareSQL;
Remarks
Call the PrepareSQL method to describe parameters of a stored procedure and assign SQL
statement that calls the stored procedure to the SQL property. If necessary, the Execute
method calls it automatically. You can define parameters at design time if Parameters Editor
is opened.
A base class that defines functionality for descendant classes which access data in a single
table without writing SQL statements.
For a list of all members of this type, see TCustomPgTable members.
Unit
PgAccess
Syntax
TCustomPgTable = class(TCustomPgDataSet);
Remarks
© 2018 Devart
563 PostgreSQL Data Access Components
Inheritance Hierarchy
TMemDataSet
TCustomDADataSet
TCustomPgDataSet
TCustomPgTable
See Also
TPgTable
TPgQuery
Master/Detail Relationships
5.12.1.3.1 Members
Properties
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
Reference 564
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
FetchAll (inherited from Defines whether to request all records of the query
from database server when the dataset is being
TCustomPgDataSet)
opened.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
© 2018 Devart
565 PostgreSQL Data Access Components
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
© 2018 Devart
Reference 566
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
© 2018 Devart
567 PostgreSQL Data Access Components
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
© 2018 Devart
Reference 568
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
© 2018 Devart
569 PostgreSQL Data Access Components
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 570
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
GetPgDate (inherited from Retrieves a TPgDate object for a field with known
TCustomPgDataSet) name.
© 2018 Devart
571 PostgreSQL Data Access Components
GetPgRow (inherited from Retrieves a TPgRow object for a field with known
TCustomPgDataSet) name.
GetPgTime (inherited from Retrieves a TPgTime object for a field with known
TCustomPgDataSet) name.
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
ParamByName (inherited from Searches for and returns a parameter with the
TCustomPgDataSet) specified name.
© 2018 Devart
Reference 572
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
© 2018 Devart
573 PostgreSQL Data Access Components
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute (inherited from Occurs after a component has executed a query to
TCustomDADataSet) database.
AfterFetch (inherited from Occurs after dataset finishes fetching data from
TCustomDADataSet) server.
© 2018 Devart
Reference 574
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.12.1.3.2 Properties
Public
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
575 PostgreSQL Data Access Components
TCustomDADataSet)
FetchAll (inherited from Defines whether to request all records of the query
from database server when the dataset is being
TCustomPgDataSet)
opened.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
Used to specify the name of a sequence that will
KeySequence (inherited from be used to fill in a key field after a new record is
inserted or posted to a database.
© 2018 Devart
Reference 576
TCustomPgDataSet)
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
© 2018 Devart
577 PostgreSQL Data Access Components
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
© 2018 Devart
Reference 578
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
See Also
TCustomPgTable Class
TCustomPgTable Class Members
Class
TCustomPgTable
© 2018 Devart
579 PostgreSQL Data Access Components
Syntax
property Limit: integer default - 1;
Remarks
Use the Limit property to set the number of rows retrieved from the query. If Limit is -1, all
records will be obtained.
See Also
Offset
Used to allow retrieving data from the server starting from the specified row.
Class
TCustomPgTable
Syntax
property Offset: integer default 0;
Remarks
Use the Offset property to allow retrieving data from the server starting from the specified
row. The default value is 0.
See Also
Limit
A base class defining functionality for the classes derived from it.
For a list of all members of this type, see TCustomPgTimeStampField members.
Unit
PgAccess
Syntax
TCustomPgTimeStampField = class(TField);
Remarks
© 2018 Devart
Reference 580
Properties
Name Description
AsPgTimeStamp Used to provide access to a TPgTimeStamp
object.
5.12.1.4.2 Properties
Public
Name Description
See Also
TCustomPgTimeStampField Class
TCustomPgTimeStampField Class Members
Class
TCustomPgTimeStampField
Syntax
property AsPgTimeStamp: TCustomPgTimeStamp;
Remarks
© 2018 Devart
581 PostgreSQL Data Access Components
Use the AsTimeStamp property to get access to a TPgTimeStamp object which you can use
for manipulations with timestamp value.
Unit
PgAccess
Syntax
TPgConnection = class(TCustomDAConnection);
Remarks
The TPgConnection component is used to maintain connection to a PostgreSQL database.
After setting the Username, Password, Server, and Database properties, you can establish a
connection to the database by calling the Connect method or setting the Connected property
to True. There are also many properties at the connection level that affect the default behavior
of the queries executed within this connection.
Use this component in conjunction with TPgQuery, TPqTable, TPgStoredProc or other
components for convenient interoperation with PostgreSQL database.
TPgConnection object represents a unique connection to PostgreSQL database.
Note: f the port differs from the default one (5432) please use the Port property to set it.
Inheritance Hierarchy
TCustomDAConnection
TPgConnection
5.12.1.5.1 Members
Properties
Name Description
ConnectDialog (inherited from Allows to link a TCustomConnectDialog
TCustomDAConnection) component.
© 2018 Devart
Reference 582
ConvertEOL (inherited from Allows customizing line breaks in string fields and
TCustomDAConnection) parameters.
© 2018 Devart
583 PostgreSQL Data Access Components
Methods
Name Description
ApplyUpdates (inherited from
Overloaded. Applies changes in datasets.
TCustomDAConnection)
© 2018 Devart
Reference 584
TCustomDAConnection)
ExecSQLEx (inherited from Executes any SQL statement outside the TQuery
TCustomDAConnection) or TSQL components.
GetDatabaseNames (inherited
Returns a database list from the server.
from TCustomDAConnection)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDAConnection)
GetStoredProcNames (inherited
Returns a list of stored procedures from the server.
from TCustomDAConnection)
© 2018 Devart
585 PostgreSQL Data Access Components
Rollback (inherited from Discards all current data changes and ends
TCustomDAConnection) transaction.
Events
Name Description
OnConnectionLost (inherited
This event occurs when connection was lost.
from TCustomDAConnection)
OnError (inherited from This event occurs when an error has arisen in the
TCustomDAConnection) connection.
5.12.1.5.2 Properties
Public
© 2018 Devart
Reference 586
Name Description
ConnectDialog (inherited from Allows to link a TCustomConnectDialog
TCustomDAConnection) component.
ConvertEOL (inherited from Allows customizing line breaks in string fields and
TCustomDAConnection) parameters.
Published
Name Description
Used to set the time to wait while trying to
ConnectionTimeout establish a connection before terminating the
attempt and generating an error.
© 2018 Devart
587 PostgreSQL Data Access Components
See Also
TPgConnection Class
TPgConnection Class Members
Used to set the time to wait while trying to establish a connection before terminating the
attempt and generating an error.
Class
TPgConnection
Syntax
property ConnectionTimeout: integer default
DefValConnectionTimeout;
Remarks
Use the ConnectionTimeout property to set the time to wait while trying to establish a
© 2018 Devart
Reference 588
connection before terminating the attempt and generating an error. The 0 value indicates no
limit.
5.12.1.5.2.2 Database Property
Used to specify the name of the database to be used once a connection is open.
Class
TPgConnection
Syntax
property Database: string;
Remarks
Use the Database property to specify the name of the database to be used once a connection
is open. If the Database property is empty, it is assumed that the name of a database is
identical to the user name.
See Also
TCustomDAConnection.Server
Port
TCustomDAConnection.Username
TCustomDAConnection.Password
TCustomDAConnection.GetDatabaseNames
Class
TPgConnection
Syntax
property Options: TPgConnectionOptions;
Remarks
Set the properties of Options to specify the behaviour of a TPgConnectionOptions object.
Descriptions of all options are in the table below.
© 2018 Devart
589 PostgreSQL Data Access Components
Class
TPgConnection
Syntax
© 2018 Devart
Reference 590
Remarks
Use the Password property to specify a password for a connection. When property is being
changed TPgConnection calls Disconnect method.
See Also
Username
Server
TCustomDAConnection.Connect
Class
TPgConnection
Syntax
property Port: integer default PgDefValPort;
Remarks
Use the Port property to specify the port number of PostgreSQL database for connection.
See Also
TCustomDAConnection.Server
Database
Returns the process ID (PID) of the backend server process handling this connection.
Class
TPgConnection
Syntax
property ProcessID: integer;
Remarks
© 2018 Devart
591 PostgreSQL Data Access Components
Used to return the process ID (PID) of the backend server process handling this connection.
The backend PID is useful for debugging purposes and for comparison to NOTIFY messages
(which include the PID of the notifying backend process).
5.12.1.5.2.7 ProtocolVersion Property
Used to set the version of protocol for communication with PostgreSQL server.
Class
TPgConnection
Syntax
property ProtocolVersion: TProtocolVersion default
DefValProtocol;
Remarks
Set the ProtocolVersion to pv20 to work with PostgreSQL servers 7.3 or lower that don't
support the 3.0 protocol.
5.12.1.5.2.8 Schema Property
Used to change the search path of the connection to the specified schema, or get the first
value from the search path.
Class
TPgConnection
Syntax
property Schema: string stored IsSchemaStored;
Remarks
Use the Schema property to change the search path of the connection to the specified
schema, or get the first value from the search path.
Set the Schema property to change the search path of the connection to the specified
schema. When connection is open, read the value of the property to get the name of the
current schema (the first value from the current search path).
The TPgQuery, TPgStoredProc and other PgDAC components can implicitly use this
property. Therefore you may have problems in case your search path contains several
schemas and you use objects not from the current one.
© 2018 Devart
Reference 592
Class
TPgConnection
Syntax
property Server: string;
Remarks
Use the Server property to supply server name to handle server's request for a login. When
the property is being changed TPgConnection calls the Disconnect method.
See Also
Username
Password
TCustomDAConnection.Connect
Class
TPgConnection
Syntax
property ServerVersion: string;
Remarks
Read the ServerVersion property to get the PostgreSQL server version number in a string, for
a example '8.2.5'
Works only when a TPgConnection instance is connected.
5.12.1.5.2.11 ServerVersionFull Property
Holds full PostgreSQL server version including version number and some additional
information.
Class
© 2018 Devart
593 PostgreSQL Data Access Components
TPgConnection
Syntax
property ServerVersionFull: string;
Remarks
Read the ServerVersionFull property to get full PostgreSQL server version including version
number and some additional information.
Works only when a TPgConnection instance is connected.
5.12.1.5.2.12 SSLOptions Property
Used to set the properties required for protected SSL connection with the server.
Class
TPgConnection
Syntax
property SSLOptions: TPgConnectionSSLOptions;
Remarks
Use the SSLOptions property to set the properties required for protected SSL connection with
the server.
Descriptions of all options are in the table below.
Contains username.
Class
© 2018 Devart
Reference 594
TPgConnection
Syntax
property Username: string;
Remarks
Use the Username property to supply a user name to handle server's request for a login.
When the property is being changed TPgConnection calls Disconnect method.
Note: The UserName property will be used as a default value for the Database and Schema
parameters if they are empty.
See Also
Password
Server
TCustomDAConnection.Connect
5.12.1.5.3 Methods
Public
Name Description
ApplyUpdates (inherited from
Overloaded. Applies changes in datasets.
TCustomDAConnection)
© 2018 Devart
595 PostgreSQL Data Access Components
ExecSQLEx (inherited from Executes any SQL statement outside the TQuery
TCustomDAConnection) or TSQL components.
GetDatabaseNames (inherited
Returns a database list from the server.
from TCustomDAConnection)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDAConnection)
GetStoredProcNames (inherited
Returns a list of stored procedures from the server.
from TCustomDAConnection)
© 2018 Devart
Reference 596
TCustomDAConnection)
Rollback (inherited from Discards all current data changes and ends
TCustomDAConnection) transaction.
See Also
TPgConnection Class
TPgConnection Class Members
Class
TPgConnection
Syntax
procedure BreakExec;
© 2018 Devart
597 PostgreSQL Data Access Components
Remarks
Call the BreakExec method to cancel a query that is currently being executed on the
connection. If you call the Execute method of TPgQuery, it will not return until the query is
executed. So you need to call the BreakExec method from another thread to cancel the query.
5.12.1.5.3.2 CreateDataSet Method
Returns a new instance of TPgQuery class and associates it with the connection object.
Class
TPgConnection
Syntax
function CreateDataSet(AOwner: TComponent = nil):
TCustomDADataSet; override;
Return Value
a new instance of TPgQuery class.
Remarks
The CreateDataSet method returns a new instance of TPgQuery class and associates it with
the connection object.
5.12.1.5.3.3 CreateMetaData Method
Class
TPgConnection
Syntax
function CreateMetaData: TDAMetaData; override;
Return Value
a new instance of the TPgMetaData class.
Remarks
The CreateMetaData method returns a new instance of the TPgMetaData class and
associates it with the connection object.
© 2018 Devart
Reference 598
Returns a new instance of TPgSQL class and associates it with the connection object.
Class
TPgConnection
Syntax
function CreateSQL: TCustomDASQL; override;
Return Value
a new instance of TPgSQL class.
Remarks
Call the CreateSQL to return a new instance of TPgSQL class and associates it with the
connection object.
5.12.1.5.3.5 CreateTransaction Method
Class
TPgConnection
Syntax
function CreateTransaction: TDATransaction; override;
Return Value
a new instance of the TPgTransaction class.
Remarks
The createTransaction method returns a new instance of the TPgTransaction class.
5.12.1.5.3.6 GetRow Type Method
Class
TPgConnection
Overload List
© 2018 Devart
599 PostgreSQL Data Access Components
Name Description
GetRowType(TypeOID: integer) Used to get a TPgRowType object for
composite type by its OID.
GetRowType(const TypeName: string) Used to get a TPgRowType object for
composite type by its name.
Used to get a TPgRowType object for composite type by its OID.
Class
TPgConnection
Syntax
function GetRowType(TypeOID: integer): TPgRowType; overload;
Parameters
TypeOID
OID of the composite type.
Return Value
a TPgRowType object.
Remarks
Use the GetRowType function to set the RowType property of TPgRow when you know the
OID of the composite type. You can also use a TPgRowType object to get a list of composite
type attributes.
Class
TPgConnection
Syntax
function GetRowType(const TypeName: string): TPgRowType;
overload;
Parameters
TypeName
Name of the composite type.
Return Value
a TPgRowType object.
© 2018 Devart
Reference 600
Remarks
Use the GetRowType function to set the RowType property of TPgRow when you know the
name of the composite type. You can also use a TPgRowType object to get a list of
composite type attributes.
5.12.1.5.3.7 ReleaseSavepoint Method
Releases the specified savepoint without affecting any work that has been performed after its
creation.
Class
TPgConnection
Syntax
procedure ReleaseSavepoint(const Name: string);
Parameters
Name
Holds the savepoint name.
Remarks
Call the ReleaseSavepoint method to release the specified savepoint without affecting any
work that has been performed after its creation.
See Also
RollbackToSavepoint
Savepoint
Class
TPgConnection
Syntax
procedure RollbackToSavepoint(const Name: string);
Parameters
Name
© 2018 Devart
601 PostgreSQL Data Access Components
Remarks
Call the RollbackToSavepoint method to cancel all updates for the current transaction and
restore its state up to the moment of the last defined savepoint.
See Also
ReleaseSavepoint
Savepoint
Defines a point in the transaction to which you can roll back later.
Class
TPgConnection
Syntax
procedure Savepoint(const Name: string);
Parameters
Name
Holds the name of the savepoint.
Remarks
Call the Savepoint method to define a point in the transaction to which you can roll back later.
As the parameter, you can pass any valid name to identify the savepoint.
To roll back to the last savepoint call RollbackToSavepoint.
See Also
ReleaseSavepoint
RollbackToSavepoint
Class
TPgConnection
Overload List
© 2018 Devart
Reference 602
Name Description
StartTransaction Starts a new user transaction against the
database server.
StartTransaction(IsolationLevel: Starts a new user transaction against the
TPgIsolationLevel; ReadOnly: boolean) database server.
Starts a new user transaction against the database server.
Class
TPgConnection
Syntax
procedure StartTransaction; overload; override;
Remarks
StartTransaction is an overload method for TCustomDAConnection.StartTransaction. Call the
StartTransaction method to begin a new user transaction against the database server. Before
calling StartTransaction, an application should check the status of the InTransaction property.
If InTransaction is True, it indicates that a transaction is already in progress, a subsequent
call to StartTransaction without first calling TCustomDAConnection.Commit or
TCustomDAConnection.Rollback to end the current transaction raises EDatabaseError.
Calling StartTransaction when connection is closed also raises EDatabaseError.
Updates, insertions, and deletions that take place after a call to StartTransaction are held by
the server until an application calls Commit to save the changes or Rollback to cancel them.
Class
TPgConnection
Syntax
procedure StartTransaction(IsolationLevel: TPgIsolationLevel;
ReadOnly: boolean = False); reintroduce; overload;
Parameters
IsolationLevel
Specifies how the transactions containing database modifications are handled.
ReadOnly
If True, read-only transaction is started that cannot modify data in the database.
© 2018 Devart
603 PostgreSQL Data Access Components
Remarks
Call the StartTransaction method to begin a new user transaction against the database
server. Before calling StartTransaction, an application should check the status of the
InTransaction property. If InTransaction is True, it indicates that a transaction is already in
progress, a subsequent call to StartTransaction without first calling
TCustomDAConnection.Commit or TCustomDAConnection.Rollback to end the current
transaction raises EDatabaseError. Calling StartTransaction when connection is closed also
raises EDatabaseError.
Updates, insertions, and deletions that take place after a call to StartTransaction are held by
the server until an application calls Commit to save the changes or Rollback to cancel them.
5.12.1.5.4 Events
Public
Name Description
OnConnectionLost (inherited
This event occurs when connection was lost.
from TCustomDAConnection)
OnError (inherited from This event occurs when an error has arisen in the
TCustomDAConnection) connection.
Published
Name Description
OnNotice Occurs when a message or notice is received
from PostgreSQL server.
See Also
TPgConnection Class
TPgConnection Class Members
© 2018 Devart
Reference 604
Class
TPgConnection
Syntax
property OnNotice: TPgNoticeEvent;
Remarks
The OnNotice event occurs when PostgreSQL server sends a message or multiple
messages with Severity lower than ERROR.
To set the message levels to be sent to the client, use the PostgreSQL client_min_messages
configuration parameter. For more information refer to the PostgreSQL documentation.
5.12.1.5.4.2 OnNotification Event
Class
TPgConnection
Syntax
property OnNotification: TPgNotificationEvent;
Remarks
The OnNotification event occurs when an asynchronous notification is received from
PostgreSQL server. Notification can be sent using NOTIFY command. To receive
notifications use LISTEN command. To stop receiving notifications use UNLISTEN command.
You can read more information about these commands in the PostgreSQL documentation.
Note: Notifications can be received only when a call to the server is performed (for example,
on executing SQL statement). While the connection is idle, notifications are not received. To
receive notifications while the connection is idle, use the TPgAlerter component.
Unit
© 2018 Devart
605 PostgreSQL Data Access Components
PgAccess
Syntax
TPgConnectionOptions = class(TDAConnectionOptions);
Inheritance Hierarchy
TDAConnectionOptions
TPgConnectionOptions
5.12.1.6.1 Members
Properties
Name Description
AllowImplicitConnect (inherited Specifies whether to allow or not implicit
from TDAConnectionOptions) connection opening.
© 2018 Devart
Reference 606
KeepDesignConnected
(inherited from Used to prevent an application from establishing a
connection at the time of startup.
TDAConnectionOptions)
If True, the
LocalFailover (inherited from TCustomDAConnection.OnConnectionLost event
TDAConnectionOptions) occurs and a failover operation can be performed
after connection breaks.
MessagesCharset Used to set a character set for PostgreSQL error
messages.
Public
Name Description
Used to determine the default type of local sorting
DefaultSortType (inherited from for string fields. It is used when a sort type is not
TDAConnectionOptions) specified explicitly after the field name in the
TMemDataSet.IndexFieldNames property of a
© 2018 Devart
607 PostgreSQL Data Access Components
dataset.
DisconnectedMode (inherited Used to open a connection only when needed for
performing a server call and closes after
from TDAConnectionOptions)
performing the operation.
KeepDesignConnected
(inherited from Used to prevent an application from establishing a
connection at the time of startup.
TDAConnectionOptions)
If True, the
LocalFailover (inherited from TCustomDAConnection.OnConnectionLost event
TDAConnectionOptions) occurs and a failover operation can be performed
after connection breaks.
Published
Name Description
AllowImplicitConnect (inherited Specifies whether to allow or not implicit
from TDAConnectionOptions) connection opening.
© 2018 Devart
Reference 608
See Also
TPgConnectionOptions Class
TPgConnectionOptions Class Members
Defines the application name for connecting to the server. This name will be displayed in the
pg_stat_activity view and included in CSV log entries. Only printable ASCII characters may be
used in the ApplicationName value. Other characters will be replaced with question marks (?).
Class
TPgConnectionOptions
Syntax
property ApplicationName: string;
Remarks
Note: required PostgreSQL 9.0 or higher.
5.12.1.6.2.2 Charset Property
Used to set the character set that PgDAC uses to read and write character data.
Class
TPgConnectionOptions
© 2018 Devart
609 PostgreSQL Data Access Components
Syntax
property Charset: string;
Remarks
Use the Charset property to set the character set that PgDAC uses to read and write
character data.
5.12.1.6.2.3 EnableBCD Property
Class
TPgConnectionOptions
Syntax
property EnableBCD: boolean;
5.12.1.6.2.4 EnableComposites Property
Used to detect fields of composite (ROW) type and create separate fields for each attribute of
composite type.
Class
TPgConnectionOptions
Syntax
property EnableComposites: boolean default True;
Remarks
Use the EnableComposites property to detect fields of compisite (ROW) type and create
separate fields for each attribute of composite type.
When EnableComposites is set to True, PgDAC detects fields of composite type and creates
separate fields for each attribute of composite type. If the ObjectView property is set to True,
PgDAC also creates an instanse of TADTField that is parent for all attributes fields.
When EnableComposites is False, fields of composite types are not detected and mapped to
TStringField, TMemoField, TWideStringField, or TWideMemoField depending on the
UnknownAsString and UseUnicode options.
© 2018 Devart
Reference 610
Used to map fields of domain types to TField with the base domain type.
Class
TPgConnectionOptions
Syntax
property EnableDomains: boolean default True;
Remarks
Use the EnableDomains property to map fields of domain types to TField with base domain
type.
When EnableDomains is set to True, the base data type of the domian is detected and the
field with the domain data type is mapped to TField with the corresponding type. When
EnableDomains is False, fields of domain types are mapped to TStringField, TMemoField,
TWideStringField, or TWideMemoField depending on the UnknownAsString and UseUnicode
options.
5.12.1.6.2.6 EnableFMTBCD Property
Used to enable using FMTBCD instead of float for large integer numbers to keep precision.
Class
TPgConnectionOptions
Syntax
property EnableFMTBCD: boolean;
Remarks
Use the EnableFMTBCD property to enable using FMTBCD instead of float for large integer
numbers to keep precision.
5.12.1.6.2.7 EnableGeometrics Property
Class
TPgConnectionOptions
Syntax
© 2018 Devart
611 PostgreSQL Data Access Components
Remarks
Use the EnableGeometrics property to map fields of geometric types to TPgGeometricField.
When EnableGeometrics is set to True, fields with POINT, LSEG, BOX, PATH, POLYGON,
and CIRCLE data type are mapped to TPgGeometricField. When EnableGeometrics is False,
fields of geometric types are mapped to TStringField, TMemoField, TWideStringField, or
TWideMemoField depending on the UnknownAsString and UseUnicode options.
5.12.1.6.2.8 EnablePgTimeStamps Property
Used to map DATE, TIME, and TIMESTAMP fields to TPgDateField, TPgTimeField, and
TPgTimeStampField accordingly.
Class
TPgConnectionOptions
Syntax
property EnablePgTimeStamps: boolean default False;
Remarks
Use the EnablePgTimeStamp property to map DATE, TIME, and TIMESTAMP fields to
TPgDateField, TPgTimeField, and TPgTimeStampField accordingly.
By default this option is set to False, and DATE, TIME, and TIMESTAMP fields are mapped to
standard TDateField, TTimeField, and TDateTimeField. Set this option to True to work with
values than can be represended by TDateTime variable. These values include dates before
01-01-0100 or after 12-31-9999 and special values INFINITY and -INFINITY that can hold
TIMESTAMP field. You can work with such values using special PgDAC field types:
TPgDateField, TPgTimeField, and TPgTimeStampField. TPgTimeField and
TPgTimeStampField allows also getting timezone value for fields WITH TIMEZONE.
5.12.1.6.2.9 ImmediateNotices Property
Class
TPgConnectionOptions
Syntax
© 2018 Devart
Reference 612
Remarks
If True, the TPgConnection.OnNotice event occurs immediately without waiting for the SQL
query to be completed. The default value is False.
5.12.1.6.2.10 IPVersion Property
Class
TPgConnectionOptions
Syntax
property IPVersion: TIPVersion default DefValIPVersion;
Remarks
Use the IPVersion property to specify the Internet Protocol version. The default value is
T:Devart.Dac.TIPVersion.
See Also
T:Devart.Dac.TIPVersion
Class
TPgConnectionOptions
Syntax
property MessagesCharset: string;
Remarks
If the property value is empty, the character set from PostgreSQL settings will be used.
5.12.1.6.2.12 UseUnicode Property
Used to specify a value indicating whether the UTF8 charset will be used.
Class
© 2018 Devart
613 PostgreSQL Data Access Components
TPgConnectionOptions
Syntax
property UseUnicode: boolean default DefValUseUnicode;
Remarks
Use the UseUnicode property to set PostgreSQL client charset to UTF8 and converts client
data according to this charset.
When a value is assigned to this property, TPgConnection is closed.
Unit
PgAccess
Syntax
TPgConnectionSSLOptions = class(TPersistent);
5.12.1.7.1 Members
Properties
Name Description
CACert Holds the pathname to the certificate authority file.
© 2018 Devart
Reference 614
5.12.1.7.2 Properties
Published
Name Description
See Also
TPgConnectionSSLOptions Class
TPgConnectionSSLOptions Class Members
Class
TPgConnectionSSLOptions
Syntax
property CACert: string;
Remarks
CACert is the pathname to the certificate authority file.
© 2018 Devart
615 PostgreSQL Data Access Components
Class
TPgConnectionSSLOptions
Syntax
property Cert: string;
Remarks
Cert is the pathname to the certificate file.
5.12.1.7.2.3 CipherList Property
Class
TPgConnectionSSLOptions
Syntax
property CipherList: string;
Remarks
ChipherList is the list of allowed ciphers to use for SSL encryption.
5.12.1.7.2.4 Key Property
Class
TPgConnectionSSLOptions
Syntax
property Key: string;
Remarks
Key is the pathname to the key file.
© 2018 Devart
Reference 616
Used to determine whether or with what priority an SSL connection will be negotiated with the
server.
Class
TPgConnectionSSLOptions
Syntax
property Mode: TSSLMode default DefValSSLMode;
Remarks
Use the Mode property to determine whether or with what priority an SSL connection will be
negotiated with the server.
Unit
PgAccess
Syntax
TPgCursorField = class(TDACursorField);
Remarks
The TPgCursorField class provides access to the PostgreSQL cursor fields.
Inheritance Hierarchy
TDACursorField
TPgCursorField
5.12.1.8.1 Members
Properties
Name Description
© 2018 Devart
617 PostgreSQL Data Access Components
5.12.1.8.2 Properties
Public
Name Description
AsCursor Used to provide access to a TPgCursor object.
See Also
TPgCursorField Class
TPgCursorField Class Members
Class
TPgCursorField
Syntax
property AsCursor: TPgRefCursor;
Remarks
Use the AsCursor property to provide access to a TPgCursor object you can use for
manipulations with the cursor value.
Unit
PgAccess
© 2018 Devart
Reference 618
Syntax
TPgDataSetOptions = class(TDADataSetOptions);
Inheritance Hierarchy
TDADataSetOptions
TPgDataSetOptions
5.12.1.9.1 Members
Properties
Name Description
Used to delete large objects from the database
AutoDeleteBlob automatically when a record is deleted from the
dataset.
AutoPrepare (inherited from Used to execute automatic
TCustomDADataSet.Prepare on the query
TDADataSetOptions)
execution.
© 2018 Devart
619 PostgreSQL Data Access Components
TDADataSetOptions)
FlatBuffers (inherited from Used to control how a dataset treats data of the
TDADataSetOptions) ftString and ftVarBytes fields.
LongStrings (inherited from Used to represent string fields with the length that
TDADataSetOptions) is greater than 255 as TStringField.
© 2018 Devart
Reference 620
ReturnParams (inherited from Used to return the new value of fields to dataset
TDADataSetOptions) after insert or update.
© 2018 Devart
621 PostgreSQL Data Access Components
UpdateAllFields (inherited from Used to include all dataset fields in the generated
TDADataSetOptions) UPDATE and INSERT statements.
Public
Name Description
AutoPrepare (inherited from Used to execute automatic
TCustomDADataSet.Prepare on the query
TDADataSetOptions)
execution.
© 2018 Devart
Reference 622
FlatBuffers (inherited from Used to control how a dataset treats data of the
TDADataSetOptions) ftString and ftVarBytes fields.
InsertAllSetFields (inherited from Used to include all set dataset fields in the
TDADataSetOptions) generated INSERT statement
LongStrings (inherited from Used to represent string fields with the length that
TDADataSetOptions) is greater than 255 as TStringField.
ReturnParams (inherited from Used to return the new value of fields to dataset
TDADataSetOptions) after insert or update.
© 2018 Devart
623 PostgreSQL Data Access Components
UpdateAllFields (inherited from Used to include all dataset fields in the generated
TDADataSetOptions) UPDATE and INSERT statements.
Published
Name Description
Used to delete large objects from the database
AutoDeleteBlob automatically when a record is deleted from the
dataset.
CacheBlobs Used to allocate local memory buffer to hold a
copy of the large object content.
© 2018 Devart
Reference 624
See Also
TPgDataSetOptions Class
TPgDataSetOptions Class Members
Used to delete large objects from the database automatically when a record is deleted from
the dataset.
Class
TPgDataSetOptions
Syntax
property AutoDeleteBlob: boolean default True;
Remarks
Use the AutoDeleteBlob property to delete large objects from the database automatically
when a record is deleted from the dataset.
If True, the large objects are deleted from the database automatically when a record that
© 2018 Devart
625 PostgreSQL Data Access Components
Used to allocate local memory buffer to hold a copy of the large object content.
Class
TPgDataSetOptions
Syntax
property CacheBlobs: boolean default True;
Remarks
Use the CacheBlobs property to allocate local memory buffer to hold a copy of the large
object content.
If True, local memory buffer is allocated to hold a copy of the large object content.
If False, value of large object is being read and written directly from/to database without
memory buffer on the client. This can save memory on the client for very large values.
5.12.1.9.2.3 CursorWithHold Property
Class
TPgDataSetOptions
Syntax
property CursorWithHold: boolean default False;
Remarks
Use the CursorWithHold option to open query in the FetchAll=False mode without transaction.
When this option is False (default), an active transaction is required to open a query in the
FetchAll=False mode. If there is no active transaction, PgDAC opens additional internal
connection and starts transaction on this connection.
When this option is True, PgDAC uses DECLARE CURSOR ... WITH HOLD statement to
open the query. In this case no active transaction is required but this may take additional
server resources.
© 2018 Devart
Reference 626
Used to fetch values of large objects when they are explicitly requested.
Class
TPgDataSetOptions
Syntax
property DeferredBlobRead: boolean default False;
Remarks
Use the DeferredBlobRead property to fetch values of large objects when they are explicitly
requested.
If True, values of large objects are only fetched when they are explicitly requested.
Otherwise all values of large objects are fetched when dataset is opened. This option has no
sence when the CacheBlobs option is set to False.
5.12.1.9.2.5 DistinctParams Property
Class
TPgDataSetOptions
Syntax
property DistinctParams: boolean default True;
5.12.1.9.2.6 EnableBCD Property
Class
TPgDataSetOptions
Syntax
property EnableBCD: boolean;
5.12.1.9.2.7 EnableFMTBCD Property
Used to enable using FMTBCD instead of float for large integer numbers to keep precision.
Class
© 2018 Devart
627 PostgreSQL Data Access Components
TPgDataSetOptions
Syntax
property EnableFMTBCD: boolean;
Remarks
Use the EnableFMTBCD property to enable using FMTBCD instead of float for large integer
numbers to keep precision.
5.12.1.9.2.8 ExtendedFieldsInfo Property
Used to perform an additional query to get information about returned fields and the tables
they belong to.
Class
TPgDataSetOptions
Syntax
property ExtendedFieldsInfo: boolean default True;
Remarks
Use the ExtendedFieldsInfo property to perform an additional query to get information about
returned fields and the tables they belong to.
If True, an additional query is performed to get information about returned fields and the tables
they belong to. This information includes NOT NULL attribute of the field, SEQUENCE linked
to the field, and table name corresponding to the field. Table name information is needed to
detect fields that belong to updating table, and set read-only attribute for all other fields
returned by the query.
5.12.1.9.2.9 FullRefresh Property
Used to specify the fields to include in the automatically generated SQL statement when
calling the method.
Class
TPgDataSetOptions
Syntax
property FullRefresh: boolean;
© 2018 Devart
Reference 628
Remarks
Use the FullRefresh property to specify what fields to include in the automatically generated
SQL statement when calling the TCustomDADataSet.RefreshRecord method. If the
FullRefresh property is True, all fields from a query are included into SQL statement to
refresh a single record. If FullRefresh is False, only fields from TPgQuery.UpdatingTable are
included.
Note: If FullRefresh is True, the refresh of SQL statement for complex queries and views
may be generated with errors. The default value is False.
5.12.1.9.2.10 OIDAsInt Property
Used to read OID fields as integer values and map these fields to TIntegerField.
Class
TPgDataSetOptions
Syntax
property OIDAsInt: boolean default False;
Remarks
Use the OIDAsInt property to read OID fields as integer values and map these fields to
TIntegerField.
By default dataset treats all fields with OID data type in the table (except main OID field of
table created WITH OIDS option) as descriptors of large objects. PgDAC will try to read large
objects with OIDs from query, and will fail if these OIDs are not large object descriptors.
Set these option to False to read OIDs as integer values and map OID fields to TIntegerField.
Set this option to True to read OIDs as large objects descriptors, and then read the values of
the corresponding large objects. When OIDAsInt is True, OID fields are mapped on
TBlobField.
5.12.1.9.2.11 PrepareUpdateSQL Property
Class
TPgDataSetOptions
Syntax
property PrepareUpdateSQL: boolean;
© 2018 Devart
629 PostgreSQL Data Access Components
Remarks
If True, update queries are automatically prepared before executing.
5.12.1.9.2.12 SetEmptyStrToNull Property
Force replace of empty strings with NULL values in data. The default value is False.
Class
TPgDataSetOptions
Syntax
property SetEmptyStrToNull: boolean;
5.12.1.9.2.13 Unknow nAsString Property
Class
TPgDataSetOptions
Syntax
property UnknownAsString: boolean default False;
Remarks
Use the UnknownAsString to map fields of unknown data types to TStringField
(TWideStringField).
If False, fields of unknown data types (including geometric types and composite type when
the EnableGeometrics and EnableComposites options of TPgConnection are set to False)
are mapped to TMemoField or TWideMemoField depending on the value of the UseUnicode
option.
Memo is used because maximum length of values from such fields is unknown.
If True, fields of unknown data types are mapped to TStringField or TWideStringField
depending on the value of the UseUnicode option. Size of fields is set to 8192. Values larger
than this size are truncated.
5.12.1.9.2.14 UnpreparedExecute Property
Class
© 2018 Devart
Reference 630
TPgDataSetOptions
Syntax
property UnpreparedExecute: boolean default False;
Remarks
If the UnpreparedExecute propery is set to True, the simple execute is used for SQL
statement. Statement is not prepared before execute. It allows to add multiple statements
separated by semicolon to the SQL property.
5.12.1.9.2.15 UseParamTypes Property
Class
TPgDataSetOptions
Syntax
property UseParamTypes: boolean default False;
Remarks
Set the UseParamTypes option to True to disable automatic detection of parameter types.
When this option is True, data types of parameters are set basing on the DataType property.
When this option is False, data types of the parameters are detected by server automatically.
Unit
PgAccess
Syntax
TPgDataSource = class(TCRDataSource);
Remarks
TPgDataSource provides an interface between a PgDAC dataset components and data-
© 2018 Devart
631 PostgreSQL Data Access Components
Inheritance Hierarchy
TCRDataSource
TPgDataSource
5.12.1.10.1 Members
Unit
PgAccess
Syntax
TPgDateField = class(TCustomPgTimeStampField);
Remarks
The TPgDateField class provides access to the PostgreSQL date fields.
Inheritance Hierarchy
TCustomPgTimeStampField
TPgDateField
5.12.1.11.1 Members
Properties
Name Description
AsPgDate Used to provide access to a TPgDate object.
© 2018 Devart
Reference 632
5.12.1.11.2 Properties
Public
Name Description
AsPgDate Used to provide access to a TPgDate object.
See Also
TPgDateField Class
TPgDateField Class Members
Class
TPgDateField
Syntax
property AsPgDate: TPgDate;
Remarks
Use the AsPgDate property to provide access to a TPgDate object you can use for
manipulations with the date value.
© 2018 Devart
633 PostgreSQL Data Access Components
Unit
PgAccess
Syntax
TPgEncryptor = class(TCREncryptor);
Inheritance Hierarchy
TCREncryptor
TPgEncryptor
5.12.1.12.1 Members
Properties
Name Description
DataHeader (inherited from Specifies whether the additional information is
TCREncryptor) stored with the encrypted data.
EncryptionAlgorithm (inherited
Specifies the algorithm of data encryption.
from TCREncryptor)
© 2018 Devart
Reference 634
Methods
Name Description
SetKey (inherited from
Sets a key, using which data is encrypted.
TCREncryptor)
Unit
PgAccess
Syntax
TPgGeometricField = class(TField);
Remarks
The TPgGeometricField class provides access to the PostgreSQL geometric fields.
5.12.1.13.1 Members
Properties
Name Description
AsPgGeometric Used to provide access to a TPgGeometric
object.
5.12.1.13.2 Properties
Public
Name Description
© 2018 Devart
635 PostgreSQL Data Access Components
See Also
TPgGeometricField Class
TPgGeometricField Class Members
Class
TPgGeometricField
Syntax
property AsPgGeometric: TPgGeometric;
Remarks
Use the AsPgGeometric property to provide access to a TPgGeometric object you can use
for manipulations with the date value.
Unit
PgAccess
Syntax
TPgIntervalField = class(TField);
Remarks
The TPgIntervalFields class provides access to the PostgreSQL interval fields.
5.12.1.14.1 Members
Properties
© 2018 Devart
Reference 636
Name Description
AsPgInterval Used to provide access to a TPgInterval object.
5.12.1.14.2 Properties
Public
Name Description
AsPgInterval Used to provide access to a TPgInterval object.
See Also
TPgIntervalField Class
TPgIntervalField Class Members
Class
TPgIntervalField
Syntax
property AsPgInterval: TPgInterval;
Remarks
Use the AsPgInterval property to provide access to a TPgInterval object you can use for
manipulations with the interval value.
Unit
© 2018 Devart
637 PostgreSQL Data Access Components
PgAccess
Syntax
TPgLargeObject = class(TPgSQLLargeObject);
Remarks
The TPgLargeObject class provides support of PostgreSQL large objects.
Inheritance Hierarchy
TSharedObject
TBlob
TCompressedBlob
TPgSQLLargeObject
TPgLargeObject
5.12.1.15.1 Members
Properties
Name Description
AsString (inherited from TBlob) Used to manipulate BLOB value as string.
Cached (inherited from Used to specify whether the content of large object
TPgSQLLargeObject) should be stored in memory buffer on the client.
© 2018 Devart
Reference 638
IsUnicode (inherited from TBlob) Gives choice of making TBlob store and process
data in Unicode format or not.
Size (inherited from TBlob) Used to learn the size of the TBlob value in bytes.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Assign (inherited from TBlob) Sets BLOB value from another TBlob object.
Clear (inherited from TBlob) Deletes the current value in TBlob object.
CloseObject (inherited from Closes the large object that was previously
TPgSQLLargeObject) opened by the OpenObject method.
© 2018 Devart
639 PostgreSQL Data Access Components
OpenObject (inherited from Opens the large object specified by the OID
TPgSQLLargeObject) property.
Read (inherited from TBlob) Acquires a raw sequence of bytes from the data
stored in TBlob.
ReadBlob (inherited from Reads the content of the large object from the
TPgSQLLargeObject) database.
Truncate (inherited from TBlob) Sets new TBlob size and discards all data over it.
UnlinkObject (inherited from Deletes the large object specified by the OID
TPgSQLLargeObject) property from the database.
Write (inherited from TBlob) Stores a raw sequence of bytes into a TBlob
object.
WriteBlob (inherited from Writes the content of the large object to the
TPgSQLLargeObject) database.
5.12.1.15.2 Properties
Public
© 2018 Devart
Reference 640
Name Description
AsString (inherited from TBlob) Used to manipulate BLOB value as string.
Cached (inherited from Used to specify whether the content of large object
TPgSQLLargeObject) should be stored in memory buffer on the client.
IsUnicode (inherited from TBlob) Gives choice of making TBlob store and process
data in Unicode format or not.
Size (inherited from TBlob) Used to learn the size of the TBlob value in bytes.
See Also
TPgLargeObject Class
TPgLargeObject Class Members
© 2018 Devart
641 PostgreSQL Data Access Components
Class
TPgLargeObject
Syntax
property Connection: TPgConnection;
Remarks
If you call methods that read or write large object value from/to database, set the Connection
property to an appropriate TPgConnection objects. Otherwise these methods will fail.
Unit
PgAccess
Syntax
TPgLargeObjectField = class(TBlobField);
Remarks
The TPgLargeObjectFields class provides access to the PostgreSQL large object fields.
5.12.1.16.1 Members
Properties
Name Description
AsLargeObject Used to provide access to a TPgLargeObject
object.
5.12.1.16.2 Properties
© 2018 Devart
Reference 642
Public
Name Description
AsLargeObject Used to provide access to a TPgLargeObject
object.
See Also
TPgLargeObjectField Class
TPgLargeObjectField Class Members
Class
TPgLargeObjectField
Syntax
property AsLargeObject: TPgLargeObject;
Remarks
Use the AsLargeObject property to provide access to a TPgLargeObject object you can use
for manipulations with the large object value.
A component for obtaining metainformation about database objects from the server.
For a list of all members of this type, see TPgMetaData members.
Unit
PgAccess
Syntax
TPgMetaData = class(TDAMetaData);
Remarks
The TPgMetaData component is used to obtain metainformation from the server about
objects in the database, such as tables, table columns, stored procedures, etc.
© 2018 Devart
643 PostgreSQL Data Access Components
Inheritance Hierarchy
TMemDataSet
TDAMetaData
TPgMetaData
See Also
TCustomDADataSet.Debug
TCustomDASQL.Debug
DBMonitor
5.12.1.17.1 Members
Properties
Name Description
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
© 2018 Devart
Reference 644
TDAMetaData)
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
ApplyRange (inherited from
Applies a range to the dataset.
TMemDataSet)
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
© 2018 Devart
645 PostgreSQL Data Access Components
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
GetRestrictions (inherited from Used to find out which restrictions are applicable
TDAMetaData) to a certain MetaDataKind.
© 2018 Devart
Reference 646
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
OnUpdateError (inherited from Occurs when an exception is generated while
TMemDataSet) cached updates are applied to a database.
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
© 2018 Devart
647 PostgreSQL Data Access Components
A class that is used to set the values of individual parameters passed with queries or stored
procedures.
For a list of all members of this type, see TPgParam members.
Unit
PgAccess
Syntax
TPgParam = class(TDAParam);
Remarks
Use the properties of TPgParam to set the value of a parameter. Objects that use parameters
create TPgParam objects to represent these parameters. For example, TPgParam objects
are used by TPgSQL, TCustomPgDataSet.
TPgParam shares many properties with TField, as both describe the value of a field in a
dataset. However, a TField object has several properties to describe the field binding, and
how the field is displayed, edited, or calculated that are not needed in a TPgParam object.
Conversely, TPgParam includes properties that indicate how the field value is passed as a
parameter.
Inheritance Hierarchy
TDAParam
TPgParam
See Also
TCustomPgDataSet
TPgSQL
TPgParams
5.12.1.18.1 Members
Properties
Name Description
AsBlob (inherited from Used to set and read the value of the BLOB
parameter as string.
© 2018 Devart
Reference 648
TDAParam)
AsBlobRef (inherited from Used to set and read the value of the BLOB
TDAParam) parameter as a TBlob object.
AsFloat (inherited from Used to assign the value for a float field to a
TDAParam) parameter.
AsInteger (inherited from Used to assign the value for an integer field to the
TDAParam) parameter.
AsLargeInt (inherited from Used to assign the value for a LargeInteger field to
TDAParam) the parameter.
AsMemo (inherited from Used to assign the value for a memo field to the
TDAParam) parameter.
AsMemoRef (inherited from Used to set and read the value of the memo
TDAParam) parameter as a TBlob object.
© 2018 Devart
649 PostgreSQL Data Access Components
AsWideString (inherited from Used to assign the Unicode string value to the
TDAParam) parameter.
Size (inherited from TDAParam) Specifies the size of a string type parameter.
Methods
Name Description
AssignField (inherited from
Assigns field name and field value to a param.
TDAParam)
© 2018 Devart
Reference 650
5.12.1.18.2 Properties
Public
Name Description
AsBlob (inherited from Used to set and read the value of the BLOB
TDAParam) parameter as string.
AsBlobRef (inherited from Used to set and read the value of the BLOB
TDAParam) parameter as a TBlob object.
AsFloat (inherited from Used to assign the value for a float field to a
TDAParam) parameter.
AsInteger (inherited from Used to assign the value for an integer field to the
TDAParam) parameter.
AsLargeInt (inherited from Used to assign the value for a LargeInteger field to
TDAParam) the parameter.
AsMemo (inherited from Used to assign the value for a memo field to the
TDAParam) parameter.
AsMemoRef (inherited from Used to set and read the value of the memo
TDAParam) parameter as a TBlob object.
© 2018 Devart
651 PostgreSQL Data Access Components
AsWideString (inherited from Used to assign the Unicode string value to the
TDAParam) parameter.
Published
Name Description
DataType (inherited from
Indicates the data type of the parameter.
TDAParam)
Size (inherited from TDAParam) Specifies the size of a string type parameter.
See Also
© 2018 Devart
Reference 652
TPgParam Class
TPgParam Class Members
Used to specify the parameter value when it represents the date type.
Class
TPgParam
Syntax
property AsPgDate: TPgDate;
Remarks
Use the AsPgDate property to specify the parameter value when it represents the date type.
5.12.1.18.2.2 AsPgInterval Property
Used to specify the parameter value when it represents the INTERVAL type.
Class
TPgParam
Syntax
property AsPgInterval: TPgInterval;
Remarks
Use the AsPgInterval property to specify the parameter value when it represents the
INTERVAL type.
5.12.1.18.2.3 AsPgTime Property
Used to specify the parameter value when it represents the time type.
Class
TPgParam
Syntax
property AsPgTime: TPgTime;
Remarks
© 2018 Devart
653 PostgreSQL Data Access Components
Use the AsPgTime property to specify the parameter value when it represents the time type.
5.12.1.18.2.4 AsPgTimeStamp Property
Used to specify the parameter value when it represents the TimeStamp type.
Class
TPgParam
Syntax
property AsPgTimeStamp: TPgTimeStamp;
Remarks
Use the AsPgTimeStamp property to specify the parameter value when it represents the
TimeStamp type.
Unit
PgAccess
Syntax
TPgParams = class(TDAParams);
Remarks
Use TPgParams to manage a list of TPgParam objects for an object that uses field
parameters. For example, TPgStoredProc objects and TPgQuery objects use TPgParams
objects to create and access their parameters.
Inheritance Hierarchy
TDAParams
TPgParams
See Also
TPgParam
TCustomDASQL.Params
© 2018 Devart
Reference 654
TCustomDADataSet.Params
5.12.1.19.1 Members
Properties
Name Description
Items Used to iterate through all field parameters.
Methods
Name Description
FindParam (inherited from Searches for a parameter with the specified
TDAParams) name.
5.12.1.19.2 Properties
Public
Name Description
Items Used to iterate through all field parameters.
See Also
TPgParams Class
TPgParams Class Members
Class
© 2018 Devart
655 PostgreSQL Data Access Components
TPgParams
Syntax
property Items[Index: integer]: TPgParam; default;
Parameters
Index
Holds the index in the range 0..Count - 1.
Remarks
Use the Items property to iterate through all field parameters. Index identifies the index in the
range 0..Count - 1. Items can refer to a particular parameter by its index, but the
TDAParams.ParamByName method is preferred to avoid depending on the order of the
parameters.
A component for executing queries and operating record sets. It also provides flexible way to
update data.
For a list of all members of this type, see TPgQuery members.
Unit
PgAccess
Syntax
TPgQuery = class(TCustomPgDataSet);
Remarks
TPgQuery is a direct descendant of the TCustomPgDataSet component. It publishes most of
its inherited properties and events so that they can be manipulated at design-time.
Use TPgQuery to perform fetching, insertion, deletion and update of record by dynamically
generated SQL statements. TPgQuery provides automatic blocking of records, their checking
before edit and refreshing after post. Set SQL, SQLInsert, SQLDelete, SQLRefresh, and
SQLUpdate properties to define SQL statements for subsequent accesses to the database
server. There is no restriction to their syntax, so any SQL statement is allowed. Usually you
need to use INSERT, DELETE, and UPDATE statements but you also may use stored
procedures in more diverse cases.
To modify records, you can specify KeyFields. If they are not specified, TPgQuery will retrieve
primary keys for UpdatingTable from metadata. TPgQuery can automatically update only one
© 2018 Devart
Reference 656
table. Updating table is defined by the UpdatingTable property if this property is set.
Otherwise, the table a field of which is the first field in the field list in the SELECT clause is
used as an updating table.
The SQLInsert, SQLDelete, SQLUpdate, SQLRefresh properties support automatic binding of
parameters which have identical names to fields captions. To retrieve the value of a field as it
was before the operation use the field name with the 'OLD_' prefix. This is especially useful
when doing field comparisons in the WHERE clause of the statement. Use the
TCustomDADataSet.BeforeUpdateExecute event to assign the value to additional parameters
and the TCustomDADataSet.AfterUpdateExecute event to read them.
Inheritance Hierarchy
TMemDataSet
TCustomDADataSet
TCustomPgDataSet
TPgQuery
See Also
Updating Data with PgDAC Dataset Components
Master/Detail Relationships
TPgStoredProc
TPgTable
5.12.1.20.1 Members
Properties
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
657 PostgreSQL Data Access Components
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
recordset is sorted.
© 2018 Devart
Reference 658
TMemDataSet)
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
© 2018 Devart
659 PostgreSQL Data Access Components
MasterSource (inherited from Used to specify the data source component which
TCustomDADataSet) binds current dataset to the master one.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
© 2018 Devart
Reference 660
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
© 2018 Devart
661 PostgreSQL Data Access Components
Methods
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
© 2018 Devart
Reference 662
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
663 PostgreSQL Data Access Components
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
GetPgDate (inherited from Retrieves a TPgDate object for a field with known
TCustomPgDataSet) name.
© 2018 Devart
Reference 664
GetPgRow (inherited from Retrieves a TPgRow object for a field with known
TCustomPgDataSet) name.
GetPgTime (inherited from Retrieves a TPgTime object for a field with known
TCustomPgDataSet) name.
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
© 2018 Devart
665 PostgreSQL Data Access Components
ParamByName (inherited from Searches for and returns a parameter with the
TCustomPgDataSet) specified name.
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
© 2018 Devart
Reference 666
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute (inherited from Occurs after a component has executed a query to
TCustomDADataSet) database.
AfterFetch (inherited from Occurs after dataset finishes fetching data from
TCustomDADataSet) server.
© 2018 Devart
667 PostgreSQL Data Access Components
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.12.1.20.2 Properties
Public
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
Reference 668
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
© 2018 Devart
669 PostgreSQL Data Access Components
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
Reference 670
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
© 2018 Devart
671 PostgreSQL Data Access Components
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Published
Name Description
Defines whether to request all records of the query
FetchAll from database server when the dataset is being
opened.
LockMode Used to specify what kind of lock will be performed
when editing a record.
Used to specify which table in a query is assumed
UpdatingTable to be the target for subsequent data-modification
queries as a result of user incentive to insert,
update or delete records.
See Also
© 2018 Devart
Reference 672
TPgQuery Class
TPgQuery Class Members
Defines whether to request all records of the query from database server when the dataset is
being opened.
Class
TPgQuery
Syntax
property FetchAll: boolean;
Remarks
When set to True, all records of the query are requested from database server when the
dataset is being opened. When set to False, records are retrieved when a data-aware
component or a program requests it. If a query can return a lot of records, set this property to
False if initial response time is important.
Opening a dataset in FetchAll = False mode requires an active transaction.When the FetchAll
property is False, the first call to TMemDataSet.Locate and TMemDataSet.LocateEx methods
may take a lot of time to retrieve additional records to the client side.
5.12.1.20.2.2 LockMode Property
Used to specify what kind of lock will be performed when editing a record.
Class
TPgQuery
Syntax
property LockMode: TLockMode;
Remarks
Use the LockMode property to define what kind of lock will be performed when editing a
record. Locking a record is useful in creating multi-user applications. It prevents modification
of a record by several users at the same time.
Locking is performed by the RefreshRecord method.
The default value is lmNone.
© 2018 Devart
673 PostgreSQL Data Access Components
See Also
TPgStoredProc.LockMode
TPgTable.LockMode
Used to specify which table in a query is assumed to be the target for subsequent data-
modification queries as a result of user incentive to insert, update or delete records.
Class
TPgQuery
Syntax
property UpdatingTable: string;
Remarks
Use the UpdatingTable property to specify which table in a query is assumed to be the target
for the subsequent data-modification queries as a result of user incentive to insert, update or
delete records.
This property is used on Insert, Update, Delete or RefreshRecord (see also
TCustomPgDataSet.Options) if appropriate SQL (SQLInsert, SQLUpdate or SQLDelete) is
not provided.
If UpdatingTable is not set then the first table used in a query is assumed to be the target.
Example
Below are two examples for the query, where:
1. the only allowed value for UpdatingTable property is 'Dept';
2. allowed values for UpdatingTable are 'Dept' and 'Emp'.
In the first case (or by default) editable field is ShipName, in the second
A component for executing SQL statements and calling stored procedures on the database
server.
For a list of all members of this type, see TPgSQL members.
Unit
PgAccess
© 2018 Devart
Reference 674
Syntax
TPgSQL = class(TCustomDASQL);
Remarks
The TPgSQL component is a direct descendant of the TCustomDASQL class.
Use The TPgSQL component when a client application must execute SQL statement or the
PL/SQL block, and call stored procedure on the database server. The SQL statement should
not retrieve rows from the database.
Inheritance Hierarchy
TCustomDASQL
TPgSQL
See Also
TPgQuery
5.12.1.21.1 Members
Properties
Name Description
ChangeCursor (inherited from Enables or disables changing screen cursor when
TCustomDASQL) executing commands in the NonBlocking mode.
© 2018 Devart
675 PostgreSQL Data Access Components
MacroCount (inherited from Used to get the number of macros associated with
TCustomDASQL) the Macros property.
ParamValues (inherited from Used to get or set the values of individual field
TCustomDASQL) parameters that are identified by name.
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDASQL)
operation.
Methods
© 2018 Devart
Reference 676
Name Description
Execute (inherited from Overloaded. Executes a SQL statement on the
TCustomDASQL) server.
Events
Name Description
AfterExecute (inherited from
Occurs after a SQL statement has been executed.
TCustomDASQL)
© 2018 Devart
677 PostgreSQL Data Access Components
5.12.1.21.2 Properties
Public
Name Description
ChangeCursor (inherited from Enables or disables changing screen cursor when
TCustomDASQL) executing commands in the NonBlocking mode.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDASQL) the Macros property.
ParamValues (inherited from Used to get or set the values of individual field
TCustomDASQL) parameters that are identified by name.
© 2018 Devart
Reference 678
TCustomDASQL)
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDASQL)
operation.
Published
Name Description
CommandTimeout The time to wait for a statement to be executed.
See Also
TPgSQL Class
TPgSQL Class Members
Class
TPgSQL
Syntax
property CommandTimeout: integer default 0;
© 2018 Devart
679 PostgreSQL Data Access Components
Used to specify a connection object that will be used to connect to a data store.
Class
TPgSQL
Syntax
property Connection: TPgConnection;
Remarks
Use the Connection property to specify a connection object that will be used to connect to a
data store.
Set at design-time by selecting from the list of provided TPgConnection objects.
At run-time, set the Connection property to reference an existing TPgConnection object.
See Also
TPgConnection
Returns OID of the record inserted by the last query for table with OIDs.
Class
TPgSQL
Syntax
property LastInsertOID: Int64;
Remarks
Use the LastInsertOID property to get OID of the record inserted by the last query for table
with OIDs.
5.12.1.21.2.4 Params Property
Class
TPgSQL
Syntax
© 2018 Devart
Reference 680
Remarks
Contains parameters for a query's SQL statement.
Access Params at runtime to view and set parameter names, values, and data types
dynamically (at design time use the Parameters editor to set the parameter information).
Params is a zero-based array of parameter records. Index specifies the array element to
access.
An easier way to set and retrieve parameter values when the name of each parameter is
known is to call ParamByName.
5.12.1.21.2.5 UnpreparedExecute Property
Class
TPgSQL
Syntax
property UnpreparedExecute: boolean default False;
Remarks
If the UnpreparedExecute propery is set to True, the simple execute is used for SQL
statement. Statement is not prepared before execute. It allows to add multiple statements
separated by semicolon to the SQL property.
5.12.1.21.2.6 UseParamTypes Property
Class
TPgSQL
Syntax
property UseParamTypes: boolean default False;
Remarks
Set the UseParamTypes option to True to disable automatic detection of parameter types.
When this option is True, data types of parameters are set basing on the DataType property.
© 2018 Devart
681 PostgreSQL Data Access Components
When this option is False, data types of the parameters are detected by server automatically.
5.12.1.21.3 Methods
Public
Name Description
Execute (inherited from Overloaded. Executes a SQL statement on the
TCustomDASQL) server.
See Also
© 2018 Devart
Reference 682
TPgSQL Class
TPgSQL Class Members
Class
TPgSQL
Syntax
function FindParam(const Value: string): TPgParam;
Parameters
Value
Holds the stored procedure name.
Return Value
the parameter, if a match was found. Nil otherwise.
Remarks
Call the FindParam method to find a parameter with the name passed in the Name argument.
If a match was found, FindParam returns the parameter. Otherwise, it returns nil.
See Also
TPgParam
ParamByName
Class
TPgSQL
Syntax
function ParamByName(const Value: string): TPgParam;
Parameters
Value
Holds the parameter name.
Return Value
© 2018 Devart
683 PostgreSQL Data Access Components
Remarks
Call the ParamByName method to find a parameter with the name passed in the Name
argument.
If a match is found, ParamByName returns the parameter. Otherwise, an exception is raised.
See Also
TPgParam
FindParam
Unit
PgAccess
Syntax
TPgStoredProc = class(TCustomPgStoredProc);
Remarks
Use TPgStoredProc to access stored procedures on the database server.
You need only to define the StoredProcName property, and the SQL statement to call the
stored procedure will be generated automatically.
Use the Execute method at runtime to generate request that instructs server to execute
procedure and PrepareSQL to describe parameters at run time
Inheritance Hierarchy
TMemDataSet
TCustomDADataSet
TCustomPgDataSet
TCustomPgStoredProc
TPgStoredProc
See Also
TPgQuery
TPgSQL
© 2018 Devart
Reference 684
5.12.1.22.1 Members
Properties
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
© 2018 Devart
685 PostgreSQL Data Access Components
TCustomDADataSet)
FetchAll (inherited from Defines whether to request all records of the query
from database server when the dataset is being
TCustomPgDataSet)
opened.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
query for table with OIDs.
© 2018 Devart
Reference 686
TCustomPgDataSet)
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
687 PostgreSQL Data Access Components
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
© 2018 Devart
Reference 688
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
© 2018 Devart
689 PostgreSQL Data Access Components
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 690
© 2018 Devart
691 PostgreSQL Data Access Components
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
GetPgDate (inherited from Retrieves a TPgDate object for a field with known
TCustomPgDataSet) name.
GetPgRow (inherited from Retrieves a TPgRow object for a field with known
TCustomPgDataSet) name.
© 2018 Devart
Reference 692
GetPgTime (inherited from Retrieves a TPgTime object for a field with known
TCustomPgDataSet) name.
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
ParamByName (inherited from Searches for and returns a parameter with the
TCustomPgDataSet) specified name.
© 2018 Devart
693 PostgreSQL Data Access Components
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
© 2018 Devart
Reference 694
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute (inherited from Occurs after a component has executed a query to
TCustomDADataSet) database.
AfterFetch (inherited from Occurs after dataset finishes fetching data from
TCustomDADataSet) server.
© 2018 Devart
695 PostgreSQL Data Access Components
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.12.1.22.2 Properties
Public
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
© 2018 Devart
Reference 696
TCustomDADataSet)
FetchAll (inherited from Defines whether to request all records of the query
from database server when the dataset is being
TCustomPgDataSet)
opened.
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
Used to specify the name of a sequence that will
KeySequence (inherited from be used to fill in a key field after a new record is
inserted or posted to a database.
© 2018 Devart
697 PostgreSQL Data Access Components
TCustomPgDataSet)
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
ParamCount (inherited from Used to indicate how many parameters are there
in the Params property.
© 2018 Devart
Reference 698
TCustomDADataSet)
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
to perform a record lock.
© 2018 Devart
699 PostgreSQL Data Access Components
TCustomDADataSet)
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Published
Name Description
CommandTimeout The time to wait for a statement to be executed.
See Also
© 2018 Devart
Reference 700
TPgStoredProc Class
TPgStoredProc Class Members
Class
TPgStoredProc
Syntax
property CommandTimeout: integer;
5.12.1.22.2.2 LockMode Property
Used to specify what kind of lock will be performed when editing a record.
Class
TPgStoredProc
Syntax
property LockMode: TLockMode;
Remarks
Use the LockMode property to define what kind of lock will be performed when editing a
record. Locking a record is useful in creating multi-user applications. It prevents modification
of a record by several users at the same time.
Locking is performed by the RefreshRecord method.
The default value is lmNone.
5.12.1.22.2.3 StoredProcName Property
Used to specify the name of the stored procedure to call on the server.
Class
TPgStoredProc
Syntax
property StoredProcName: string;
Remarks
© 2018 Devart
701 PostgreSQL Data Access Components
Use the StoredProcName property to specify the name of the stored procedure to call on the
server. If StoredProcName does not match the name of an existing stored procedure on the
server, then when the application attempts to prepare the procedure prior to execution, an
exception is raised.
A component for retrieving and updating data in a single table without writing SQL statements.
For a list of all members of this type, see TPgTable members.
Unit
PgAccess
Syntax
TPgTable = class(TCustomPgTable);
Remarks
The TPgTable component allows retrieving and updating data in a single table without writing
SQL statements. Use TPgTable to access data in a table . Use the TableName property to
specify table name. TPgTable uses the KeyFields property to build SQL statements for
updating table data. KeyFields is a string containing a semicolon-delimited list of the field
names.
Inheritance Hierarchy
TMemDataSet
TCustomDADataSet
TCustomPgDataSet
TCustomPgTable
TPgTable
See Also
Updating Data with PgDAC Dataset Components
Master/Detail Relationships
TCustomPgDataSet
TPgQuery
TCustomPgTable
© 2018 Devart
Reference 702
5.12.1.23.1 Members
Properties
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
© 2018 Devart
703 PostgreSQL Data Access Components
TCustomPgDataSet)
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
Limit (inherited from Used to set the number of rows retrieved from the
TCustomPgTable) query.
© 2018 Devart
Reference 704
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
Offset (inherited from Used to allow retrieving data from the server
TCustomPgTable) starting from the specified row.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
705 PostgreSQL Data Access Components
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
© 2018 Devart
Reference 706
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
AddWhere (inherited from Adds condition to the WHERE clause of SELECT
TCustomDADataSet) statement in the SQL property.
© 2018 Devart
707 PostgreSQL Data Access Components
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
DeleteWhere (inherited from Removes WHERE clause from the SQL property
TCustomDADataSet) and assigns the BaseSQL property.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 708
© 2018 Devart
709 PostgreSQL Data Access Components
GetFieldPrecision (inherited
Retrieves the precision of a number field.
from TCustomDADataSet)
GetKeyFieldNames (inherited
Provides a list of available key field names.
from TCustomDADataSet)
GetPgDate (inherited from Retrieves a TPgDate object for a field with known
TCustomPgDataSet) name.
GetPgRow (inherited from Retrieves a TPgRow object for a field with known
TCustomPgDataSet) name.
GetPgTime (inherited from Retrieves a TPgTime object for a field with known
TCustomPgDataSet) name.
© 2018 Devart
Reference 710
GotoCurrent (inherited from Sets the current record in this dataset similar to
TCustomDADataSet) the current record in another dataset.
ParamByName (inherited from Searches for and returns a parameter with the
TCustomPgDataSet) specified name.
© 2018 Devart
711 PostgreSQL Data Access Components
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
SQLSaved (inherited from Determines if the SQL property value was saved
TCustomDADataSet) to the BaseSQL property.
© 2018 Devart
Reference 712
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
AfterExecute (inherited from Occurs after a component has executed a query to
TCustomDADataSet) database.
AfterFetch (inherited from Occurs after dataset finishes fetching data from
TCustomDADataSet) server.
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.12.1.23.2 Properties
© 2018 Devart
713 PostgreSQL Data Access Components
Public
Name Description
BaseSQL (inherited from Used to return SQL text without any changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL.
DetailFields (inherited from Used to specify the fields that correspond to the
foreign key fields from MasterFields when building
TCustomDADataSet)
master/detail relationship.
© 2018 Devart
Reference 714
FinalSQL (inherited from Used to return SQL text with all changes
performed by AddWhere, SetOrderBy, and
TCustomDADataSet)
FilterSQL, and with expanded macros.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
KeyFields (inherited from Used to build SQL statements for the SQLDelete,
SQLInsert, and SQLUpdate properties if they were
TCustomDADataSet)
empty before updating the database.
KeySequence (inherited from Used to specify the name of a sequence that will
be used to fill in a key field after a new record is
TCustomPgDataSet)
inserted or posted to a database.
LastInsertOID (inherited from Returns OID of the record inserted by the last
TCustomPgDataSet) query for table with OIDs.
Limit (inherited from Used to set the number of rows retrieved from the
TCustomPgTable) query.
© 2018 Devart
715 PostgreSQL Data Access Components
MacroCount (inherited from Used to get the number of macros associated with
TCustomDADataSet) the Macros property.
Offset (inherited from Used to allow retrieving data from the server
TCustomPgTable) starting from the specified row.
ParamCount (inherited from Used to indicate how many parameters are there
TCustomDADataSet) in the Params property.
© 2018 Devart
Reference 716
RowsAffected (inherited from Used to indicate the number of rows which were
inserted, updated, or deleted during the last query
TCustomDADataSet)
operation.
SQLDelete (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying a deletion to a record.
SQLInsert (inherited from Used to specify the SQL statement that will be
TCustomDADataSet) used when applying an insertion to a dataset.
SQLLock (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) to perform a record lock.
SQLRecCount (inherited from Used to specify the SQL statement that is used to
TCustomDADataSet) get the record count when opening a dataset.
SQLRefresh (inherited from Used to specify a SQL statement that will be used
to refresh current record by calling the
TCustomDADataSet)
TCustomDADataSet.RefreshRecord procedure.
© 2018 Devart
717 PostgreSQL Data Access Components
SQLUpdate (inherited from Used to specify a SQL statement that will be used
TCustomDADataSet) when applying an update to a dataset.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Published
Name Description
Defines whether to request all records of the query
FetchAll from database server when the dataset is being
opened.
LockMode Used to specify what kind of lock will be performed
when editing a record.
See Also
TPgTable Class
TPgTable Class Members
Defines whether to request all records of the query from database server when the dataset is
being opened.
© 2018 Devart
Reference 718
Class
TPgTable
Syntax
property FetchAll: boolean;
Remarks
When set to True, all records of the query are requested from database server when the
dataset is being opened. When set to False, records are retrieved when a data-aware
component or a program requests it. If a query can return a lot of records, set this property to
False if initial response time is important.
Opening a dataset in FetchAll = False mode requires an active transaction.When the FetchAll
property is False, the first call to TMemDataSet.Locate and TMemDataSet.LocateEx methods
may take a lot of time to retrieve additional records to the client side.
5.12.1.23.2.2 LockMode Property
Used to specify what kind of lock will be performed when editing a record.
Class
TPgTable
Syntax
property LockMode: TLockMode;
Remarks
Use the LockMode property to define what kind of lock will be performed when editing a
record. Locking a record is useful in creating multi-user applications. It prevents modification
of a record by several users at the same time.
Locking is performed by the RefreshRecord method.
The default value is lmNone.
See Also
TPgStoredProc.LockMode
TPgQuery.LockMode
© 2018 Devart
719 PostgreSQL Data Access Components
Class
TPgTable
Syntax
property OrderFields: string;
Remarks
TPgTable uses the OrderFields property to build ORDER BY clause of SQL statements. To
set several field names to this property separate them with commas.
TPgTable is reopened when OrderFields is being changed.
See Also
TPgTable
Used to specify the name of the database table this component encapsulates.
Class
TPgTable
Syntax
property TableName: string;
Remarks
Use the TableName property to specify the name of the database table this component
encapsulates. If TCustomDADataSet.Connection is assigned at design time,select a valid
table name from the TableName drop-down list in Object Inspector.
Unit
PgAccess
© 2018 Devart
Reference 720
Syntax
TPgTimeField = class(TCustomPgTimeStampField);
Remarks
The TPgTimeFields class provides access to the PostgreSQL time fields.
Inheritance Hierarchy
TCustomPgTimeStampField
TPgTimeField
5.12.1.24.1 Members
Properties
Name Description
AsPgTime Used to provide access to a TPgTime object.
5.12.1.24.2 Properties
Public
Name Description
AsPgTime Used to provide access to a TPgTime object.
See Also
© 2018 Devart
721 PostgreSQL Data Access Components
TPgTimeField Class
TPgTimeField Class Members
Class
TPgTimeField
Syntax
property AsPgTime: TPgTime;
Remarks
Use the AsPgTime property to provide access to a TPgTime object you can use for
manipulations with the time value.
Unit
PgAccess
Syntax
TPgTimeStampField = class(TCustomPgTimeStampField);
Remarks
TPgTimeStampField provides access to PostgreSQL timestamp fields.
Inheritance Hierarchy
TCustomPgTimeStampField
TPgTimeStampField
5.12.1.25.1 Members
Properties
© 2018 Devart
Reference 722
Name Description
AsPgTimeStamp Used to provide access to a TPgTimeStamp
object.
5.12.1.25.2 Properties
Public
Name Description
AsPgTimeStamp Used to provide access to a TPgTimeStamp
object.
See Also
TPgTimeStampField Class
TPgTimeStampField Class Members
Class
TPgTimeStampField
Syntax
property AsPgTimeStamp: TPgTimeStamp;
Remarks
Use the AsTimeStamp property to get access to a TPgTimeStamp object which you can use
for manipulations with the timestamp value.
Unit
© 2018 Devart
723 PostgreSQL Data Access Components
PgAccess
Syntax
TPgTransaction = class(TDATransaction);
Remarks
The TPgTransaction component is used to provide discrete transaction control over
connection. This component is used internally by PgDAC. For user, it is recommended to use
methods of TPgConnection instead (such as StartTransaction, Commit, Rollback) for
transaction contol.
Inheritance Hierarchy
TDATransaction
TPgTransaction
See Also
TCustomDAConnection.StartTransaction
TCustomDAConnection.Commit
TCustomDAConnection.Rollback
5.12.1.26.1 Members
Properties
Name Description
Active (inherited from
Used to determine if the transaction is active.
TDATransaction)
Methods
© 2018 Devart
Reference 724
Name Description
Commit (inherited from
Commits the current transaction.
TDATransaction)
Events
Name Description
OnCommit (inherited from Occurs after the transaction has been successfully
TDATransaction) committed.
OnCommitRetaining (inherited
Occurs after CommitRetaining has been executed.
from TDATransaction)
OnError (inherited from Used to process errors that occur during executing
TDATransaction) a transaction.
OnRollback (inherited from Occurs after the transaction has been successfully
TDATransaction) rolled back.
5.12.1.26.2 Properties
© 2018 Devart
725 PostgreSQL Data Access Components
Public
Name Description
Active (inherited from
Used to determine if the transaction is active.
TDATransaction)
See Also
TPgTransaction Class
TPgTransaction Class Members
Used to specify how the transactions containing database modifications are handled.
Class
TPgTransaction
Syntax
property IsolationLevel: TCRIsolationLevel;
Remarks
Use the IsolationLevel property to specify how the transactions containing database
modifications are handled.
Unit
PgAccess
Syntax
© 2018 Devart
Reference 726
TPgUpdateSQL = class(TCustomDAUpdateSQL);
Inheritance Hierarchy
TCustomDAUpdateSQL
TPgUpdateSQL
5.12.1.27.1 Members
Properties
Name Description
DataSet (inherited from Used to hold a reference to the
TCustomDAUpdateSQL) TCustomDADataSet object that is being updated.
© 2018 Devart
727 PostgreSQL Data Access Components
SQL (inherited from Used to return a SQL statement for one of the
TCustomDAUpdateSQL) ModifySQL, InsertSQL, or DeleteSQL properties.
Methods
Name Description
Apply (inherited from Sets parameters for a SQL statement and
TCustomDAUpdateSQL) executes it to update a record.
5.12.2 Types
Types in the PgAccess unit.
Types
Name Description
TPgNoticeEvent This type is used for the TPgConnection.OnNotice
event.
© 2018 Devart
Reference 728
Unit
PgAccess
Syntax
TPgNoticeEvent = procedure (Sender: TObject; Errors: TPgErrors) of
object;
Parameters
Sender
An object that raised the event.
Errors
Holds a collection of TPgError objects containing notices.
5.12.2.2 TPgNotificationEvent Procedure Reference
Unit
PgAccess
Syntax
TPgNotificationEvent = procedure (Sender: TObject; const
EventName: string; PID: integer; const EventMessage: string) of
object;
Parameters
Sender
An object that raised the event.
EventName
Holds the event name.
PID
Holds the process ID of a connection that has sent this notification.
EventMessage
Holds the event message.
Remarks
EventMessage parameter supported in PostgreSQL 9.0 or higher. For previous PostgreSQL
© 2018 Devart
729 PostgreSQL Data Access Components
5.12.3 Enumerations
Enumerations in the PgAccess unit.
Enumerations
Name Description
TPgIsolationLevel Specifies the way the transactions containing
database modifications are handled.
Specifies the way the transactions containing database modifications are handled.
Unit
PgAccess
Syntax
TPgIsolationLevel = (pilReadCommitted, pilSerializable);
Values
Value Meaning
If the transaction contains DML that requires row locks held by
pilReadCommitted another transaction, then the DML statement waits until the row
locks are released. The default PostgreSQL behavior.
Specifies serializable transaction isolation mode as defined in
the SQL92 standard. If a serializable transaction contains data
pilSerializable manipulation language (DML) that attempts to update any
resource that may have been updated in a transaction
uncommitted at the start of the serializable transaction, then the
DML statement fails.
5.12.4 Constants
Constants in the PgAccess unit.
Constants
Name Description
© 2018 Devart
Reference 730
Unit
PgAccess
Syntax
PgDACVersion = '5.3.8';
5.13 PgAlerter
This unit contains the implementation of the TPgAlerter component.
Classes
Name Description
A component that allows to register interest in and
TPgAlerter asynchronously handle event notifications posted
by PostgreSQL server.
5.13.1 Classes
Classes in the PgAlerter unit.
Classes
Name Description
A component that allows to register interest in and
TPgAlerter asynchronously handle event notifications posted
by PostgreSQL server.
5.13.1.1 TPgAlerter Class
A component that allows to register interest in and asynchronously handle event notifications
posted by PostgreSQL server.
For a list of all members of this type, see TPgAlerter members.
Unit
PgAlerter
© 2018 Devart
731 PostgreSQL Data Access Components
Syntax
TPgAlerter = class(TDAAlerter);
Remarks
The TPgAlerter component allows you to register interest in and asynchronously handle event
notifications posted by PostgreSQL server. Notifications are posted to all clients when a client
executes the NOTIFY command.
Use TPgAlerter to handle events for responding to actions and database changes made by
other applications.
To get events application must register the required events. To do it set the Events property to
the required events and call the Start method. TPgAlerter calls the LISTEN command to listen
on specified events. When one of the registered events occurs, the OnEvent handler is
called.
Note: Notifications are transaction-based. This means that the waiting connection does not
get event until the transaction posting the event commits.
Inheritance Hierarchy
TDAAlerter
TPgAlerter
See Also
The Alerter demo program
5.13.1.1.1 Members
Properties
Name Description
Active (inherited from Used to determine if TDAAlerter waits for
TDAAlerter) messages.
© 2018 Devart
Reference 732
TDAAlerter)
Methods
Name Description
SendEvent Overloaded.Description is not available at the
moment.
Events
Name Description
OnError (inherited from
Occurs if an exception occurs in waiting process
TDAAlerter)
5.13.1.1.2 Properties
Public
Name Description
Active (inherited from Used to determine if TDAAlerter waits for
TDAAlerter) messages.
© 2018 Devart
733 PostgreSQL Data Access Components
TDAAlerter)
Published
Name Description
Events Used to set the names of the events to wait.
See Also
TPgAlerter Class
TPgAlerter Class Members
Class
TPgAlerter
Syntax
property Events: string;
Remarks
Use the Events property to set the names of the events to wait.
5.13.1.1.3 Methods
Public
Name Description
SendEvent Overloaded.Description is not available at the
moment.
© 2018 Devart
Reference 734
See Also
TPgAlerter Class
TPgAlerter Class Members
Class
TPgAlerter
Overload List
Name Description
SendEvent(const Name: string) Sends an event notification with Name.
SendEvent(const Name: string;
Sends an event notification with Name.
Message: string)
Class
TPgAlerter
Syntax
procedure SendEvent(const Name: string); overload;
Parameters
Name
Message name.
Remarks
Call the SendEvent method to send an event notification with Name.
Class
© 2018 Devart
735 PostgreSQL Data Access Components
TPgAlerter
Syntax
procedure SendEvent(const Name: string; Message: string);
overload;
Parameters
Name
Message name.
Message
Message text.
Remarks
Note: required PostgreSQL 9.0 or higher.
5.13.1.1.4 Events
Public
Name Description
OnError (inherited from
Occurs if an exception occurs in waiting process
TDAAlerter)
Published
Name Description
OnEvent Occurs when waiting thread receives event
notification from PostgreSQL server.
See Also
TPgAlerter Class
TPgAlerter Class Members
© 2018 Devart
Reference 736
Occurs when waiting thread receives event notification from PostgreSQL server.
Class
TPgAlerter
Syntax
property OnEvent: TPgNotificationEvent;
Remarks
OnEvent occurs when waiting thread receives event notification from PostgreSQL server.
5.14 PgClasses
This unit contains the implementation of internal PgDAC classes and types.
Classes
Name Description
TPgCursor A class for working with PostgreSQL cursors.
Enumerations
Name Description
TProtocolVersion Specifies version of protocol to be used when
several versions are available.
This option determines whether or with what
TSSLMode priority an SSL connection will be negotiated with
the server.
5.14.1 Classes
Classes in the PgClasses unit.
Classes
Name Description
TPgCursor A class for working with PostgreSQL cursors.
© 2018 Devart
737 PostgreSQL Data Access Components
Unit
PgClasses
Syntax
TPgCursor = class(TCRCursor);
Remarks
The TPgCursor class is used to work with PostgreSQL cursors. This is a PgDAC internal
class, and application should not use it directly.
Inheritance Hierarchy
TSharedObject
TCRCursor
TPgCursor
5.14.1.1.1 Members
Properties
Name Description
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
Reference 738
5.14.1.1.2 Properties
Public
Name Description
RefCount (inherited from Used to return the count of reference to a
TSharedObject) TSharedObject object.
See Also
TPgCursor Class
TPgCursor Class Members
Class
TPgCursor
Syntax
property State: TCursorState;
See Also
TCursorState
5.14.2 Enumerations
Enumerations in the PgClasses unit.
Enumerations
© 2018 Devart
739 PostgreSQL Data Access Components
Name Description
TProtocolVersion Specifies version of protocol to be used when
several versions are available.
This option determines whether or with what
TSSLMode priority an SSL connection will be negotiated with
the server.
5.14.2.1 TProtocolVersion Enumeration
Unit
PgClasses
Syntax
TProtocolVersion = (pv20, pv30);
Values
Value Meaning
pv20 Version 2.0 protocol.
pv30 Version 3.0 protocol.
5.14.2.2 TSSLMode Enumeration
This option determines whether or with what priority an SSL connection will be negotiated with
the server.
Unit
PgClasses
Syntax
TSSLMode = (smDisable, smRequire, smPrefer, smAllow);
Values
Value Meaning
smAllow Negotiates trying first a non-SSL connection, then if that fails,
tries an SSL connection.
smDisable Only an unencrypted SSL connection will be attempted.
© 2018 Devart
Reference 740
Remarks
If PostgreSQL is compiled without SSL support, using option smRequire will cause an error,
while options smAllow and smPrefer will be accepted, but PgDAC will not in fact attempt an
SSL connection.
5.15 PgConnectionPool
This unit contains the TPgConnectionPoolManager class for managing connection pool.
Classes
Name Description
TPgConnectionPoolManager A class of methods that are used for managing
PgDAC connection pool.
5.15.1 Classes
Classes in the PgConnectionPool unit.
Classes
Name Description
TPgConnectionPoolManager A class of methods that are used for managing
PgDAC connection pool.
A class of methods that are used for managing PgDAC connection pool.
For a list of all members of this type, see TPgConnectionPoolManager members.
Unit
PgConnectionPool
Syntax
TPgConnectionPoolManager = class(TCRConnectionPoolManager);
Remarks
© 2018 Devart
741 PostgreSQL Data Access Components
Inheritance Hierarchy
TCRConnectionPoolManager
TPgConnectionPoolManager
See Also
Connection Pooling
5.15.1.1.1 Members
5.16 PgDacVcl
This unit contains the visual constituent of PgDAC.
Classes
Name Description
TPgConnectDialog A component providing a dialog box for user to
supply his login information.
5.16.1 Classes
Classes in the PgDacVcl unit.
Classes
Name Description
TPgConnectDialog A component providing a dialog box for user to
supply his login information.
A component providing a dialog box for user to supply his login information.
For a list of all members of this type, see TPgConnectDialog members.
Unit
PgDacVcl
Syntax
© 2018 Devart
Reference 742
TPgConnectDialog = class(TCustomConnectDialog);
Remarks
The TPgConnectDialog class provides a dialog box for user to supply his login information.
The TPgConnectDialog component is a direct descendant of the TCustomConnectDialog
class. Use TPgConnectDialog to provide dialog box for a user to supply user name,
password, server, port, and database name. You may want to customize appearance of the
dialog box using properties of this class.
Inheritance Hierarchy
TCustomConnectDialog
TPgConnectDialog
5.16.1.1.1 Members
Properties
Name Description
CancelButton (inherited from
Used to specify the label for the Cancel button.
TCustomConnectDialog)
DialogClass (inherited from Used to specify the class of the form that will be
TCustomConnectDialog) displayed to enter login information.
© 2018 Devart
743 PostgreSQL Data Access Components
LabelSet (inherited from Used to set the language of buttons and labels
TCustomConnectDialog) captions.
Methods
Name Description
Execute (inherited from Displays the connect dialog and calls the
connection's Connect method when user clicks the
TCustomConnectDialog)
Connect button.
© 2018 Devart
Reference 744
5.16.1.1.2 Properties
Public
Name Description
CancelButton (inherited from
Used to specify the label for the Cancel button.
TCustomConnectDialog)
DialogClass (inherited from Used to specify the class of the form that will be
TCustomConnectDialog) displayed to enter login information.
LabelSet (inherited from Used to set the language of buttons and labels
TCustomConnectDialog) captions.
© 2018 Devart
745 PostgreSQL Data Access Components
See Also
TPgConnectDialog Class
TPgConnectDialog Class Members
Class
TPgConnectDialog
Syntax
property Connection: TPgConnection;
© 2018 Devart
Reference 746
Remarks
Use the Connection property to learn which TPgConnection component uses
TPgConnectDialog object. This property is read-only.
See Also
TCustomDAConnection.ConnectDialog
Class
TPgConnectDialog
Syntax
property DatabaseLabel: string;
Remarks
Use the DatabaseLabel property to specify a prompt for database edit.
See Also
ShowDatabase
Class
TPgConnectDialog
Syntax
property PortLabel: string;
Remarks
Use the PortLabel property to specify a prompt for port edit.
See Also
ShowPort
© 2018 Devart
747 PostgreSQL Data Access Components
Class
TPgConnectDialog
Syntax
property ShowDatabase: boolean default True;
Remarks
Use the ShowDatabase property to display a field for entering database at connect dialog.
The default value is True.
See Also
DatabaseLabel
ShowPort
Class
TPgConnectDialog
Syntax
property ShowPort: boolean default True;
Remarks
Use the ShowPort property to display a field for entering port at connect dialog.
The default value is True.
See Also
PortLabel
ShowDatabase
© 2018 Devart
Reference 748
5.17 PgDump
This unit contains the implementation of the TPgDump component.
Classes
Name Description
A component for storing database or its parts as a
TPgDump script and also for restoring database from the
received script.
TPgDumpOptions This class allows setting up the behaviour of the
TPgDump component.
Types
Name Description
TPgDumpObjects Represents the set of TPgDumpObject.
Enumerations
Name Description
TPgDumpMode Specifies the mode of backup performed by
TPgDump.
5.17.1 Classes
Classes in the PgDump unit.
Classes
Name Description
A component for storing database or its parts as a
TPgDump script and also for restoring database from the
received script.
TPgDumpOptions This class allows setting up the behaviour of the
TPgDump component.
© 2018 Devart
749 PostgreSQL Data Access Components
A component for storing database or its parts as a script and also for restoring database from
the received script.
For a list of all members of this type, see TPgDump members.
Unit
PgDump
Syntax
TPgDump = class(TDADump);
Remarks
The TPgDump component is a component for storing database or its parts as a script and
also for restoring database from the received script.
Serves to store a database or its parts as a script and also to restore database from received
script. TPgDump behaviour is similar to pg_dump program. Use SchemaNames,
TableNames, and ObjectTypes properties to specify the objects to be stored. To generate a
script call TDADump.Backup or TDADump.BackupQuery method. Resulted script can be
viewed in TDADump.SQL.
Inheritance Hierarchy
TDADump
TPgDump
5.17.1.1.1 Members
Properties
Name Description
Connection (inherited from Used to specify a connection object that will be
TDADump) used to connect to a data store.
© 2018 Devart
Reference 750
SQL (inherited from TDADump) Used to set or get the dump script.
Methods
Name Description
Backup (inherited from Dumps database objects to the TDADump.SQL
TDADump) property.
© 2018 Devart
751 PostgreSQL Data Access Components
RestoreFromStream (inherited
Executes a script received from the stream.
from TDADump)
Events
Name Description
Occurs to indicate the TDADump.Backup,
OnBackupProgress (inherited M:Devart.Dac.TDADump.BackupToFile(System.S
from TDADump) tring) or
M:Devart.Dac.TDADump.BackupToStream(Borla
nd.Vcl.TStream) method execution progress.
OnError (inherited from Occurs when PostgreSQL raises some error on
TDADump) TDADump.Restore.
Public
Name Description
Connection (inherited from Used to specify a connection object that will be
TDADump) used to connect to a data store.
Published
Name Description
Debug (inherited from Used to display executing statement, all its
TDADump) parameters' values, and the type of parameters.
© 2018 Devart
Reference 752
SQL (inherited from TDADump) Used to set or get the dump script.
See Also
TPgDump Class
TPgDump Class Members
Class
TPgDump
Syntax
property Mode: TPgDumpMode default dmAll;
Remarks
Use the Mode property to specify the mode of backup performed by TPgDump.
5.17.1.1.2.2 ObjectTypes Property
Class
TPgDump
© 2018 Devart
753 PostgreSQL Data Access Components
Syntax
property ObjectTypes: TPgDumpObjects default [doSchemas,
doLanguages, doDomains, doTypes, doTables, doViews, doSequences,
doStoredProcs, doTriggers, doIndexes];
Remarks
Use the ObjectTypes property to specify the types of objects that are backuped by PgDump.
5.17.1.1.2.3 Options Property
Class
TPgDump
Syntax
property Options: TPgDumpOptions;
Remarks
Set the properties of Options to specify the behaviour of a TPgDump component.
Descriptions of all options are in the table below.
Descriptions of all options are in the table below.
Class
TPgDump
Syntax
property SchemaNames: string;
Remarks
Use the SchemaNames property to set the names of the schemas to dump. Table names
© 2018 Devart
Reference 754
must be separated with semicolons. If it is empty, the Backup method will dump all available
schemas.
Unit
PgDump
Syntax
TPgDumpOptions = class(TDADumpOptions);
Inheritance Hierarchy
TDADumpOptions
TPgDumpOptions
5.17.1.2.1 Members
Properties
Name Description
AddDrop (inherited from Used to add drop statements to a script before
TDADumpOptions) creating statements.
CompleteInsert (inherited from Used to explicitly specify the table fields names
when generating the INSERT SQL query. The
TDADumpOptions)
default value is False.
QuoteNames (inherited from Used for TDADump to quote all database object
TDADumpOptions) names in generated SQL statements.
© 2018 Devart
755 PostgreSQL Data Access Components
5.17.1.2.2 Properties
Published
Name Description
CompleteInsert (inherited from Used to explicitly specify the table fields names
when generating the INSERT SQL query. The
TDADumpOptions)
default value is False.
QuoteNames (inherited from Used for TDADump to quote all database object
TDADumpOptions) names in generated SQL statements.
See Also
TPgDumpOptions Class
TPgDumpOptions Class Members
Class
TPgDumpOptions
Syntax
property CreateConstraints: boolean default True;
Remarks
© 2018 Devart
Reference 756
If True (the default value), statements to create table constrains are added to the dump. If
False, tables are created without constraints.
5.17.2 Types
Types in the PgDump unit.
Types
Name Description
TPgDumpObjects Represents the set of TPgDumpObject.
Unit
PgDump
Syntax
TPgDumpObjects = set of TPgDumpObject;
5.17.3 Enumerations
Enumerations in the PgDump unit.
Enumerations
Name Description
TPgDumpMode Specifies the mode of backup performed by
TPgDump.
Unit
PgDump
© 2018 Devart
757 PostgreSQL Data Access Components
Syntax
TPgDumpMode = (dmAll, dmData, dmSchema);
Values
Value Meaning
Backup of schema objects and table data is performed. The
dmAll
default value.
dmData Backup of table data only is performed.
dmSchema Backup of schema only is performed.
Unit
PgDump
Syntax
TPgDumpObject = (doDatabase, doDomains, doIndexes, doLanguages,
doSchemas, doSequences, doStoredProcs, doTables, doTriggers,
doTypes, doViews);
Values
Value Meaning
doDatabase If set, CREATE DATABASE statement is added to the dump.
doDomains Backup of domains is performed.
doIndexes Backup of indexes is performed.
doLanguages Backup of languages is performed.
doSchemas Backup of schemas is performed.
doSequences Backup of sequences is performed.
doStoredProcs Backup of stored procedures is performed.
doTables Backup of tables is performed.
doTriggers Backup of triggers is performed.
doTypes Backup of types is performed.
doViews Backup of views is performed.
© 2018 Devart
Reference 758
5.18 PgError
This unit contains the EPgError exception class.
Classes
Name Description
EPgError Represents a PostgreSQL notice, warning, and
error messages.
Enumerations
Name Description
TPgSeverity Specifies the severity of the event occurred.
5.18.1 Classes
Classes in the PgError unit.
Classes
Name Description
EPgError Represents a PostgreSQL notice, warning, and
error messages.
Unit
PgError
Syntax
EPgError = class(EDAError);
Remarks
The EPgError object contains information that the server returns in the form of error, warning,
log, notice etc. messages.
© 2018 Devart
759 PostgreSQL Data Access Components
Inheritance Hierarchy
EDAError
EPgError
5.18.1.1.1 Members
Properties
Name Description
Includes a call stack traceback of active
CallStack procedural language functions and internally-
generated queries.
Component (inherited from
Contains the component that caused the error.
EDAError)
5.18.1.1.2 Properties
© 2018 Devart
Reference 760
Public
Name Description
Includes a call stack traceback of active
CallStack procedural language functions and internally-
generated queries.
Component (inherited from
Contains the component that caused the error.
EDAError)
See Also
EPgError Class
EPgError Class Members
Includes a call stack traceback of active procedural language functions and internally-
generated queries.
Class
EPgError
© 2018 Devart
761 PostgreSQL Data Access Components
Syntax
property CallStack: string;
Remarks
The CallStack property includes a call stack traceback of active procedural language
functions and internally-generated queries. The trace is one entry per line, most recent first.
5.18.1.1.2.2 DetailMsg Property
Class
EPgError
Syntax
property DetailMsg: string;
Remarks
The DetailMsg property holds a secondary error message.
5.18.1.1.2.3 ErrorCode Property
Class
EPgError
Syntax
property ErrorCode: string;
Remarks
The ErrorCode property holds the SQLSTATE code.
5.18.1.1.2.4 FileName Property
Used to provide the file name of the source-code location where the error was reported.
Class
EPgError
© 2018 Devart
Reference 762
Syntax
property FileName: string;
Remarks
Use the FileName property to get the file name of the source-code location.
5.18.1.1.2.5 Hint Property
Class
EPgError
Syntax
property Hint: string;
Remarks
The Hint property provides a piece of advice (potentially inappropriate) on how the problem
can be solved.
5.18.1.1.2.6 LineNumber Property
Holds the line number of the source-code location where an error has occered.
Class
EPgError
Syntax
property LineNumber: integer;
Remarks
The LineNumber property holds the line number of the source-code location.
5.18.1.1.2.7 Position Property
Class
EPgError
© 2018 Devart
763 PostgreSQL Data Access Components
Syntax
property Position: integer;
Remarks
The Position property holds the error cursor position as 1-based index in the original query
string. The position is measured in characters.
5.18.1.1.2.8 ProcedureName Property
Class
EPgError
Syntax
property ProcedureName: string;
Remarks
The ProcedureName property holds the name of the source-code routine where an error has
occurred.
5.18.1.1.2.9 Severity Property
Class
EPgError
Syntax
property Severity: TPgSeverity;
Remarks
The Severity property holds the message severity value.
5.18.2 Enumerations
Enumerations in the PgError unit.
Enumerations
© 2018 Devart
Reference 764
Name Description
TPgSeverity Specifies the severity of the event occurred.
Unit
PgError
Syntax
TPgSeverity = (sError, sFatal, sPanic, sWarning, sNotice, sDebug,
sInfo, sLog);
Values
Value Meaning
sDebug Information for developers containing internal server operations.
sError Information about a user error.
sFatal Fatal situation after which recovery isn't possible.
sInfo Useful information of insignificant type.
sLog Log of some commands execution by the server.
sNotice Notification for the user about the occurred events.
sPanic Critical error after which recovery isn't possible.
sWarning Warnings for a user that can include information about possible
problems.
5.19 PgLoader
This unit contains the implementation of the TPgLoader component.
Classes
Name Description
TPgLoader Description of TPgLoader is not available at the
moment
© 2018 Devart
765 PostgreSQL Data Access Components
5.19.1 Classes
Classes in the PgLoader unit.
Classes
Name Description
TPgLoader
Unit
PgLoader
Syntax
TPgLoader = class(TDALoader);
Remarks
TPgLoader allows to load external data into the PostgreSQL database. It uses the COPY
command to load data. To specify the name of the loading table set the TableName property.
Use the Columns property to access individual columns. Write the OnGetColumnData or
OnPutData event handler to read external data and pass it to the database. Call the Load
method to start loading data.
Inheritance Hierarchy
TDALoader
TPgLoader
5.19.1.1.1 Members
Properties
Name Description
© 2018 Devart
Reference 766
Columns (inherited from Used to add a TDAColumn object for each field
TDALoader) that will be loaded.
TableName (inherited from Used to specify the name of the table to which
TDALoader) data will be loaded.
Methods
Name Description
CreateColumns (inherited from Creates TDAColumn objects for all fields of the
table with the same name as
TDALoader)
TDALoader.TableName.
LoadFromDataSet (inherited
Loads data from the specified dataset.
from TDALoader)
Events
Name Description
OnGetColumnData (inherited
Occurs when it is needed to put column values.
from TDALoader)
© 2018 Devart
767 PostgreSQL Data Access Components
5.19.1.1.2 Properties
Public
Name Description
BufferSize Holds the size of the memory buffer used by
TPgLoader.
Columns (inherited from Used to add a TDAColumn object for each field
TDALoader) that will be loaded.
TableName (inherited from Used to specify the name of the table to which
TDALoader) data will be loaded.
Published
Name Description
Connection Used to specify a connection object and populate
the columns connection.
See Also
TPgLoader Class
TPgLoader Class Members
© 2018 Devart
Reference 768
Class
TPgLoader
Syntax
property BufferSize: integer;
Remarks
The BufferSize property contains the size of the memory buffer used by TPgLoader. When
buffer is filled, the loader sends block of data to the server.
5.19.1.1.2.2 Connection Property
Class
TPgLoader
Syntax
property Connection: TPgConnection;
Remarks
Use the Connection property to specify a connection object that will be used to connect to a
data store and to populate the columns collection.
5.19.1.1.2.3 TextMode Property
Class
TPgLoader
Syntax
property TextMode: boolean;
Remarks
Use the TextMode property to load data in the text mode.
© 2018 Devart
769 PostgreSQL Data Access Components
TPgLoader supports two load modes: text and binary. By default the binary mode is used for
a connection with 3.0 protocol. Set TextMode property to True to force text mode. In binary
mode TPgLoader may work slightly faster but some data type are not supported in this mode.
In text mode you can load data to columns with any PostgreSQL data type.
Unit
PgLoader
Syntax
TPgLoaderColumn = class(TDAColumn);
Remarks
Each TPgLoader uses TPgLoaderColumn to maintain a collection of TPgLoaderColumn
objects. TPgLoaderColumn object represents the attributes for column loading. Every
TPgLoaderColumn object corresponds to one of the table fields with the same name as its
Name property.
To create columns at design time use column editor of TPgLoader component.
Inheritance Hierarchy
TDAColumn
TPgLoaderColumn
See Also
TPgLoader
5.19.1.2.1 Members
Properties
Name Description
FieldType (inherited from Used to specify the types of values that will be
TDAColumn) loaded.
© 2018 Devart
Reference 770
Published
Name Description
FieldType (inherited from Used to specify the types of values that will be
TDAColumn) loaded.
See Also
TPgLoaderColumn Class
TPgLoaderColumn Class Members
Class
TPgLoaderColumn
Syntax
property RowTypeName: string;
© 2018 Devart
771 PostgreSQL Data Access Components
Remarks
The RowTypeName property holds the name of a composite type that corresponds to this
field.If a field is of the composite (ROW) data type, assign the name of the type to this
property. This is required for loading values of composite type in the binary mode.
5.20 PgObjects
This unit contains classes for PostgreSQL specific data types.
Classes
Name Description
TCustomPgTimeStamp A base class for the TPgDate, TPgTime, and
TPgTimeStamp classes.
© 2018 Devart
Reference 772
5.20.1 Classes
Classes in the PgObjects unit.
Classes
Name Description
TCustomPgTimeStamp A base class for the TPgDate, TPgTime, and
TPgTimeStamp classes.
© 2018 Devart
773 PostgreSQL Data Access Components
Unit
PgObjects
Syntax
TCustomPgTimeStamp = class(TSharedObject);
Remarks
The TCustomPgTmeStamp class is a base class for the TPgDate, TPgTime, and
TPgTimeStamp classes.
Inheritance Hierarchy
© 2018 Devart
Reference 774
TSharedObject
TCustomPgTimeStamp
5.20.1.1.1 Members
Properties
Name Description
AsDateTime Used to get and set the timestamp value as
TDateTime.
Methods
Name Description
© 2018 Devart
775 PostgreSQL Data Access Components
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.1.2 Properties
Public
Name Description
AsDateTime Used to get and set the timestamp value as
TDateTime.
© 2018 Devart
Reference 776
See Also
TCustomPgTimeStamp Class
TCustomPgTimeStamp Class Members
Class
TCustomPgTimeStamp
Syntax
property AsDateTime: TDateTime;
Remarks
Use the AsDateTime property to get and set the timestamp value as TDateTime.
© 2018 Devart
777 PostgreSQL Data Access Components
Class
TCustomPgTimeStamp
Syntax
property AsSQLTimeStamp: TSQLTimeStamp;
Remarks
Use the AsString property to get and set the timestamp value as TSQLTimeStamp record.
5.20.1.1.2.3 AsString Property
Class
TCustomPgTimeStamp
Syntax
property AsString: string;
Remarks
Use the AsString property to get and set the timestamp value as string.
5.20.1.1.2.4 Days Property
Class
TCustomPgTimeStamp
Syntax
property Days: integer;
Remarks
The Days property holds the date part of timestamp as a number of days since 01-01-2000.
See Also
© 2018 Devart
Reference 778
DecodeDate
EncodeDate
Class
TCustomPgTimeStamp
Syntax
property HasTimeZone: boolean;
Remarks
Use the HasTimeZone property to specify whether the timestamp object has time zone.
5.20.1.1.2.6 IsInfinity Property
Class
TCustomPgTimeStamp
Syntax
property IsInfinity: boolean;
Remarks
Use the IsInfinity property to determine if a timestamp object has +/-infinity value. The IsInfinity
is True, if timestamp value is +infinity or -infinity, and False, if the value is not infinity.
5.20.1.1.2.7 IsNegInfinity Property
Class
TCustomPgTimeStamp
Syntax
property IsNegInfinity: boolean;
Remarks
© 2018 Devart
779 PostgreSQL Data Access Components
Use the IsNegInfinity property to determine if a timestamp object has -infinity value. The
IsNegInfinity property is True, if timestamp value is -infinity.
5.20.1.1.2.8 IsPosInfinity Property
Class
TCustomPgTimeStamp
Syntax
property IsPosInfinity: boolean;
Remarks
Use the IsPosInfinity property to determine if a timestamp object has +infinity value. The
IsPosInfinity property is True, if timestamp value is +infinity.
5.20.1.1.2.9 Ticks Property
Class
TCustomPgTimeStamp
Syntax
property Ticks: int64;
Remarks
The Ticks property holds the time part of timestamp in microseconds.
See Also
DecodeTime
EncodeTime
Class
TCustomPgTimeStamp
© 2018 Devart
Reference 780
Syntax
property TimeZoneOffset: integer;
Remarks
Use the TimeZoneOffset property to specify the time zone offset of a timestamp object (in
seconds).
For values of TIMESTAMP WITH TIMEZONE read this property to get the offset of the
timestamp value from Universal Time (UTC).
The value of TimeZoneOffset is specified in seconds.
5.20.1.1.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
781 PostgreSQL Data Access Components
See Also
TCustomPgTimeStamp Class
TCustomPgTimeStamp Class Members
Class
TCustomPgTimeStamp
Syntax
procedure Assign(Source: TCustomPgTimeStamp); virtual;
Parameters
Source
Holds the TCustomPgTimeStamp object to assign a value from.
Remarks
Call the Assign property to assign a value from another TCustomPgTimeStamp object to this
object.
5.20.1.1.3.2 Compare Method
Class
TCustomPgTimeStamp
Syntax
function Compare(Value: TCustomPgTimeStamp): integer; virtual;
abstract;
Parameters
© 2018 Devart
Reference 782
Value
Holds a TCustomPgTimeStamp object to compare with.
Remarks
Call the Compare method to compare two TCustomPgTimeStamp objects.
If the current object represent date and time that is greater than Value, Compare returns a
positive number.
If the current object represent date and time that is lower than Value, Compare returns a
negative number.
If the current object equals to Value, Compare returns 0.
5.20.1.1.3.3 DecodeDate Method
Class
TCustomPgTimeStamp
Syntax
procedure DecodeDate(var Year: integer; var Month: integer; var
Day: integer);
Parameters
Year
Holds the year.
Month
Holds the month.
Day
Holds the day.
Remarks
Call the DecodeDate method to get year, month, and day from the timestamp object.
5.20.1.1.3.4 DecodeDateTime Method
Provides the value of the timestamp object as year, month, day, hour, minute, second, and
microsecond.
Class
TCustomPgTimeStamp
© 2018 Devart
783 PostgreSQL Data Access Components
Syntax
procedure DecodeDateTime(var Year: integer; var Month: integer;
var Day: integer; var Hour: integer; var Minute: integer; var
Second: integer; var Microsecond: integer);
Parameters
Year
Holds the year.
Month
Holds the month.
Day
Holds the day.
Hour
Holds the hour.
Minute
Holds the minute.
Second
Holds the second.
Microsecond
Holds the microsecond.
Remarks
Call the DecodeDateTime method to get the value of the timestamp object as year, month,
day, hour, minute, second, and microsecond.
5.20.1.1.3.5 DecodeTime Method
Provides hour, minute, second, and microsecond from the timestamp object.
Class
TCustomPgTimeStamp
Syntax
procedure DecodeTime(var Hour: integer; var Minute: integer; var
Second: integer; var Microsecond: integer);
Parameters
Hour
Holds the hour.
Minute
© 2018 Devart
Reference 784
Remarks
Call the DecodeTime method to get hour, minute, second, and microsecond from the
timestamp object.
5.20.1.1.3.6 EncodeDate Method
Class
TCustomPgTimeStamp
Syntax
procedure EncodeDate(Year: integer; Month: integer; Day: integer);
Parameters
Year
Holds the year.
Month
Holds the month.
Day
Holds the ady.
Remarks
Call the EncodeDate property to set year, month, and day in the timestamp object.
5.20.1.1.3.7 EncodeDateTime Method
Sets the value of the timestamp object as year, month, day, hour, minute, second, and
microsecond.
Class
TCustomPgTimeStamp
Syntax
procedure EncodeDateTime(Year: integer; Month: integer; Day:
© 2018 Devart
785 PostgreSQL Data Access Components
Parameters
Year
Holds the year.
Month
Holds the month.
Day
Holds the day.
Hour
Holds the hour.
Minute
Holds the minute.
Second
Holds the second.
Microsecond
Holsd the microsecond.
Remarks
Call the EncodeDateTime method to set the value of the timestamp object as year, month,
day, hour, minute, second, and microsecond.
5.20.1.1.3.8 EncodeTime Method
Class
TCustomPgTimeStamp
Syntax
procedure EncodeTime(Hour: integer; Minute: integer; Second:
integer; Microsecond: integer);
Parameters
Hour
Holds the hour.
Minute
Holds the minute.
Second
Holds the second.
© 2018 Devart
Reference 786
Microsecond
Holds the microsecond.
Remarks
Call the EncodeTime method to set hour, minute, second, and microsecond in the timestamp
object.
Unit
PgObjects
Syntax
TPgAttribute = class(TAttribute);
Remarks
The TPgAttribute class holds the description of an attribute of PostgreSQL composite type.
You can use TPgRowType.Attibutes to access individual attributes.
Inheritance Hierarchy
TAttribute
TPgAttribute
5.20.1.2.1 Members
Properties
Name Description
AttributeNo (inherited from
Returns an attribute's ordinal position in object.
TAttribute)
© 2018 Devart
787 PostgreSQL Data Access Components
DataType (inherited from Returns the type of data that was assigned to the
TAttribute) Attribute.
Length (inherited from Returns the length of the string for dtString attribute
TAttribute) and precision for dtInteger and dtFloat attribute.
Offset (inherited from TAttribute) Returns an offset of the attribute value in internal
representation.
Scale (inherited from TAttribute) Returns the scale of dtFloat and dtInteger
attributes.
Size (inherited from TAttribute) Returns the size of an attribute value in external
representation.
Unit
PgObjects
Syntax
TPgBox = class(TPgPointsArray);
Remarks
The TPgBox class is used to work with PostgreSQL BOX data type.
Inheritance Hierarchy
TSharedObject
TPgGeometric
© 2018 Devart
Reference 788
TPgPointsArray
TPgBox
5.20.1.3.1 Members
Properties
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.3.2 Properties
© 2018 Devart
789 PostgreSQL Data Access Components
Public
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
See Also
TPgBox Class
TPgBox Class Members
Class
TPgBox
Syntax
property LowerLeft: TPgPoint;
Remarks
The LowerLeft property holds the lower-left corner of the box.
5.20.1.3.2.2 UpperRight Property
Class
TPgBox
© 2018 Devart
Reference 790
Syntax
property UpperRight: TPgPoint;
Remarks
The UpperRight property holds the upper-right corner of the box.
Unit
PgObjects
Syntax
TPgCircle = class(TPgGeometric);
Remarks
The TPgCircle class is used to work with PostgreSQL CIRCLE data type.
Inheritance Hierarchy
TSharedObject
TPgGeometric
TPgCircle
5.20.1.4.1 Members
Properties
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
© 2018 Devart
791 PostgreSQL Data Access Components
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.4.2 Properties
Public
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
© 2018 Devart
Reference 792
See Also
TPgCircle Class
TPgCircle Class Members
Class
TPgCircle
Syntax
property Center: TPgPoint;
Remarks
The Center property holds the center point of the circle.
5.20.1.4.2.2 Radius Property
Class
TPgCircle
Syntax
property Radius: Double;
Remarks
The Radius property holds the radius of the circle.
Unit
PgObjects
Syntax
TPgDate = class(TCustomPgTimeStamp);
© 2018 Devart
793 PostgreSQL Data Access Components
Remarks
The TPgDate class is used to work with PostgreSQL DATE data type.
Inheritance Hierarchy
TSharedObject
TCustomPgTimeStamp
TPgDate
5.20.1.5.1 Members
Properties
Name Description
AsDateTime (inherited from Used to get and set the timestamp value as
TCustomPgTimeStamp) TDateTime.
HasTimeZone (inherited from Used to specify whether the timestamp object has
TCustomPgTimeStamp) time zone.
© 2018 Devart
Reference 794
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
DecodeDate (inherited from Provides year, month, and day from the timestamp
TCustomPgTimeStamp) object.
© 2018 Devart
795 PostgreSQL Data Access Components
EncodeTime (inherited from Sets hour, minute, second, and microsecond in the
TCustomPgTimeStamp) timestamp object.
A base class for classes that work with geometric data types.
For a list of all members of this type, see TPgGeometric members.
Unit
PgObjects
Syntax
TPgGeometric = class(TSharedObject);
Remarks
The TPgGeometric class is a class for classes that work with geometric data types.
Inheritance Hierarchy
TSharedObject
TPgGeometric
5.20.1.6.1 Members
Properties
Name Description
© 2018 Devart
Reference 796
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.6.2 Properties
Public
Name Description
AsString Used to get and set the geometric value as string.
See Also
TPgGeometric Class
TPgGeometric Class Members
© 2018 Devart
797 PostgreSQL Data Access Components
Class
TPgGeometric
Syntax
property AsString: string;
Remarks
Use the AsString property to get and set the geometric value as string.
5.20.1.6.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
See Also
TPgGeometric Class
TPgGeometric Class Members
Class
© 2018 Devart
Reference 798
TPgGeometric
Syntax
procedure Assign(Source: TPgGeometric); virtual;
Parameters
Source
Holds a TPgGeometric object to assign the value from.
Remarks
Call the Assign property to assign a value from another TPgGeometric object to this object.
Unit
PgObjects
Syntax
TPgInterval = class(TSharedObject);
Remarks
The TPgInterval class is used to work with PostgreSQL INTERVAL data type.
Inheritance Hierarchy
TSharedObject
TPgInterval
5.20.1.7.1 Members
Properties
Name Description
AsString Used to get and set the INTERVAL value as string.
© 2018 Devart
799 PostgreSQL Data Access Components
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.7.2 Properties
Public
Name Description
© 2018 Devart
Reference 800
See Also
TPgInterval Class
TPgInterval Class Members
Class
TPgInterval
Syntax
property AsString: string;
Remarks
Use the AsString property to get and set the INTERVAL value as string.
5.20.1.7.2.2 Days Property
Class
TPgInterval
Syntax
property Days: integer;
© 2018 Devart
801 PostgreSQL Data Access Components
Remarks
Use the Days property to get the days part of an interval.
5.20.1.7.2.3 MonthsFull Property
Class
TPgInterval
Syntax
property MonthsFull: integer;
Remarks
Use the MonthsFull property to get the months part of an interval.
The months part of an interval that includes months and years converted to months.
5.20.1.7.2.4 SecondsFull Property
Class
TPgInterval
Syntax
property SecondsFull: double;
Remarks
Use the SecondsFull property to get the time part of an interval represented in seconds.
5.20.1.7.3 Methods
Public
Name Description
Increments the reference count for the number of
AddRef (inherited from references dependent on the TSharedObject
object.
© 2018 Devart
Reference 802
TSharedObject)
See Also
TPgInterval Class
TPgInterval Class Members
Class
TPgInterval
Syntax
procedure Assign(Source: TPgInterval);
Parameters
Source
Holds the TPgInterval object to assign value from.
Remarks
Call the Assign method to assign a value from another TPgInterval object to this object.
© 2018 Devart
803 PostgreSQL Data Access Components
Class
TPgInterval
Syntax
function Compare(Value: TPgInterval): integer;
Parameters
Value
Holds a TPgInterval object to compare with.
Remarks
Call the Compare method to compare two TPgInterval objects.
If the current object represents an interval that is longer than Value, Compare returns a
positive number. If the current object represents an interval that is shorter than Value,
Compare returns a negative number. If the current object equals to Value, Compare returns 0.
Internally INTERVAL values are stored as months, days, and seconds. Compare supposes
that months value has more priority than days, and days has more priority than seconds.
5.20.1.7.3.3 DecodeInterval Method
Provides the value of interval as years, months, days, hours, minutes, seconds, and
microseconds.
Class
TPgInterval
Syntax
procedure DecodeInterval(var Years: integer; var Months:
integer; var Days: integer; var Hours: integer; var Minutes:
integer; var Seconds: integer; var Microseconds: integer);
Parameters
Years
Holds the years value.
Months
Holds the months value.
Days
© 2018 Devart
Reference 804
Remarks
Call the DecodeInterval method to get the value of interval as years, months, days, hours,
minutes, seconds, and microseconds.
5.20.1.7.3.4 EncodeInterval Method
Sets the value of interval as years, months, days, hours, minutes, seconds, and
microseconds.
Class
TPgInterval
Syntax
procedure EncodeInterval(Years: integer; Months: integer; Days:
integer; Hours: integer; Minutes: integer; Seconds: integer;
Microseconds: integer);
Parameters
Years
Holds the years value.
Months
Holds the months value.
Days
Holds the days value.
Hours
Holds the hours value.
Minutes
Holds the minutes value.
Seconds
Holds the seconds value.
Microseconds
© 2018 Devart
805 PostgreSQL Data Access Components
Remarks
Call the EncodeInterval method to set the value of interval as years, months, days, hours,
minutes, seconds, and microseconds.
A class for working with PostgreSQL LSEG (line segment) data type.
For a list of all members of this type, see TPgLSeg members.
Unit
PgObjects
Syntax
TPgLSeg = class(TPgPointsArray);
Remarks
The TPgLSeg class is used to work with PostgreSQL LSEG (line segment) data type.
Inheritance Hierarchy
TSharedObject
TPgGeometric
TPgPointsArray
TPgLSeg
5.20.1.8.1 Members
Properties
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
© 2018 Devart
Reference 806
TSharedObject)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.8.2 Properties
Public
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
© 2018 Devart
807 PostgreSQL Data Access Components
See Also
TPgLSeg Class
TPgLSeg Class Members
Class
TPgLSeg
Syntax
property EndPoint: TPgPoint;
Remarks
The EndPoint property holds the end point of the line segment.
5.20.1.8.2.2 StartPoint Property
Class
TPgLSeg
Syntax
property StartPoint: TPgPoint;
Remarks
The StartPoint property holds the start point of the line segment.
Unit
PgObjects
Syntax
TPgPath = class(TPgPointsArray);
© 2018 Devart
Reference 808
Remarks
The TPgPath class is used to work with PostgreSQL PATH data type.
Inheritance Hierarchy
TSharedObject
TPgGeometric
TPgPointsArray
TPgPath
5.20.1.9.1 Members
Properties
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
809 PostgreSQL Data Access Components
TPgGeometric)
5.20.1.9.2 Properties
Public
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
See Also
TPgPath Class
TPgPath Class Members
Class
TPgPath
© 2018 Devart
Reference 810
Syntax
property Count: integer;
Remarks
The Count property holds the count of points in the path.
5.20.1.9.2.2 IsClosedPath Property
Class
TPgPath
Syntax
property IsClosedPath: boolean;
Remarks
If the IsClosedPath property is True, the path is closed. This assumes that the last point in the
path is connected with the fist point by a line.
If False, the path is not closed.
5.20.1.9.2.3 Points Property
Class
TPgPath
Syntax
property Points: array of TPgPoint;
Remarks
Use the Points property to access a point in the path by its index.
Unit
© 2018 Devart
811 PostgreSQL Data Access Components
PgObjects
Syntax
TPgPoint = class(TPgGeometric);
Remarks
The TPgPoint class is used to work with PostgreSQL POINT data type.
Inheritance Hierarchy
TSharedObject
TPgGeometric
TPgPoint
5.20.1.10.1 Members
Properties
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
Reference 812
5.20.1.10.2 Properties
Public
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
See Also
TPgPoint Class
TPgPoint Class Members
5.20.1.10.2.1 X Property
Class
TPgPoint
Syntax
property X: Double;
© 2018 Devart
813 PostgreSQL Data Access Components
Remarks
The X property holds the X coordinate of the point.
5.20.1.10.2.2 Y Property
Class
TPgPoint
Syntax
property Y: Double;
Remarks
The Y property holds the Y coordinate of the point.
5.20.1.10.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
See Also
TPgPoint Class
TPgPoint Class Members
© 2018 Devart
Reference 814
Class
TPgPoint
Syntax
procedure Assign(Source: TPgGeometric); override;
Parameters
Source
Holds the TPgPoint object to assign value from.
Remarks
Call the Assign method to assign a value from another TPgPoint object to this object.
Unit
PgObjects
Syntax
TPgPointsArray = class(TPgGeometric);
Remarks
The TPgPointsArray is a base class for most classes that work with geometric data types.
Inheritance Hierarchy
TSharedObject
TPgGeometric
TPgPointsArray
5.20.1.11.1 Members
Properties
© 2018 Devart
815 PostgreSQL Data Access Components
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Unit
PgObjects
Syntax
TPgPolygon = class(TPgPointsArray);
Remarks
The TPgPolygon class is used to work with PostgreSQL POLYGON data type.
Inheritance Hierarchy
© 2018 Devart
Reference 816
TSharedObject
TPgGeometric
TPgPointsArray
TPgPolygon
5.20.1.12.1 Members
Properties
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
817 PostgreSQL Data Access Components
5.20.1.12.2 Properties
Public
Name Description
AsString (inherited from
Used to get and set the geometric value as string.
TPgGeometric)
See Also
TPgPolygon Class
TPgPolygon Class Members
Class
TPgPolygon
Syntax
property Count: integer;
Remarks
The Count property holds the count of points in the polygon.
© 2018 Devart
Reference 818
Class
TPgPolygon
Syntax
property Points: array of TPgPoint;
Remarks
Use the Points property to access a point in the polygon by its index.
Unit
PgObjects
Syntax
TPgRefCursor = class(TPgCursor);
Remarks
The TPgRefCursor class is used to work with REFCURSOR values. An instance of
TPgRefCursor holds the cursor name that is returned, for exapmle, from a stored procedure,
and can be used to fetch data from the cursor. Assign an instance of the TPgRefCursor class
to the Cursor property of TPgQuery and call the TPgQuery.Open method to fetch data from
the cursor.
Note: all operations with REFCURSOR require an active transaction.
Inheritance Hierarchy
TSharedObject
TCRCursor
TPgCursor
TPgRefCursor
© 2018 Devart
819 PostgreSQL Data Access Components
5.20.1.13.1 Members
Properties
Name Description
CursorName Used to get the name of a cursor.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.13.2 Properties
Public
Name Description
CursorName Used to get the name of a cursor.
© 2018 Devart
Reference 820
TSharedObject)
See Also
TPgRefCursor Class
TPgRefCursor Class Members
Class
TPgRefCursor
Syntax
property CursorName: string;
Remarks
Use the CursorName property to get the name of a cursor.
Unit
PgObjects
Syntax
TPgRow = class(TDBObject);
Remarks
The TPgRow class is used to work with PostgreSQL composite (ROW) data types.
Inheritance Hierarchy
© 2018 Devart
821 PostgreSQL Data Access Components
TSharedObject
TDBObject
TPgRow
5.20.1.14.1 Members
Properties
Name Description
AsString Used to get and set the row value as string.
© 2018 Devart
Reference 822
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
5.20.1.14.2 Properties
Public
Name Description
AsString Used to get and set the row value as string.
© 2018 Devart
823 PostgreSQL Data Access Components
See Also
© 2018 Devart
Reference 824
TPgRow Class
TPgRow Class Members
Class
TPgRow
Syntax
property AsString: string;
Remarks
Use the AsString property to get and set the row value as string.
5.20.1.14.2.2 AttrAsPgBox Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgBox[const Name: string]: TPgBox;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgBox property to get a reference to a TPgBox object for an attribute of
ftPgBox type.
5.20.1.14.2.3 AttrAsPgCircle Property(Indexer)
Class
TPgRow
Syntax
© 2018 Devart
825 PostgreSQL Data Access Components
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgCircle property to get a reference to a TPgCircle object for an attribute of
ftPgCircle type.
5.20.1.14.2.4 AttrAsPgCursor Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgCursor[const Name: string]: TPgCursor;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgCursor property to get a reference to a TPgCursor object for an attribute of
ftPgCursor type.
5.20.1.14.2.5 AttrAsPgDate Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgDate[const Name: string]: TPgDate;
Parameters
Name
Holds the name of an attribute.
© 2018 Devart
Reference 826
Remarks
Use the AttrAsPgDate property to get a reference to a TPgDate object for an attribute of
ftPgDate type.
5.20.1.14.2.6 AttrAsPgInterval Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgInterval[const Name: string]: TPgInterval;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgInterval property to get a reference to a TPgInterval object for an attribute of
ftPgInterval type.
5.20.1.14.2.7 AttrAsPgLargeObject Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgLargeObject[const Name: string]:
TPgSQLLargeObject;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgLargeObject property to get a reference to a TPgLargeObject object for an
attribute of ftPgLargeObject type.
© 2018 Devart
827 PostgreSQL Data Access Components
Class
TPgRow
Syntax
property AttrAsPgLSeg[const Name: string]: TPgLSeg;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgLSeg property to get a reference to a TPgLSeg object for an attribute of
ftPgLSeg type.
5.20.1.14.2.9 AttrAsPgPath Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgPath[const Name: string]: TPgPath;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgPath property to get a reference to a TPgPath object for an attribute of
ftPgPath type.
5.20.1.14.2.10 AttrAsPgPoint Property(Indexer)
Class
TPgRow
© 2018 Devart
Reference 828
Syntax
property AttrAsPgPoint[const Name: string]: TPgPoint;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgPoint property to get a reference to a TPgPoint object for an attribute of
ftPgPoint type.
5.20.1.14.2.11 AttrAsPgPolygon Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgPolygon[const Name: string]: TPgPolygon;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgPolygon property to get a reference to a TPgPolygon object for an attribute of
ftPgPolygon type.
5.20.1.14.2.12 AttrAsPgRow Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgRow[const Name: string]: TPgRow;
Parameters
Name
© 2018 Devart
829 PostgreSQL Data Access Components
Remarks
Use the AttrAsPgRow property to get a reference to a TPgRow object for an attribute of
composite type.
5.20.1.14.2.13 AttrAsPgTime Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgTime[const Name: string]: TPgTime;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgTime property to get a reference to a TPgTime object for an attribute of
ftPgTime type.
5.20.1.14.2.14 AttrAsPgTimeStamp Property(Indexer)
Class
TPgRow
Syntax
property AttrAsPgTimeStamp[const Name: string]: TPgTimeStamp;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrAsPgTimeStamp property to get a reference to a TPgTimeStamp object for an
attribute of ftPgTimeStamp type.
© 2018 Devart
Reference 830
Class
TPgRow
Syntax
property AttrIsNull[const Name: string]: boolean;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrIsNull property to find out if an attribute is NULL, or to set an attribute value to
NULL.
5.20.1.14.2.16 AttrValue Property(Indexer)
Class
TPgRow
Syntax
property AttrValue[const Name: string]: variant;
Parameters
Name
Holds the name of an attribute.
Remarks
Use the AttrValue property to get or set the value of an attribute.
5.20.1.14.2.17 Row Type Property
Class
TPgRow
© 2018 Devart
831 PostgreSQL Data Access Components
Syntax
property RowType: TPgRowType;
Remarks
The RowType property holds the reference to a TPgRowType object containing information
about corresponding composite type. This property must be set before you can read or write
values to attributes.
5.20.1.14.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
See Also
TPgRow Class
TPgRow Class Members
Class
TPgRow
Syntax
procedure Assign(Source: TPgRow);
© 2018 Devart
Reference 832
Parameters
Source
Holds the TPgRow object to assign a value from.
Remarks
Call the Assign method to assign a value from another TPgRow object to this object.
Unit
PgObjects
Syntax
TPgRowType = class(TPgType);
Remarks
The TPgRowType class holds the description of a PostgreSQL composite (ROW) type. Use
the GetRowType method of TPgConnection to get an instance of a TPgRowType object.
Inheritance Hierarchy
TSharedObject
TObjectType
TPgType
TPgRowType
5.20.1.15.1 Members
Methods
Name Description
Describe Overloaded. Provides information about a
composite type from the database.
© 2018 Devart
833 PostgreSQL Data Access Components
5.20.1.15.2 Methods
See Also
TPgRowType Class
TPgRowType Class Members
Class
TPgRowType
Overload List
Name Description
Describe Provides information about a composite
type from the database by the OID.
Describe Provides information about a composite
type from the database by the name.
Provides information about a composite type from the database by the OID.
Unit
Syntax
Remarks
Call the Describe method to get information about a composite type from the database by the
OID.
Provides information about a composite type from the database by the name.
Unit
Syntax
Remarks
© 2018 Devart
Reference 834
Call the Describe method to get information about a composite type from the database by the
name.
Unit
PgObjects
Syntax
TPgSQLLargeObject = class(TCompressedBlob);
Remarks
The TPgSQLLargeObject class is used to work with PostgreSQL large objects. An instance
of TPgSQLLargeObject holds an OID of large object and can be used for operations with this
large object.
Note: all operations with large objects require an active transaction.
Inheritance Hierarchy
TSharedObject
TBlob
TCompressedBlob
TPgSQLLargeObject
5.20.1.16.1 Members
Properties
Name Description
AsString (inherited from TBlob) Used to manipulate BLOB value as string.
© 2018 Devart
835 PostgreSQL Data Access Components
IsUnicode (inherited from TBlob) Gives choice of making TBlob store and process
data in Unicode format or not.
Size (inherited from TBlob) Used to learn the size of the TBlob value in bytes.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Assign (inherited from TBlob) Sets BLOB value from another TBlob object.
Clear (inherited from TBlob) Deletes the current value in TBlob object.
© 2018 Devart
Reference 836
Read (inherited from TBlob) Acquires a raw sequence of bytes from the data
stored in TBlob.
Truncate (inherited from TBlob) Sets new TBlob size and discards all data over it.
Write (inherited from TBlob) Stores a raw sequence of bytes into a TBlob
object.
© 2018 Devart
837 PostgreSQL Data Access Components
Public
Name Description
AsString (inherited from TBlob) Used to manipulate BLOB value as string.
IsUnicode (inherited from TBlob) Gives choice of making TBlob store and process
data in Unicode format or not.
Size (inherited from TBlob) Used to learn the size of the TBlob value in bytes.
See Also
TPgSQLLargeObject Class
TPgSQLLargeObject Class Members
Used to specify whether the content of large object should be stored in memory buffer on the
client.
© 2018 Devart
Reference 838
Class
TPgSQLLargeObject
Syntax
property Cached: boolean;
Remarks
Use the Cached property to specify whether the content of large object should be stored in
memory buffer on the client.
By default the whole content of large object is stored in the memory buffer on the client. Set
Cached to False if you want to reduce memory usage in your application when working with
very large object. When Cached is False, the Read and Write methods read/write data
directly from/to the database.
5.20.1.16.2.2 Connection Property
Used to specify a connection object that is used to perform operations with large object.
Class
TPgSQLLargeObject
Syntax
property Connection: TPgSQLConnection;
Remarks
Use the Connection property to specify a connection object that is used to perform operations
with large object.
5.20.1.16.2.3 OID Property
Class
TPgSQLLargeObject
Syntax
property OID: OID;
Remarks
© 2018 Devart
839 PostgreSQL Data Access Components
Read the OID property to get the OID of the object created by the CreateObject method. Set
the OID property to work with an existing large object.
5.20.1.16.3 Methods
Public
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
Assign (inherited from TBlob) Sets BLOB value from another TBlob object.
Clear (inherited from TBlob) Deletes the current value in TBlob object.
Read (inherited from TBlob) Acquires a raw sequence of bytes from the data
stored in TBlob.
© 2018 Devart
Reference 840
TSharedObject)
Truncate (inherited from TBlob) Sets new TBlob size and discards all data over it.
Write (inherited from TBlob) Stores a raw sequence of bytes into a TBlob
object.
See Also
TPgSQLLargeObject Class
TPgSQLLargeObject Class Members
Closes the large object that was previously opened by the OpenObject method.
Class
TPgSQLLargeObject
Syntax
procedure CloseObject;
Remarks
Call the CloseObject property to close the large object that was previously opened by the
OpenObject method.
© 2018 Devart
841 PostgreSQL Data Access Components
Class
TPgSQLLargeObject
Syntax
procedure CreateObject;
Remarks
Call the CreateObject method to create a new large object database.
5.20.1.16.3.3 OpenObject Method
Class
TPgSQLLargeObject
Syntax
procedure OpenObject;
Remarks
Call the OpenObject method to open the large object specified by the OID property.
5.20.1.16.3.4 ReadBlob Method
Class
TPgSQLLargeObject
Syntax
procedure ReadBlob; overload;procedure ReadBlob(var SharedPiece:
PPieceHeader); overload;
Remarks
Call the ReadBlob method to get the content of large object from the database. When reading
such properties as AsString or AsWideString, this method is called automatically.
© 2018 Devart
Reference 842
Deletes the large object specified by the OID property from the database.
Class
TPgSQLLargeObject
Syntax
procedure UnlinkObject;
Remarks
Call the UnlinkObject method to delete the large object specified by the OID property from the
database.
5.20.1.16.3.6 WriteBlob Method
Class
TPgSQLLargeObject
Syntax
procedure WriteBlob;
Remarks
Call the WriteBlob method to write the content of the large object to the database.
When the Cached property is set to True, call WriteLob to write the cached content of the
large object to the database.
A class for working with PostgreSQL TIME and TIME WITH TIMEZONE data type.
For a list of all members of this type, see TPgTime members.
Unit
PgObjects
Syntax
TPgTime = class(TCustomPgTimeStamp);
© 2018 Devart
843 PostgreSQL Data Access Components
Remarks
The TPgTime class is used to work with PostgreSQL TIME and TIME WITH TIMEZONE data
type.
Inheritance Hierarchy
TSharedObject
TCustomPgTimeStamp
TPgTime
5.20.1.17.1 Members
Properties
Name Description
AsDateTime (inherited from Used to get and set the timestamp value as
TCustomPgTimeStamp) TDateTime.
HasTimeZone (inherited from Used to specify whether the timestamp object has
TCustomPgTimeStamp) time zone.
© 2018 Devart
Reference 844
TCustomPgTimeStamp)
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
DecodeDate (inherited from Provides year, month, and day from the timestamp
TCustomPgTimeStamp) object.
© 2018 Devart
845 PostgreSQL Data Access Components
TCustomPgTimeStamp)
EncodeTime (inherited from Sets hour, minute, second, and microsecond in the
TCustomPgTimeStamp) timestamp object.
5.20.1.17.2 Properties
Public
Name Description
AsDateTime (inherited from Used to get and set the timestamp value as
TCustomPgTimeStamp) TDateTime.
© 2018 Devart
Reference 846
HasTimeZone (inherited from Used to specify whether the timestamp object has
TCustomPgTimeStamp) time zone.
See Also
TPgTime Class
TPgTime Class Members
Class
TPgTime
Syntax
property TimeZoneOffset: integer;
Remarks
© 2018 Devart
847 PostgreSQL Data Access Components
Use the TimeZoneOffset property to get or set the time zone offset (in seconds).
For values of TIME WITH TIMEZONE use this property to get or set offset of time value from
Universal Time (UTC).
Value of TimeZoneOffset is in seconds.
A class for working with PostgreSQL TIMESTAMP and TIMESTAMP WITH TIMEZONE data
types.
For a list of all members of this type, see TPgTimeStamp members.
Unit
PgObjects
Syntax
TPgTimeStamp = class(TCustomPgTimeStamp);
Remarks
The TPgTimeStamp class is used to work with PostgreSQL TIMESTAMP and TIMESTAMP
WITH TIMEZONE data types.
Inheritance Hierarchy
TSharedObject
TCustomPgTimeStamp
TPgTimeStamp
5.20.1.18.1 Members
Properties
Name Description
AsDateTime (inherited from Used to get and set the timestamp value as
TCustomPgTimeStamp) TDateTime.
© 2018 Devart
Reference 848
HasTimeZone (inherited from Used to specify whether the timestamp object has
TCustomPgTimeStamp) time zone.
Methods
Name Description
AddRef (inherited from Increments the reference count for the number of
references dependent on the TSharedObject
TSharedObject)
object.
© 2018 Devart
849 PostgreSQL Data Access Components
DecodeDate (inherited from Provides year, month, and day from the timestamp
TCustomPgTimeStamp) object.
EncodeTime (inherited from Sets hour, minute, second, and microsecond in the
TCustomPgTimeStamp) timestamp object.
5.21 PgScript
This unit contains the implementation of the TPgScript component.
Classes
Name Description
© 2018 Devart
Reference 850
5.21.1 Classes
Classes in the PgScript unit.
Classes
Name Description
TPgScript Executes sequences of SQL statements.
Unit
PgScript
Syntax
TPgScript = class(TDAScript);
Inheritance Hierarchy
TDAScript
TPgScript
5.21.1.1.1 Members
Properties
Name Description
Connection (inherited from Used to specify the connection in which the script
TDAScript) will be executed.
DataSet (inherited from Refers to a dataset that holds the result set of
query execution.
© 2018 Devart
851 PostgreSQL Data Access Components
TDAScript)
Debug (inherited from Used to display the script execution and all its
TDAScript) parameter values.
Delimiter (inherited from Used to set the delimiter string that separates
TDAScript) script statements.
EndLine (inherited from Used to get the current statement last line number
TDAScript) in a script.
EndOffset (inherited from Used to get the offset in the last line of the current
TDAScript) statement.
EndPos (inherited from Used to get the end position of the current
TDAScript) statement.
Macros (inherited from Used to change SQL script text in design- or run-
TDAScript) time easily.
StartLine (inherited from Used to get the current statement start line number
TDAScript) in a script.
StartOffset (inherited from Used to get the offset in the first line of the current
TDAScript) statement.
StartPos (inherited from Used to get the start position of the current
TDAScript) statement in a script.
© 2018 Devart
Reference 852
Methods
Name Description
BreakExec (inherited from
Stops script execution.
TDAScript)
ErrorOffset (inherited from Used to get the offset of the statement if the
TDAScript) Execute method raised an exception.
ExecuteNext (inherited from Executes the next statement in the script and then
TDAScript) stops.
Events
Name Description
AfterExecute (inherited from
Occurs after a SQL script execution.
TDAScript)
© 2018 Devart
853 PostgreSQL Data Access Components
5.22 PgSQLMonitor
This unit contains the implementation of the TPgSQLMonitor component.
Classes
Name Description
TPgSQLMonitor This component serves for monitoring dynamic
SQL execution in PgDAC-based applications.
5.22.1 Classes
Classes in the PgSQLMonitor unit.
Classes
Name Description
TPgSQLMonitor This component serves for monitoring dynamic
SQL execution in PgDAC-based applications.
This component serves for monitoring dynamic SQL execution in PgDAC-based applications.
For a list of all members of this type, see TPgSQLMonitor members.
Unit
PgSQLMonitor
Syntax
TPgSQLMonitor = class(TCustomDASQLMonitor);
Remarks
Use TPgSQLMonitor to monitor dynamic SQL execution in PgDAC-based applications.
TPgSQLMonitor provides two ways of displaying debug information: with dialog window,
DBMonitor or Borland SQL Monitor. Furthermore to receive debug information the
TCustomDASQLMonitor.OnSQL event can be used. Also it is possible to use all these ways
© 2018 Devart
Reference 854
at the same time, though an application may have only one TPgSQLMonitor object. If an
application has no TPgSQLMonitor instance, the Debug window is available to display SQL
statements to be sent.
Inheritance Hierarchy
TCustomDASQLMonitor
TPgSQLMonitor
See Also
TCustomDADataSet.Debug
TCustomDASQL.Debug
DBMonitor
5.22.1.1.1 Members
Properties
Name Description
Active (inherited from
Used to activate monitoring of SQL.
TCustomDASQLMonitor)
DBMonitorOptions (inherited
Used to set options for dbMonitor.
from TCustomDASQLMonitor)
Events
Name Description
© 2018 Devart
855 PostgreSQL Data Access Components
TCustomDASQLMonitor)
5.23 VirtualDataSet
5.23.1 Classes
Classes in the VirtualDataSet unit.
Classes
Name Description
TCustomVirtualDataSet A base class for representation of arbitrary data in
tabular form.
Unit
VirtualDataSet
Syntax
TCustomVirtualDataSet = class(TMemDataSet);
Inheritance Hierarchy
TMemDataSet
TCustomVirtualDataSet
5.23.1.1.1 Members
Properties
Name Description
© 2018 Devart
Reference 856
TMemDataSet)
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
ApplyRange (inherited from
Applies a range to the dataset.
TMemDataSet)
© 2018 Devart
857 PostgreSQL Data Access Components
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 858
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
OnUpdateError (inherited from Occurs when an exception is generated while
TMemDataSet) cached updates are applied to a database.
© 2018 Devart
859 PostgreSQL Data Access Components
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
Unit
VirtualDataSet
Syntax
TVirtualDataSet = class(TCustomVirtualDataSet);
Inheritance Hierarchy
TMemDataSet
TCustomVirtualDataSet
TVirtualDataSet
5.23.1.2.1 Members
Properties
Name Description
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
© 2018 Devart
Reference 860
TMemDataSet)
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
ApplyRange (inherited from
Applies a range to the dataset.
TMemDataSet)
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
© 2018 Devart
861 PostgreSQL Data Access Components
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
© 2018 Devart
Reference 862
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
OnUpdateError (inherited from Occurs when an exception is generated while
TMemDataSet) cached updates are applied to a database.
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
5.23.2 Types
Types in the VirtualDataSet unit.
Types
Name Description
© 2018 Devart
863 PostgreSQL Data Access Components
Unit
VirtualDataSet
Syntax
TOnDeleteRecordEvent = procedure (Sender: TObject; RecNo:
Integer) of object;
Parameters
Sender
An object that raised the event.
RecNo
Number of the record being deleted.
5.23.2.2 TOnGetFieldValueEvent Procedure Reference
Unit
VirtualDataSet
Syntax
TOnGetFieldValueEvent = procedure (Sender: TObject; Field: TField;
RecNo: Integer; out Value: Variant) of object;
© 2018 Devart
Reference 864
Parameters
Sender
An object that raised the event.
Field
The field, which data has to be returned.
RecNo
The number of the record, which data has to be returned.
Value
Requested field value.
5.23.2.3 TOnGetRecordCountEvent Procedure Reference
Unit
VirtualDataSet
Syntax
TOnGetRecordCountEvent = procedure (Sender: TObject; out Count:
Integer) of object;
Parameters
Sender
An object that raised the event.
Count
The number of records that the virtual dataset will contain.
5.23.2.4 TOnModifyRecordEvent Procedure Reference
Unit
VirtualDataSet
Syntax
TOnModifyRecordEvent = procedure (Sender: TObject; var RecNo:
Integer) of object;
Parameters
Sender
An object that raised the event.
© 2018 Devart
865 PostgreSQL Data Access Components
RecNo
Number of the record being inserted or modified.
5.24 VirtualTable
5.24.1 Classes
Classes in the VirtualTable unit.
Classes
Name Description
Dataset that stores data in memory. This
TVirtualTable component is placed on the Data Access page of
the Component palette.
5.24.1.1 TVirtualTable Class
Dataset that stores data in memory. This component is placed on the Data Access page of
the Component palette.
For a list of all members of this type, see TVirtualTable members.
Unit
VirtualTable
Syntax
TVirtualTable = class(TMemDataSet);
Inheritance Hierarchy
TMemDataSet
TVirtualTable
5.24.1.1.1 Members
Properties
Name Description
CachedUpdates (inherited from Used to enable or disable the use of cached
TMemDataSet) updates for a dataset.
© 2018 Devart
Reference 866
IndexFieldNames (inherited from Used to get or set the list of fields on which the
TMemDataSet) recordset is sorted.
KeyExclusive (inherited from Specifies the upper and lower boundaries for a
TMemDataSet) range.
UpdateRecordTypes (inherited Used to indicate the update status for the current
from TMemDataSet) record when cached updates are enabled.
UpdatesPending (inherited from Used to check the status of the cached updates
TMemDataSet) buffer.
Methods
Name Description
ApplyRange (inherited from
Applies a range to the dataset.
TMemDataSet)
© 2018 Devart
867 PostgreSQL Data Access Components
CancelUpdates (inherited from Clears all pending cached updates from cache
TMemDataSet) and restores dataset in its prior state.
EditRangeEnd (inherited from Enables changing the ending value for an existing
TMemDataSet) range.
EditRangeStart (inherited from Enables changing the starting value for an existing
TMemDataSet) range.
© 2018 Devart
Reference 868
RevertRecord (inherited from Cancels changes made to the current record when
TMemDataSet) cached updates are enabled.
SetRange (inherited from Sets the starting and ending values of a range,
TMemDataSet) and applies it.
UpdateResult (inherited from Reads the status of the latest call to the
ApplyUpdates method while cached updates are
TMemDataSet)
enabled.
UpdateStatus (inherited from Indicates the current update status for the dataset
TMemDataSet) when cached updates are enabled.
Events
Name Description
OnUpdateError (inherited from Occurs when an exception is generated while
TMemDataSet) cached updates are applied to a database.
OnUpdateRecord (inherited from Occurs when a single update component can not
TMemDataSet) handle the updates.
© 2018 Devart