00001 {*********************************************************}
00002 { }
00003 { Zeos Database Objects }
00004 { Component Property Editors }
00005 { }
00006 { Originally written by Sergey Seroukhov }
00007 { }
00008 {*********************************************************}
00009
00010 {@********************************************************}
00011 { Copyright (c) 1999-2006 Zeos Development Group }
00012 { }
00013 { License Agreement: }
00014 { }
00015 { This library is distributed in the hope that it will be }
00016 { useful, but WITHOUT ANY WARRANTY; without even the }
00017 { implied warranty of MERCHANTABILITY or FITNESS FOR }
00018 { A PARTICULAR PURPOSE. See the GNU Lesser General }
00019 { Public License for more details. }
00020 { }
00021 { The source code of the ZEOS Libraries and packages are }
00022 { distributed under the Library GNU General Public }
00023 { License (see the file COPYING / COPYING.ZEOS) }
00024 { with the following modification: }
00025 { As a special exception, the copyright holders of this }
00026 { library give you permission to link this library with }
00027 { independent modules to produce an executable, }
00028 { regardless of the license terms of these independent }
00029 { modules, and to copy and distribute the resulting }
00030 { executable under terms of your choice, provided that }
00031 { you also meet, for each linked independent module, }
00032 { the terms and conditions of the license of that module. }
00033 { An independent module is a module which is not derived }
00034 { from or based on this library. If you modify this }
00035 { library, you may extend this exception to your version }
00036 { of the library, but you are not obligated to do so. }
00037 { If you do not wish to do so, delete this exception }
00038 { statement from your version. }
00039 { }
00040 { }
00041 { The project web site is located on: }
00042 { http:
00043 { http:
00044 { svn:
00045 { }
00046 { http:
00047 { http:
00048 { }
00049 { }
00050 { }
00051 { Zeos Development Group. }
00052 {********************************************************@}
00053
00054 unit ZPropertyEditor;
00055
00056 interface
00057
00058 {$I ZComponent.inc}
00059
00060 {$IFDEF WITH_PROPERTY_EDITOR}
00061
00062 uses
00063 {$IFNDEF VER130BELOW}
00064 Types,
00065 {$ENDIF}
00066 Classes, ZClasses, ZCompatibility, ZDbcIntfs,
00067 {$IFNDEF VER130BELOW}
00068 DesignIntf, DesignEditors;
00069 {$ELSE}
00070 {$IFDEF FPC}
00071 PropEdits;
00072 {$ELSE}
00073 DsgnIntf;
00074 {$ENDIF}
00075 {$ENDIF}
00076
00077 type
00078
00079 {** Implements the basic methods of the property editor. }
00080 TZStringProperty = class(TStringProperty)
00081 public
00082 function GetAttributes: TPropertyAttributes; override;
00083 procedure GetValueList(List: TStrings); virtual; abstract;
00084 procedure GetValues(Proc: TGetStrProc); override;
00085 end;
00086
00087 {** Shows all Fields received from FieldDefs. }
00088 TZDataFieldPropertyEditor = class(TZStringProperty)
00089 public
00090 procedure GetValueList(List: TStrings); override;
00091 end;
00092
00093 {** Shows all Fields received from IndexDefs - not used yet. }
00094 TZIndexFieldPropertyEditor = class(TZStringProperty)
00095 public
00096 procedure GetValueList(List: TStrings); override;
00097 end;
00098
00099 {** Shows all Fields received from the MasterSource's DataSet.FieldDefs. }
00100 TZMasterFieldPropertyEditor = class(TZStringProperty)
00101 public
00102 procedure GetValueList(List: TStrings); override;
00103 end;
00104
00105 {** Shows all Tables received from Connection.IZDatabaseMetadata. }
00106 TZTableNamePropertyEditor = class(TZStringProperty)
00107 public
00108 procedure GetValueList(List: TStrings); override;
00109 end;
00110
00111 {** Shows all Procedures received from Connection.IZDatabaseMetadata. }
00112 TZProcedureNamePropertyEditor = class(TZStringProperty)
00113 public
00114 procedure GetValueList(List: TStrings); override;
00115 end;
00116
00117 {** Shows all Sequences received from Connection.IZDatabaseMetadata. }
00118 TZSequenceNamePropertyEditor = class(TZStringProperty)
00119 public
00120 procedure GetValueList(List: TStrings); override;
00121 end;
00122
00123 {** Implements a property editor for ZConnection.Protocol property. }
00124 TZProtocolPropertyEditor = class(TZStringProperty)
00125 public
00126 function GetValue: string; override;
00127 procedure GetValueList(List: TStrings); override;
00128 procedure SetValue(const Value: string); override;
00129 end;
00130
00131 {** Implements a property editor for ZConnection.Database property. }
00132 TZDatabasePropertyEditor = class(TZStringProperty)
00133 public
00134 function GetAttributes: TPropertyAttributes; override;
00135 function GetValue: string; override;
00136 procedure Edit; override;
00137 procedure GetValueList(List: TStrings); override;
00138 procedure SetValue(const Value: string); override;
00139 end;
00140
00141 {** Implements a property editor for ZConnection.Catalog property. }
00142 TZCatalogPropertyEditor = class(TZStringProperty)
00143 public
00144 function GetValue: string; override;
00145 procedure GetValueList(List: TStrings); override;
00146 procedure SetValue(const Value: string); override;
00147 end;
00148
00149 {$IFDEF USE_METADATA}
00150 {** Shows all Catalogs received from Connection.IZDatabaseMetadata. }
00151 TZCatalogProperty = class(TZStringProperty)
00152 public
00153 procedure GetValueList(List: TStrings); override;
00154 end;
00155
00156 {** Shows all Columns received from Connection.IZDatabaseMetadata. }
00157 TZColumnNamePropertyEditor = class(TZStringProperty)
00158 public
00159 procedure GetValueList(List: TStrings); override;
00160 end;
00161
00162 {** Shows all Schemes received from Connection.IZDatabaseMetadata. }
00163 TZSchemaPropertyEditor = class(TZStringProperty)
00164 public
00165 procedure GetValueList(List: TStrings); override;
00166 end;
00167
00168 {** Shows all Types received from Connection.IZDatabaseMetadata. }
00169 TZTypeNamePropertyEditor = class(TZStringProperty)
00170 public
00171 procedure GetValueList(List: TStrings); override;
00172 end;
00173 {$ENDIF}
00174
00175 const
00176 CRLF = LineEnding;
00177
00178 {$ENDIF}
00179
00180 implementation
00181
00182 {$IFDEF WITH_PROPERTY_EDITOR}
00183
00184 uses SysUtils, Forms, Dialogs, Controls, DB, TypInfo,
00185 ZConnection, ZSelectSchema
00186 {$IFDEF USE_METADATA}
00187 , ZSqlMetadata
00188 {$ENDIF}
00189 {$IFNDEF UNIX}
00190 {$IFNDEF FPC}
00191 {$IFDEF ENABLE_ADO}
00192 , ZDbcAdoUtils
00193 {$ENDIF}
00194 {$ENDIF}
00195 {$ENDIF}
00196 {$IFDEF SHOW_WARNING}
00197 ,ZMessages
00198 {$ENDIF SHOW_WARNING}
00199 ;
00200
00201 {$IFDEF FPC}
00202 procedure GetItemNames(FieldDefs: TFieldDefs; List: TStrings); overload;
00203 var
00204 i: Integer;
00205 begin
00206 List.Clear;
00207 for i := 0 to Pred(FieldDefs.Count) do
00208 List.Append(FieldDefs[i].Name);
00209 end;
00210
00211 procedure GetItemNames(IndexDefs: TIndexDefs; List: TStrings); overload;
00212 var
00213 i: Integer;
00214 begin
00215 List.Clear;
00216 for i := 0 to Pred(IndexDefs.Count) do
00217 List.Append(IndexDefs[i].Name);
00218 end;
00219 {$ENDIF}
00220
00221 { Returns the IndexDefs from Dataset }
00222 function GetIndexDefs(Component: TPersistent): TIndexDefs;
00223 var
00224 DataSet: TDataSet;
00225 begin
00226 DataSet := Component as TDataSet;
00227 Result := GetObjectProp(DataSet, 'IndexDefs') as TIndexDefs;
00228 if Assigned(Result) then
00229 begin
00230 Result.Updated := False;
00231 Result.Update;
00232 end;
00233 end;
00234
00235 function IsEmpty(const s: string): Boolean;
00236 begin
00237 Result := Trim(s) = '';
00238 end;
00239
00240 { TZStringProperty }
00241
00242 {**
00243 Gets a type of property attributes.
00244 @return a type of property attributes.
00245 }
00246 function TZStringProperty.GetAttributes: TPropertyAttributes;
00247 begin
00248 Result := [paValueList, paSortList];
00249 end;
00250
00251 {**
00252 Processes a list of list items.
00253 @param Proc a procedure to process the list items.
00254 }
00255 procedure TZStringProperty.GetValues(Proc: TGetStrProc);
00256 var
00257 i: Integer;
00258 Values: TStringList;
00259 begin
00260 Values := TStringList.Create;
00261 try
00262 GetValueList(Values);
00263 for i := 0 to Pred(Values.Count) do
00264 Proc(Values[i]);
00265 finally
00266 Values.Free;
00267 end;
00268 end;
00269
00270 { TZDataFieldPropertyEditor }
00271
00272 {**
00273 Processes a list of list items.
00274 @param List the list to process the list items.
00275 }
00276 procedure TZDataFieldPropertyEditor.GetValueList(List: TStrings);
00277 begin
00278 try
00279 with (GetComponent(0) as TDataSet) do
00280 begin
00281 // Update the FieldDefs and return the Fieldnames
00282 FieldDefs.Updated := False;
00283 FieldDefs.Update;
00284 {$IFNDEF FPC}
00285 FieldDefs.GetItemNames(List);
00286 {$ELSE}
00287 GetItemNames(FieldDefs, List);
00288 {$ENDIF}
00289 end;
00290 except
00291 end;
00292 end;
00293
00294 { TZIndexFieldPropertyEditor }
00295
00296 procedure TZIndexFieldPropertyEditor.GetValueList(List: TStrings);
00297 begin
00298 {$IFNDEF FPC}
00299 GetIndexDefs(GetComponent(0)).GetItemNames(List);
00300 {$ELSE}
00301 GetItemNames(GetIndexDefs(GetComponent(0)), List);
00302 {$ENDIF}
00303 end;
00304
00305 { TZMasterFieldPropertyEditor }
00306
00307 procedure TZMasterFieldPropertyEditor.GetValueList(List: TStrings);
00308 var
00309 DataSource: TDataSource;
00310 begin
00311 DataSource := GetObjectProp(GetComponent(0), 'MasterSource') as TDataSource;
00312 if (DataSource <> nil) and (DataSource.DataSet <> nil) then
00313 DataSource.DataSet.GetFieldNames(List);
00314 end;
00315
00316 { TZTableNamePropertyEditor }
00317
00318 {**
00319 Processes a list of list items.
00320 @param List the list to process the list items.
00321 }
00322 procedure TZTableNamePropertyEditor.GetValueList(List: TStrings);
00323 var
00324 Connection: TZConnection;
00325 Metadata: IZDatabaseMetadata;
00326 ResultSet: IZResultSet;
00327 Schema, Tablename:String;
00328 IdentifierConvertor: IZIdentifierConvertor;
00329 Catalog: string;
00330 begin
00331 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00332 if Assigned(Connection) and Connection.Connected then
00333 begin
00334 Metadata := Connection.DbcConnection.GetMetadata;
00335 IdentifierConvertor := Metadata.GetIdentifierConvertor;
00336 Catalog := Connection.Catalog;
00337 Schema := '';
00338 {$IFDEF USE_METADATA}
00339 if GetComponent(0) is TZSqlMetadata then
00340 begin
00341 Catalog := GetStrProp(GetComponent(0), 'Catalog');
00342 Schema := GetStrProp(GetComponent(0), 'Schema');
00343 {$IFDEF SHOW_WARNING}
00344 if not (IsEmpty(Catalog) and IsEmpty(Schema)) or
00345 (MessageDlg(SPropertyQuery + CRLF + SPropertyTables + CRLF +
00346 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
00347 begin
00348 // continue
00349 end
00350 else
00351 exit;
00352 {$ENDIF}
00353 end;
00354 {$ENDIF}
00355 begin
00356 try
00357 // Look for the Tables of the defined Catalog and Schema
00358 ResultSet := Metadata.GetTables(Catalog, Schema, '', nil);
00359 while ResultSet.Next do
00360 begin
00361 TableName := ResultSet.GetStringByName('TABLE_NAME');
00362 TableName := IdentifierConvertor.Quote(TableName);
00363 Schema := ResultSet.GetStringByName('TABLE_SCHEM');
00364 if Schema <> '' then
00365 TableName := IdentifierConvertor.Quote(Schema) + '.' + TableName;
00366 if Connection.Catalog <> '' then
00367 TableName := IdentifierConvertor.Quote(Connection.Catalog) + '.' + TableName;
00368 List.Add(TableName);
00369 end;
00370 finally
00371 ResultSet.Close;
00372 end;
00373 end;
00374 end;
00375 end;
00376
00377 { TZProcedureNamePropertyEditor }
00378
00379 {**
00380 Processes a list of list items.
00381 @param List the list to process the list items.
00382 }
00383 procedure TZProcedureNamePropertyEditor.GetValueList(List: TStrings);
00384 var
00385 Connection: TZConnection;
00386 Metadata: IZDatabaseMetadata;
00387 ResultSet: IZResultSet;
00388 {$IFDEF USE_METADATA}
00389 Catalog, Schema: string;
00390 {$ENDIF}
00391 begin
00392 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00393 if Assigned(Connection) and Connection.Connected then
00394 begin
00395 {$IFDEF USE_METADATA}
00396 if GetComponent(0) is TZSqlMetadata then
00397 begin
00398 Catalog := GetStrProp(GetComponent(0), 'Catalog');
00399 Schema := GetStrProp(GetComponent(0), 'Schema');
00400 {$IFDEF SHOW_WARNING}
00401 if not (IsEmpty(Catalog) and IsEmpty(Schema)) or
00402 (MessageDlg(SPropertyQuery + CRLF + SPropertyProcedures + CRLF +
00403 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
00404 {$ENDIF}
00405 try
00406 Metadata := Connection.DbcConnection.GetMetadata;
00407 // Look for the Procedures of the defined Catalog and Schema
00408 ResultSet := Metadata.GetProcedures(Catalog, Schema, '');
00409 while ResultSet.Next do
00410 List.Add(ResultSet.GetStringByName('PROCEDURE_NAME'));
00411 finally
00412 ResultSet.Close;
00413 end;
00414 end
00415 else
00416 {$ENDIF}
00417 begin
00418 try
00419 Metadata := Connection.DbcConnection.GetMetadata;
00420 // Look for the Procedures
00421 ResultSet := Metadata.GetProcedures(Connection.Catalog, '', '');
00422 while ResultSet.Next do
00423 List.Add(ResultSet.GetStringByName('PROCEDURE_NAME'));
00424 finally
00425 ResultSet.Close;
00426 end;
00427 end;
00428 end;
00429 end;
00430
00431 { TZSequenceNamePropertyEditor }
00432
00433 {**
00434 Gets a selected string value.
00435 @return a selected string value.
00436 }
00437 procedure TZSequenceNamePropertyEditor.GetValueList(List: TStrings);
00438 var
00439 Connection: TZConnection;
00440 Metadata: IZDatabaseMetadata;
00441 ResultSet: IZResultSet;
00442 {$IFDEF USE_METADATA}
00443 Catalog, Schema: string;
00444 {$ENDIF}
00445 begin
00446 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00447 if Assigned(Connection) and Connection.Connected then
00448 begin
00449 {$IFDEF USE_METADATA}
00450 if GetComponent(0) is TZSqlMetadata then
00451 begin
00452 Catalog := GetStrProp(GetComponent(0), 'Catalog');
00453 Schema := GetStrProp(GetComponent(0), 'Schema');
00454 {$IFDEF SHOW_WARNING}
00455 if not (IsEmpty(Catalog) and IsEmpty(Schema)) or
00456 (MessageDlg(SPropertyQuery + CRLF + SPropertySequences + CRLF +
00457 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
00458 {$ENDIF}
00459 try
00460 Metadata := Connection.DbcConnection.GetMetadata;
00461 // Look for the Procedures of the defined Catalog and Schema
00462 ResultSet := Metadata.GetSequences(Catalog, Schema, '');
00463 while ResultSet.Next do
00464 List.Add(ResultSet.GetStringByName('SEQUENCE_NAME'));
00465 finally
00466 ResultSet.Close;
00467 end;
00468 end
00469 else
00470 {$ENDIF}
00471 begin
00472 try
00473 Metadata := Connection.DbcConnection.GetMetadata;
00474 // Look for the Procedures
00475 ResultSet := Metadata.GetSequences(Connection.Catalog, '', '');
00476 while ResultSet.Next do
00477 if ResultSet.GetStringByName('SEQUENCE_SCHEM') <> '' then
00478 List.Add(ResultSet.GetStringByName('SEQUENCE_SCHEM')+'.'+ResultSet.GetStringByName('SEQUENCE_NAME'))
00479 else
00480 List.Add(ResultSet.GetStringByName('SEQUENCE_NAME'));
00481 finally
00482 ResultSet.Close;
00483 end;
00484 end;
00485 end;
00486 end;
00487
00488 { TZProtocolPropertyEditor }
00489
00490 {**
00491 Gets a selected string value.
00492 @return a selected string value.
00493 }
00494 function TZProtocolPropertyEditor.GetValue: string;
00495 begin
00496 Result := GetStrValue;
00497 end;
00498
00499 {**
00500 Sets a new selected string value.
00501 @param Value a new selected string value.
00502 }
00503 procedure TZProtocolPropertyEditor.SetValue(const Value: string);
00504 begin
00505 SetStrValue(Value);
00506 if GetComponent(0) is TZConnection then
00507 (GetComponent(0) as TZConnection).Connected := False;
00508 end;
00509
00510 {**
00511 Processes a list of list items.
00512 @param List the list to process the list items.
00513 }
00514 procedure TZProtocolPropertyEditor.GetValueList(List: TStrings);
00515 var
00516 I, J: Integer;
00517 Drivers: IZCollection;
00518 Protocols: TStringDynArray;
00519 begin
00520 Drivers := DriverManager.GetDrivers;
00521 Protocols := nil;
00522 for I := 0 to Drivers.Count - 1 do
00523 begin
00524 Protocols := (Drivers[I] as IZDriver).GetSupportedProtocols;
00525 for J := Low(Protocols) to High(Protocols) do
00526 List.Append(Protocols[J]);
00527 end;
00528 end;
00529
00530 { TZDatabasePropertyEditor }
00531
00532 {**
00533 Gets a type of property attributes.
00534 @return a type of property attributes.
00535 }
00536 function TZDatabasePropertyEditor.GetAttributes: TPropertyAttributes;
00537 begin
00538 if GetComponent(0) is TZConnection then
00539 begin
00540 if ((GetComponent(0) as TZConnection).Protocol = 'mssql') or
00541 ((GetComponent(0) as TZConnection).Protocol = 'sybase') then
00542 Result := inherited GetAttributes
00543 else
00544 Result := [paDialog];
00545 end;
00546 end;
00547
00548 {**
00549 Gets a selected string value.
00550 @return a selected string value.
00551 }
00552 function TZDatabasePropertyEditor.GetValue: string;
00553 begin
00554 Result := GetStrValue;
00555 end;
00556
00557 {**
00558 Sets a new selected string value.
00559 @param Value a new selected string value.
00560 }
00561 procedure TZDatabasePropertyEditor.SetValue(const Value: string);
00562 begin
00563 SetStrValue(Value);
00564 if GetComponent(0) is TZConnection then
00565 (GetComponent(0) as TZConnection).Connected := False;
00566 end;
00567
00568 {**
00569 Processes a list of list items.
00570 @param List the list to process the list items.
00571 }
00572 procedure TZDatabasePropertyEditor.GetValueList(List: TStrings);
00573 var
00574 DbcConnection: IZConnection;
00575 Url: string;
00576 begin
00577 if GetComponent(0) is TZConnection then
00578 try
00579 if (GetComponent(0) as TZConnection).Port = 0 then
00580 Url := Format('zdbc:%s:
00581 (GetComponent(0) as TZConnection).Protocol,
00582 (GetComponent(0) as TZConnection).HostName,
00583 '',
00584 (GetComponent(0) as TZConnection).User,
00585 (GetComponent(0) as TZConnection).Password])
00586 else
00587 Url := Format('zdbc:%s:
00588 (GetComponent(0) as TZConnection).Protocol,
00589 (GetComponent(0) as TZConnection).HostName,
00590 (GetComponent(0) as TZConnection).Port,
00591 '',
00592 (GetComponent(0) as TZConnection).User,
00593 (GetComponent(0) as TZConnection).Password]);
00594
00595 (GetComponent(0) as TZConnection).ShowSqlHourGlass;
00596 try
00597 DbcConnection := DriverManager.GetConnectionWithParams(Url,
00598 (GetComponent(0) as TZConnection).Properties);
00599
00600 with DbcConnection.GetMetadata.GetCatalogs do
00601 try
00602 while Next do
00603 List.Append(GetStringByName('TABLE_CAT'));
00604 finally
00605 Close;
00606 end;
00607
00608 finally
00609 (GetComponent(0) as TZConnection).HideSqlHourGlass;
00610 end;
00611 except
00612
00613 end;
00614 end;
00615
00616 {**
00617 Brings up the proper database property editor dialog.
00618 }
00619 procedure TZDatabasePropertyEditor.Edit;
00620 var
00621 OD: TOpenDialog;
00622 begin
00623 if GetComponent(0) is TZConnection then
00624 begin
00625 if ((GetComponent(0) as TZConnection).Protocol = 'mssql') or
00626 ((GetComponent(0) as TZConnection).Protocol = 'sybase') then
00627 inherited
00628 {$IFNDEF UNIX}
00629 {$IFNDEF FPC}
00630 {$IFDEF ENABLE_ADO}
00631 else
00632 if ((GetComponent(0) as TZConnection).Protocol = 'ado') then
00633 (GetComponent(0) as TZConnection).Database := PromptDataSource(Application.Handle,
00634 (GetComponent(0) as TZConnection).Database)
00635 {$ENDIF}
00636 {$ENDIF}
00637 {$ENDIF}
00638 else
00639 begin
00640 OD := TOpenDialog.Create(nil);
00641 try
00642 OD.InitialDir := ExtractFilePath((GetComponent(0) as TZConnection).Database);
00643 if OD.Execute then
00644 (GetComponent(0) as TZConnection).Database := OD.FileName;
00645 finally
00646 OD.Free;
00647 end;
00648 end;
00649 end
00650 else
00651 inherited;
00652 end;
00653
00654 { TZCatalogPropertyEditor }
00655
00656 {**
00657 Gets a selected string value.
00658 @return a selected string value.
00659 }
00660 function TZCatalogPropertyEditor.GetValue: string;
00661 begin
00662 Result := GetStrValue;
00663 end;
00664
00665 {**
00666 Sets a new selected string value.
00667 @param Value a new selected string value.
00668 }
00669 procedure TZCatalogPropertyEditor.SetValue(const Value: string);
00670 begin
00671 SetStrValue(Value);
00672 end;
00673
00674 {**
00675 Processes a list of list items.
00676 @param List the list to process the list items.
00677 }
00678 procedure TZCatalogPropertyEditor.GetValueList(List: TStrings);
00679 var
00680 DbcConnection: IZConnection;
00681 Url: string;
00682 begin
00683 if GetComponent(0) is TZConnection then
00684 try
00685 if (GetComponent(0) as TZConnection).Port = 0 then
00686 Url := Format('zdbc:%s:
00687 (GetComponent(0) as TZConnection).Protocol,
00688 (GetComponent(0) as TZConnection).HostName,
00689 '',
00690 (GetComponent(0) as TZConnection).User,
00691 (GetComponent(0) as TZConnection).Password])
00692 else
00693 Url := Format('zdbc:%s:
00694 (GetComponent(0) as TZConnection).Protocol,
00695 (GetComponent(0) as TZConnection).HostName,
00696 (GetComponent(0) as TZConnection).Port,
00697 '',
00698 (GetComponent(0) as TZConnection).User,
00699 (GetComponent(0) as TZConnection).Password]);
00700
00701 (GetComponent(0) as TZConnection).ShowSqlHourGlass;
00702 try
00703 DbcConnection := DriverManager.GetConnectionWithParams(Url,
00704 (GetComponent(0) as TZConnection).Properties);
00705
00706 with DbcConnection.GetMetadata.GetCatalogs do
00707 try
00708 while Next do
00709 List.Append(GetStringByName('TABLE_CAT'));
00710 finally
00711 Close;
00712 end;
00713
00714 finally
00715 (GetComponent(0) as TZConnection).HideSqlHourGlass;
00716 end;
00717 except
00718
00719 end;
00720 end;
00721
00722 {$IFDEF USE_METADATA}
00723
00724 { TZCatalogProperty }
00725
00726 {**
00727 Processes a list of list items.
00728 @param List the list to process the list items.
00729 }
00730 procedure TZCatalogProperty.GetValueList(List: TStrings);
00731 var
00732 Connection: TZConnection;
00733 Metadata: IZDatabaseMetadata;
00734 ResultSet: IZResultSet;
00735 begin
00736 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00737 if Assigned(Connection) and Connection.Connected then
00738 try
00739 Metadata := Connection.DbcConnection.GetMetadata;
00740 ResultSet := Metadata.GetCatalogs;
00741 while ResultSet.Next do
00742 List.Add(ResultSet.GetStringByName('TABLE_CAT'));
00743 finally
00744 ResultSet.Close;
00745 end;
00746 end;
00747
00748 { TZColumnNamePropertyEditor }
00749
00750 {**
00751 Processes a list of list items.
00752 @param List the list to process the list items.
00753 }
00754 procedure TZColumnNamePropertyEditor.GetValueList(List: TStrings);
00755 var
00756 Connection: TZConnection;
00757 Metadata: IZDatabaseMetadata;
00758 ResultSet: IZResultSet;
00759 Catalog, Schema, TableName: string;
00760 begin
00761 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00762 if Assigned(Connection) and Connection.Connected then
00763 begin
00764 Catalog := GetStrProp(GetComponent(0), 'Catalog');
00765 Schema := GetStrProp(GetComponent(0), 'Schema');
00766 TableName := GetStrProp(GetComponent(0), 'TableName');
00767 {$IFDEF SHOW_WARNING}
00768 if not IsEmpty(TableName) or not (IsEmpty(Schema) and IsEmpty(Schema)) or
00769 (MessageDlg(SPropertyQuery + CRLF + SPropertyTables + CRLF +
00770 SPropertyExecute, mtWarning, [mbYes,mbNo], 0) = mrYes) then
00771 {$ENDIF}
00772 try
00773 Metadata := Connection.DbcConnection.GetMetadata;
00774
00775 ResultSet := Metadata.GetColumns(Catalog, Schema, TableName, '');
00776 while ResultSet.Next do
00777 if List.IndexOf(ResultSet.GetStringByName('COLUMN_NAME')) = -1 then
00778 List.Add(ResultSet.GetStringByName('COLUMN_NAME'));
00779 finally
00780 ResultSet.Close;
00781 end;
00782 end;
00783 end;
00784
00785 { TZSchemaPropertyEditor }
00786
00787 {**
00788 Processes a list of list items.
00789 @param List the list to process the list items.
00790 }
00791 procedure TZSchemaPropertyEditor.GetValueList(List: TStrings);
00792 var
00793 Connection: TZConnection;
00794 Metadata: IZDatabaseMetadata;
00795 ResultSet: IZResultSet;
00796 begin
00797 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00798 if Assigned(Connection) and Connection.Connected then
00799 try
00800 Metadata := Connection.DbcConnection.GetMetadata;
00801 ResultSet := Metadata.GetSchemas;
00802 while ResultSet.Next do
00803 List.Add(ResultSet.GetStringByName('TABLE_SCHEM'));
00804 finally
00805 ResultSet.Close;
00806 end;
00807 end;
00808
00809 { TZTypeNamePropertyEditor }
00810
00811 {**
00812 Processes a list of list items.
00813 @param List the list to process the list items.
00814 }
00815 procedure TZTypeNamePropertyEditor.GetValueList(List: TStrings);
00816 var
00817 Connection: TZConnection;
00818 Metadata: IZDatabaseMetadata;
00819 ResultSet: IZResultSet;
00820 begin
00821 Connection := GetObjectProp(GetComponent(0), 'Connection') as TZConnection;
00822 if Assigned(Connection) and Connection.Connected then
00823 try
00824 Metadata := Connection.DbcConnection.GetMetadata;
00825 ResultSet := Metadata.GetTypeInfo;
00826 while ResultSet.Next do
00827 List.Add(ResultSet.GetStringByName('TYPE_NAME'));
00828 finally
00829 ResultSet.Close;
00830 end;
00831 end;
00832 {$ENDIF}
00833
00834 {$ENDIF}
00835
00836 end.
00837
00838