zeoslib  UNKNOWN
 All Files
ZROSqlEditor.pas
Go to the documentation of this file.
1 {*********************************************************}
2 { }
3 { Zeos Database Objects }
4 { SQL Monitor component }
5 { }
6 { Originally written by Sergey Seroukhov }
7 { }
8 {*********************************************************}
9 
10 {@********************************************************}
11 { Copyright (c) 1999-2012 Zeos Development Group }
12 { }
13 { License Agreement: }
14 { }
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. }
20 { }
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. }
39 { }
40 { }
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) }
45 { }
46 { http://www.sourceforge.net/projects/zeoslib. }
47 { }
48 { }
49 { Zeos Development Group. }
50 {********************************************************@}
51 
52 unit ZROSqlEditor;
53 
54 {$I ZComponent.inc}
55 
56 interface
57 
58 uses
59 {$IFDEF MSWINDOWS} // 64-bit too
60  Windows, Messages,
61 {$ENDIF}
62  {$IFDEF FPC}
63  LCLIntf,
64  {$ENDIF}
65  SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Graphtype,
66  StdCtrls, ExtCtrls, ComCtrls, Buttons, ZDataset, Menus, ZMessages;
67  //{$IFDEF USE_SYNEDIT}
68  //, SynEdit, SynEditHighlighter, SynHighlighterSQL
69  //{$IFDEF FPC}
70  //, SynCompletion
71  //{$ELSE}
72  //, SynCompletionProposal
73  //{$ENDIF}
74  //{$ENDIF};
75 
76 type
77 
78  { TZROSQLEditorForm }
79 
80  TZROSQLEditorForm = class(TForm)
81  private
82  mnuSave: TMenuItem;
83  mnuLoad: TMenuItem;
84  dlgOpen: TOpenDialog;
85  PopupMenu1: TPopupMenu;
86  dlgSave: TSaveDialog;
87  btnOk: TBitBtn;
88  btnCancel: TBitBtn;
89  Panel2: TPanel;
90  tbsSelect: TTabSheet;
91  Panel1: TPanel;
92  Splitter2: TSplitter;
93  ListBoxRelations: TListBox;
94  ListBoxFields: TListBox;
95  Splitter1: TSplitter;
96  Panel3: TPanel;
97  lblAlias: TLabel;
98  edtAlias: TEdit;
99  btnGenerate: TButton;
100  btnCheck: TButton;
101  chkReplace: TCheckBox;
102  btnTest: TButton;
103  edtSelect: TMemo;
104  //{$IFDEF USE_SYNEDIT}
105  //edtSelect: TSynEdit;
106  //SynSQLSyn1: TSynSQLSyn;
107  //{$IFDEF FPC}
108  //SynCompletion:TSynCompletion;
109  //{$ELSE}
110  //SynCompletion:TSynCompletionProposal;
111  //{$ENDIF}
112  //{$ELSE}
113  //edtSelect: TMemo;
114  //{$ENDIF}
115  FDS: TZReadOnlyQuery;
116  FSaveConnected: Boolean;
117  procedure FormClose(Sender: TObject; var Action: TCloseAction);
118  procedure ListBoxRelationsDblClick(Sender: TObject);
119  procedure ListBoxRelationsSelectionChange(Sender: TObject; User: boolean);
120  procedure PageControl1Change(Sender: TObject);
121  procedure ZeosROSQLEditorDestroy(Sender: TObject);
122  procedure btnGenerateClick(Sender: TObject);
123  procedure btnTestClick(Sender: TObject);
124  procedure mnuLoadClick(Sender: TObject);
125  procedure mnuSaveClick(Sender: TObject);
126  procedure LoadTableList;
127  procedure FillIdentifier;
128  function ActiveEditor:TMemo;
129  //function ActiveEditor:{$IFDEF USE_SYNEDIT} TSynEdit {$ELSE} TMemo {$ENDIF};
130  //{$IFDEF USE_SYNEDIT}
131  //{$IFDEF FPC}
132  //procedure ccComplete(var Value: ansistring; Shift: TShiftState);
133  //procedure ccExecute(Sender: TObject);
134  //{$ELSE}
135  //procedure ccComplete(Sender: TObject; var Value: string;
136  //Shift: TShiftState; Index: Integer; EndToken: Char);
137  //procedure ccExecute(Kind: SynCompletionType; Sender: TObject;
138  //var CurrentInput: string; var x, y: Integer; var CanExecute: Boolean);
139  //{$ENDIF}
140  //{$ENDIF}
141  public
142  PageControl1: TPageControl;
143  constructor CreateEditor(ADS:TZReadOnlyQuery);
144  end;
145 
146 var
147  ZeosROSQLEditorForm: TZROSQLEditorForm;
148 
149 implementation
150 uses
151  ZSqlTestForm, ZDbcIntfs, ZCompatibility;
152 
153 const
154  SQLDefaultFilter = 'SQL files (*.sql)|*.sql';
155 
156 { TZeosROSQLEditor }
157 
158 constructor TZROSQLEditorForm.CreateEditor(ADS: TZReadOnlyQuery);
159 begin
160  inherited CreateNew(Application,0);
161 
162  Height := 613;
163  Left := 315;
164  Top := 142;
165  TextHeight := 13;
166  Width := 768;
167  Position := poDesktopCenter;
168  Caption := sFormEditor;
169  OnClose := FormClose;
170  OnDestroy := ZeosROSQLEditorDestroy;
171  btnOk := TBitBtn.Create(self);
172  with btnOk do
173  begin
174  Parent := self;
175  Anchors := [akRight, akBottom];
176  Default := True;
177  Height := 25;
178  Kind := bkOk;
179  Left := 593;
180  ModalResult := mrOk;
181  TabOrder := 3;
182  TabStop := True;
183  Top := 552;
184  Width := 75;
185  Caption := SButtonOk;
186  end;
187  btnCancel := TBitBtn.Create(self);
188  with btnCancel do
189  begin
190  Parent := self;
191  Anchors := [akRight, akBottom];
192  Default := True;
193  Height := 25;
194  Kind := bkCancel;
195  Left := 677;
196  ModalResult := mrCancel;
197  TabOrder := 4;
198  TabStop := True;
199  Top := 552;
200  Width := 75;
201  Caption := SButtonCancel;
202  end;
203  btnGenerate := TButton.Create(self);
204  with btnGenerate do
205  begin
206  Parent := self;
207  Anchors := [akLeft,akBottom];
208  Caption := SButtonGenerate;
209  Height := 25;
210  Left := 8;
211  OnClick := btnGenerateClick;
212  TabOrder := 0;
213  TabStop := True;
214  Top := 552;
215  Width := 75;
216  end;
217  btnCheck := TButton.Create(self);
218  with btnCheck do
219  begin
220  Parent := self;
221  Anchors := [akLeft,akBottom];
222  Caption := SButtonCheck;
223  Enabled := False;
224  Height := 25;
225  Left := 88;
226  TabOrder := 1;
227  TabStop := True;
228  Top := 552;
229  Visible := False;
230  Width := 75;
231  end;
232  btnTest := TButton.Create(self);
233  with btnTest do
234  begin
235  Parent := self;
236  Anchors := [akLeft,akBottom];
237  Caption := SButtonTest;
238  Height := 25;
239  Left := 168;
240  OnClick := btnTestClick;
241  TabOrder := 2;
242  TabStop := True;
243  Top := 552;
244  Width := 75;
245  end;
246  dlgOpen := TOpenDialog.Create(self);
247  with dlgOpen do
248  begin
249  FilterIndex :=0;
250  Options := [ofEnableSizing,ofViewDetail];
251  Title := SDialogOpenTitle;
252  Filter := SQLDefaultFilter;
253  end;
254  dlgSave := TSaveDialog.Create(self);
255  with dlgSave do
256  begin
257  FilterIndex :=0;
258  Options := [ofEnableSizing,ofViewDetail];
259  Title := SDialogSaveTitle;
260  Filter := SQLDefaultFilter;
261  end;
262  mnuLoad := TMenuItem.Create(self);
263  with mnuLoad do
264  begin
265  Caption := SMenuLoad;
266  OnClick := mnuLoadClick;
267  end;
268  mnuSave := TMenuItem.Create(self);
269  with mnuSave do
270  begin
271  Caption := SMenuSave;
272  OnClick := mnuSaveClick;
273  end;
274  PopupMenu1 := TPopupMenu.Create(self);
275  with PopupMenu1 do
276  begin
277  AutoPopup := true;
278  Items.Add(mnuLoad);
279  Items.Add(mnuSave);
280  end;
281  Panel2 := TPanel.Create(self);
282  with Panel2 do
283  begin
284  Parent := self;
285  Align := alTop;
286  Anchors := [akTop,akLeft,akRight,akBottom];
287  FullRepaint := False;
288  Height := 545;
289  Left := 0;
290  TabOrder := 5;
291  TabStop := False;
292  Top := 0;
293  Width := 768;
294  end;
295  Splitter1 := TSplitter.Create(self);
296  with Splitter1 do
297  begin
298  Parent := Panel2;
299  Align := alRight;
300  Anchors := [akTop,akRight,akBottom];
301  Height := 543;
302  Left := 518;
303  Top := 1;
304  Width := 5;
305  end;
306  PageControl1 := TPageControl.Create(self);
307  with PageControl1 do
308  begin
309  Parent := Panel2;
310  Align := alClient;
311  Anchors := [akTop,akLeft,akRight,akBottom];
312  Height := 543;
313  Left := 1;
314  OnChange := PageControl1Change;
315  TabIndex := 0;
316  TabOrder := 0;
317  TabPosition := tpTop;
318  TabStop := True;
319  Top := 1;
320  Width := 517;
321  end;
322  tbsSelect := TTabSheet.Create(self);
323  with tbsSelect do
324  begin
325  Parent := PageControl1;
326  Caption := STabSheetSelect;
327  Height := 513;
328  Left := 2;
329  Top := 28;
330  Width := 513;
331  end;
332  Panel1 := TPanel.Create(self);
333  with Panel1 do
334  begin
335  Parent := Panel2;
336  Align := alRight;
337  Anchors := [akTop,akRight,akBottom];
338  FullRepaint := false;
339  Height := 543;
340  Left := 523;
341  TabOrder := 1;
342  TabStop := False;
343  Top := 1;
344  Width := 244;
345  end;
346  Splitter2 := TSplitter.Create(self);
347  with Splitter2 do
348  begin
349  Parent := Panel1;
350  Align := alBottom;
351  Anchors := [akLeft,akRight,akBottom];
352  Cursor := crVSplit;
353  Height := 9;
354  Left := 1;
355  Top := 271;
356  Width := 242;
357  end;
358  ListBoxRelations := TListBox.Create(self);
359  with ListBoxRelations do
360  begin
361  Parent := Panel1;
362  Align := alClient;
363  Anchors := [akTop,akLeft,akRight,akBottom];
364  Height := 198;
365  ItemHeight := 13;
366  Left := 1;
367  OnDblClick := ListBoxRelationsDblClick;
368  OnSelectionChange := ListBoxRelationsSelectionChange;
369  TabOrder := 0;
370  Top := 73;
371  Width := 242
372  end;
373  ListBoxFields := TListBox.Create(self);
374  with ListBoxFields do
375  begin
376  Parent := Panel1;
377  Align := alBottom;
378  Anchors := [akLeft,akRight,akBottom];
379  Height := 262;
380  ItemHeight := 13;
381  Left := 1;
382  MultiSelect := True;
383  TabOrder := 1;
384  Top := 280;
385  Width := 242;
386  end;
387  Panel3 := TPanel.Create(self);
388  with Panel3 do
389  begin
390  Parent := Panel1;
391  Align := alTop;
392  Anchors := [akTop,akLeft,akRight,akBottom];
393  BevelOuter := bvNone;
394  FullRepaint := False;
395  Height := 72;
396  Left := 1;
397  TabOrder := 2;
398  TabStop := False;
399  Top := 1;
400  Width := 242;
401  end;
402  edtAlias := TEdit.Create(self);
403  with edtAlias do
404  begin
405  Parent := Panel3;
406  Anchors := [akTop,akLeft];
407  Height := 21;
408  Left := 80;
409  TabOrder := 0;
410  Top := 8;
411  Width := 153;
412  end;
413  lblAlias := TLabel.Create(self);
414  with lblAlias do
415  begin
416  Parent := Panel3;
417  Anchors := [akTop, akLeft];
418  Caption := STableAlias;
419  FocusControl := edtAlias;
420  Height := 13;
421  Left := 8;
422  Top := 16;
423  Width := 68;
424  end;
425  chkReplace := TCheckBox.Create(self);
426  with chkReplace do
427  begin
428  Parent := Panel3;
429  Anchors := [akTop,akLeft];
430  Caption := SReplaceSQL;
431  Checked := True;
432  Height := 17;
433  Left := 8;
434  TabOrder := 1;
435  TabStop := True;
436  Top := 40;
437  Width := 97;
438  end;
439  edtSelect := TMemo.Create(self);
440  with edtSelect do
441  begin
442  Parent := tbsSelect;
443  Align := alClient;
444  Anchors := [akTop,akLeft,akRight,akBottom];
445  Font.Height := -14;
446  {$IFDEF MSWINDOWS}
447  Font.Name := 'Courier New';
448  {$ENDIF}
449  Font.Pitch := fpFixed;
450  Height := 513;
451  Left := 0;
452  PopupMenu := PopupMenu1;
453  TabOrder := 0;
454  TabStop := True;
455  Top := 0;
456  Width := 513;
457  end;
458  //{$IFDEF USE_SYNEDIT}
459  //with SynSQLSyn1 do
460  //begin
461  //TableNameAttri.Background:=clWindow;
462  //TableNameAttri.Foreground:=clGreen;
463  //TableNameAttri.Style:=[fsUnderline];
464  //with ADS.Connection do
465  //if (strpos(PChar(Protocol),'firebird') <> nil) or
466  //(strpos(PChar(Protocol),'interbase') <> nil) then
467  //begin
468  //SQLDialect:=sqlInterbase6;
469  //end
470  //else if Protocol = 'mssql' then
471  //begin
472  //SQLDialect:=sqlMSSQL2K;
473  //end
474  //else if (strpos(PChar(Protocol),'mysql') <> nil) then
475  //begin
476  //SQLDialect:=sqlMySQL;
477  //end
478  //else if (strpos(PChar(Protocol),'postgresql') <> nil) then
479  //begin
480  //SQLDialect:=sqlStandard;
481  //end
482  //else if Protocol = 'sybase' then
483  //begin
484  //SQLDialect:=sqlSybase;
485  //end;
486  //DefaultFilter:=SQLDefaultFilter;
487  //end;
488  //{$IFDEF FPC}
489  //SynCompletion:=TSynCompletion.Create(Self);
490  //{$ELSE}
491  //SynCompletion:=TSynCompletionProposal.Create(Self);
492  //{$ENDIF}
493  //with SynCompletion do begin
494  //AddEditor(edtSelect);
495  //ItemList.Clear;
496  //OnCodeCompletion:=ccComplete;
497  //OnExecute:=ccExecute;
498  //end;
499  //{$ENDIF}
500  FSaveConnected := True;
501  FDS:=ADS;
502  if Assigned(FDS) then
503  begin
504  if not FDS.Connection.Connected then
505  begin
506  FSaveConnected := False;
507  FDS.Connection.Connected := True;
508  end;
509  edtSelect.Lines.Text:=FDS.SQL.Text;
510  LoadTableList;
511  FillIdentifier;
512  end;
513 
514 end;
515 
516 procedure TZROSQLEditorForm.FillIdentifier;
517 var
518  i:integer;
519 begin
520  //{$IFDEF USE_SYNEDIT}
521  //SynSQLSyn1.TableNames.Clear;
522  //for i:=0 to ListBoxRelations.Items.Count-1 do
523  //begin
524  //SynSQLSyn1.TableNames.Add(ListBoxRelations.Items[i]);
525  //end;
526  //{$ENDIF}
527 end;
528 
529 procedure TZROSQLEditorForm.FormClose(Sender: TObject;
530  var Action: TCloseAction);
531 begin
532  if (ModalResult=mrOk) and Assigned(FDS) then
533  begin
534  FDS.SQL.Text:=edtSelect.Lines.Text;
535  end;
536 end;
537 
538 procedure TZROSQLEditorForm.LoadTableList;
539 var
540  Metadata: IZDatabaseMetadata;
541  TableTypes: TStringDynArray;
542 begin
543  if Assigned(FDS.Connection) and FDS.Connection.Connected then
544  begin
545  Metadata := FDS.Connection.DbcConnection.GetMetadata;
546  SetLength(TableTypes, 2);
547  TableTypes[0] := 'TABLE';
548  TableTypes[1] := 'VIEW';
549  FDS.Connection.ShowSQLHourGlass;
550  ListBoxRelations.Items.Clear;
551  with Metadata.GetTables(FDS.Connection.Catalog, '', '', TableTypes) do
552  try
553  while Next do
554  if ListBoxRelations.Items.IndexOf(trim(GetString(3))) = -1 then
555  ListBoxRelations.Items.Add(trim(GetString(3)));
556  finally
557  Close;
558  end;
559  FDS.Connection.HideSQLHourGlass;
560  end;
561 end;
562 
563 function TZROSQLEditorForm.ActiveEditor:TMemo;
564 //function TZROSQLEditorForm.ActiveEditor:
565  //{$IFDEF USE_SYNEDIT}TSynEdit{$ELSE}TMemo{$ENDIF};
566 begin
567  case PageControl1.ActivePageIndex of
568  0:Result:=edtSelect;
569  end;
570 end;
571 
572 procedure TZROSQLEditorForm.ListBoxRelationsDblClick(
573  Sender: TObject);
574 var
575  i:integer;
576  Als, FieldsStr:string;
577 begin
578  if ActiveEditor<>nil then
579  with ActiveEditor do
580  begin
581  if chkReplace.Checked then Lines.Clear;
582  if ListBoxFields.SelCount=0 then
583  begin
584  Lines.Add('select');
585  Lines.Add(' *');
586  Lines.Add('from');
587  Lines.Add(' '+ListBoxRelations.Items[ListBoxRelations.ItemIndex]+' '+edtAlias.Text);
588  end
589  else
590  begin
591  Lines.Add('select');
592  if edtAlias.Text<>'' then Als:=edtAlias.Text
593  else Als:=ListBoxRelations.Items[ListBoxRelations.ItemIndex];
594  FieldsStr:='';
595  for i:=0 to ListBoxFields.Items.Count-1 do
596  begin
597  if ListBoxFields.Selected[i] then
598  begin
599  if FieldsStr<>'' then
600  Lines.Add(FieldsStr+',');
601  FieldsStr:=' '+Als+'.'+ListBoxFields.Items[i];
602  end;
603  end;
604  if FieldsStr<>'' then Lines.Add(FieldsStr);
605  Lines.Add('from');
606  Lines.Add(' '+ListBoxRelations.Items[ListBoxRelations.ItemIndex]+' '+edtAlias.Text);
607  end;
608  end;
609 end;
610 
611 procedure TZROSQLEditorForm.ListBoxRelationsSelectionChange(Sender: TObject;
612  User: boolean);
613 var
614  Metadata: IZDatabaseMetadata;
615  TPName: string;
616  StrEsc: string;
617 begin
618  if Assigned(FDS.Connection) and FDS.Connection.Connected then
619  begin
620  FDS.Connection.ShowSQLHourGlass;
621  Metadata := FDS.Connection.DbcConnection.GetMetadata;
622  with ListBoxFields do begin
623  ItemIndex := -1;
624  Items.BeginUpdate;
625  Items.Clear;
626  Items.EndUpdate;
627  end;
628  if ListBoxRelations.ItemIndex >= 0 then
629  begin
630  TPName := ListBoxRelations.Items[ListBoxRelations.ItemIndex];
631  with Metadata.GetColumns(FDS.Connection.Catalog,'', TPName,'') do
632  try
633  while Next do
634  if ListBoxFields.Items.IndexOf(GetStringByName('COLUMN_NAME')) = -1 then
635  ListBoxFields.Items.Add(GetStringByName('COLUMN_NAME'));
636  finally
637  Close;
638  end;
639  end;
640  FDS.Connection.HideSQLHourGlass;
641  end;
642 end;
643 
644 procedure TZROSQLEditorForm.PageControl1Change(Sender: TObject);
645 begin
646  case PageControl1.ActivePageIndex of
647  0:edtSelect.SetFocus;
648  end;
649 end;
650 
651 procedure TZROSQLEditorForm.ZeosROSQLEditorDestroy(Sender: TObject);
652 begin
653  if not FSaveConnected then
654  FDS.Connection.Connected := False;
655 end;
656 
657 procedure TZROSQLEditorForm.btnGenerateClick(Sender: TObject);
658 begin
659  ListBoxRelationsDblClick(nil);
660 end;
661 
662 procedure TZROSQLEditorForm.btnTestClick(Sender: TObject);
663 begin
664  if Assigned(FDS.Connection) and FDS.Connection.Connected then
665  begin
666  ZeosSQLEditorTestForm:=TZeosSQLEditorTestForm.Create(Application);
667  with ZeosSQLEditorTestForm do
668  begin
669  try
670  ZeosSQL.Connection:=FDS.Connection;
671  ZeosSQL.SQL.Text:=ActiveEditor.Lines.Text;
672  ZeosSQL.Active := true;
673  ShowModal
674  except
675  on E:Exception do
676  ShowMessage(E.Message);
677  end;
678  Free;
679  end;
680  end;
681 end;
682 
683 procedure TZROSQLEditorForm.mnuLoadClick(Sender: TObject);
684 begin
685  if (dlgOpen.Execute) then
686  ActiveEditor.Lines.LoadFromFile(dlgOpen.FileName);
687 end;
688 
689 procedure TZROSQLEditorForm.mnuSaveClick(Sender: TObject);
690 begin
691  if dlgSave.Execute then
692  ActiveEditor.Lines.SaveToFile(dlgSave.FileName);
693 end;
694 
695 //{$IFDEF USE_SYNEDIT}
696 //procedure TZROSQLEditorForm.ccComplete
697 //{$IFDEF FPC}
698 //(var Value: ansistring;
699  //Shift: TShiftState)
700 //{$ELSE}
701 //(Sender: TObject; var Value: string;
702  //Shift: TShiftState; Index: Integer; EndToken: Char)
703 //{$ENDIF}
704 //;
705 //begin
706 //end;
707 
708 //procedure TZROSQLEditorForm.ccExecute
709 //{$IFDEF FPC}
710 //(Sender: TObject)
711 //{$ELSE}
712 //(Kind: SynCompletionType; Sender: TObject;
713  //var CurrentInput: string; var x, y: Integer; var CanExecute: Boolean)
714 //{$ENDIF}
715 //;
716 //function GetCurWord:string;
717 //var
718  //S:string;
719  //i,j:integer;
720 //begin
721  //Result:='';
722  //with ActiveEditor do
723  //begin
724  //S:=Trim(Copy(LineText, 1, CaretX));
725  //I:=Length(S);
726  //while (i>0) and (S[i]<>'.') do Dec(I);
727  //if (I>0) then
728  //begin
729  //J:=i-1;
730  ////Get table name
731  //while (j>0) and CharInSet(S[j], ['A'..'z','"']) do Dec(j);
732  //Result:=trim(Copy(S, j+1, i-j-1));
733  //end;
734  //end;
735 //end;
736 //var
737  //S:string;
738  //Metadata: IZDatabaseMetadata;
739  //StrEsc: string;
740 //begin
741  //S:=AnsiUpperCase(GetCurWord);
742  //if S<>'' then
743  //begin
744  //if Assigned(FDS.Connection) and FDS.Connection.Connected then
745  //begin
746  //FDS.Connection.ShowSQLHourGlass;
747  //Metadata := FDS.Connection.DbcConnection.GetMetadata;
748  //SynCompletion.ItemList.Clear;
749  //{$IFDEF FPC}
750  //SynCompletion.OnPaintItem;
751  //{$ELSE}
752  //{$ENDIF}
753  //with Metadata.GetColumns(FDS.Connection.Catalog,'',S,'') do
754  //try
755  //while Next do
756  //if SynCompletion.ItemList.IndexOf(GetStringByName('COLUMN_NAME')) = -1 then
757  //SynCompletion.ItemList.Add(GetStringByName('COLUMN_NAME'));
758  //finally
759  //Close;
760  //end;
761  //FDS.Connection.HideSQLHourGlass;
762  //end;
763  //end;
764 //end;
765 //{$ENDIF}
766 
767 end.
768