1 {*********************************************************}
3 { Zeos Database Objects }
4 { Abstract Table component }
6 { Originally written by Sergey Seroukhov }
8 {*********************************************************}
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
13 { License Agreement: }
15 { This library is distributed in the hope that it will be }
16 { useful, but WITHOUT ANY WARRANTY; without even the }
17 { implied warranty of MERCHANTABILITY or FITNESS FOR }
18 { A PARTICULAR PURPOSE. See the GNU Lesser General }
19 { Public License for more details. }
21 { The source code of the ZEOS Libraries and packages are }
22 { distributed under the Library GNU General Public }
23 { License (see the file COPYING / COPYING.ZEOS) }
24 { with the following modification: }
25 { As a special exception, the copyright holders of this }
26 { library give you permission to link this library with }
27 { independent modules to produce an executable, }
28 { regardless of the license terms of these independent }
29 { modules, and to copy and distribute the resulting }
30 { executable under terms of your choice, provided that }
31 { you also meet, for each linked independent module, }
32 { the terms and conditions of the license of that module. }
33 { An independent module is a module which is not derived }
34 { from or based on this library. If you modify this }
35 { library, you may extend this exception to your version }
36 { of the library, but you are not obligated to do so. }
37 { If you do not wish to do so, delete this exception }
38 { statement from your version. }
41 { The project web site is located on: }
42 { http://zeos.firmos.at (FORUM) }
43 { http://sourceforge.net/p/zeoslib/tickets/ (BUGTRACKER)}
44 { svn://svn.code.sf.net/p/zeoslib/code-0/trunk (SVN) }
46 { http://www.sourceforge.net/projects/zeoslib. }
49 { Zeos Development Group. }
50 {********************************************************@}
59 SysUtils, Classes, {$IFDEF MSEgui}mclasses,{$ENDIF}
65 Abstract dataset component which works with one specified table.
67 TZAbstractTable = class(TZAbstractDataset)
72 function GetExists: Boolean;
73 procedure SetTableName(const Value: string);
76 {$IFDEF WITH_IPROVIDER}
77 function PSIsSQLBased: Boolean; override;
78 {$IFDEF WITH_IPROVIDERWIDE}
79 function PSGetTableNameW: WideString; override;
81 function PSGetTableName: string; override;
83 procedure PSSetCommandText(const ACommandText: string); override;
87 property Exists: Boolean read GetExists;
88 property TableName: string read FTableName write SetTableName;
97 Checks if a table with the corresponding name exists in the database.
98 @return <code>True</code> if the the table exists.
100 function TZAbstractTable.GetExists: Boolean;
102 TableList: TStringList;
104 TableList := TStringList.Create;
107 Connection.GetTableNames(TableName, TableList);
108 TableList.CaseSensitive := False;
109 Result := (TableList.IndexOf(TableName) >= 0); // look for an exact match
116 Sets a new table name and generates a related SQL statement.
117 @param Value a new name of table.
119 procedure TZAbstractTable.SetTableName(const Value: string);
121 if FTableName <> Value then
125 SQL.Text := Format('SELECT * FROM %s', [FTableName])
130 {$IFDEF WITH_IPROVIDER}
133 Checks if dataset can execute SQL queries?
134 @returns <code>True</code> if the query can execute SQL.
136 function TZAbstractTable.PSIsSQLBased: Boolean;
142 Gets the name of the table.
143 @returns the name of this table.
145 {$IFDEF WITH_IPROVIDERWIDE}
146 function TZAbstractTable.PSGetTableNameW: WideString;
148 function TZAbstractTable.PSGetTableName: string;
155 Assignes a new name for this table.
156 @param ACommandText a new name for this table.
158 procedure TZAbstractTable.PSSetCommandText(const ACommandText: string);
160 TableName := ACommandText;