Procházet zdrojové kódy

Fixing Script part Query bux
modified: TurboBird.lpi
modified: TurboBird.lpr
modified: querywindow.lfm
modified: querywindow.lrs
modified: querywindow.pas

motaz před 12 roky
rodič
revize
3e78a6351f
5 změnil soubory, kde provedl 200 přidání a 148 odebrání
  1. 115 91
      TurboBird.lpi
  2. 3 3
      TurboBird.lpr
  3. 1 1
      querywindow.lfm
  4. 1 1
      querywindow.lrs
  5. 80 52
      querywindow.pas

+ 115 - 91
TurboBird.lpi

@@ -55,7 +55,7 @@
         <PackageName Value="LCL"/>
       </Item5>
     </RequiredPackages>
-    <Units Count="111">
+    <Units Count="113">
       <Unit0>
         <Filename Value="TurboBird.lpr"/>
         <IsPartOfProject Value="True"/>
@@ -63,8 +63,8 @@
         <IsVisibleTab Value="True"/>
         <EditorIndex Value="0"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="10"/>
-        <CursorPos X="19" Y="28"/>
+        <TopLine Value="1"/>
+        <CursorPos X="30" Y="5"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
       </Unit0>
@@ -75,10 +75,10 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="main"/>
-        <EditorIndex Value="7"/>
+        <EditorIndex Value="8"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="408"/>
-        <CursorPos X="24" Y="436"/>
+        <TopLine Value="3253"/>
+        <CursorPos X="3" Y="3504"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
@@ -121,14 +121,14 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="QueryWindow"/>
-        <EditorIndex Value="1"/>
+        <EditorIndex Value="2"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="1116"/>
-        <CursorPos X="3" Y="1119"/>
+        <TopLine Value="1442"/>
+        <CursorPos X="10" Y="1460"/>
         <UsageCount Value="200"/>
         <Bookmarks Count="2">
-          <Item0 X="3" Y="628" ID="0"/>
-          <Item1 X="3" Y="1445" ID="1"/>
+          <Item0 X="3" Y="629" ID="0"/>
+          <Item1 X="3" Y="1473" ID="1"/>
         </Bookmarks>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
@@ -207,7 +207,7 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="NewTable"/>
-        <EditorIndex Value="6"/>
+        <EditorIndex Value="7"/>
         <WindowIndex Value="0"/>
         <TopLine Value="183"/>
         <CursorPos X="56" Y="215"/>
@@ -233,7 +233,7 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="EnterPass"/>
-        <EditorIndex Value="14"/>
+        <EditorIndex Value="17"/>
         <WindowIndex Value="0"/>
         <TopLine Value="4"/>
         <CursorPos X="18" Y="22"/>
@@ -248,7 +248,7 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="About"/>
-        <EditorIndex Value="11"/>
+        <EditorIndex Value="14"/>
         <WindowIndex Value="0"/>
         <TopLine Value="13"/>
         <CursorPos X="8" Y="19"/>
@@ -470,9 +470,9 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="DataModule"/>
         <UnitName Value="SysTables"/>
-        <EditorIndex Value="3"/>
+        <EditorIndex Value="4"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="725"/>
+        <TopLine Value="713"/>
         <CursorPos X="18" Y="749"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
@@ -552,7 +552,7 @@
         <Filename Value="scriptdb.pas"/>
         <IsPartOfProject Value="True"/>
         <UnitName Value="Scriptdb"/>
-        <EditorIndex Value="15"/>
+        <EditorIndex Value="18"/>
         <WindowIndex Value="0"/>
         <TopLine Value="491"/>
         <CursorPos X="46" Y="518"/>
@@ -594,7 +594,7 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="TableManage"/>
-        <EditorIndex Value="10"/>
+        <EditorIndex Value="13"/>
         <WindowIndex Value="0"/>
         <TopLine Value="304"/>
         <CursorPos X="39" Y="310"/>
@@ -641,10 +641,10 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="BackupRestore"/>
-        <EditorIndex Value="9"/>
+        <EditorIndex Value="10"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="1"/>
-        <CursorPos X="22" Y="55"/>
+        <TopLine Value="92"/>
+        <CursorPos X="3" Y="98"/>
         <UsageCount Value="200"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
@@ -652,10 +652,12 @@
       <Unit61>
         <Filename Value="unitfirebirdservices.pas"/>
         <UnitName Value="UnitFirebirdServices"/>
+        <EditorIndex Value="11"/>
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="22"/>
+        <UsageCount Value="24"/>
+        <Loaded Value="True"/>
       </Unit61>
       <Unit62>
         <Filename Value="/usr/share/fpcsrc/2.4.0/packages/fcl-db/src/sqldb/interbase/ibconnection.pp"/>
@@ -711,11 +713,11 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="CreateUser"/>
-        <EditorIndex Value="2"/>
+        <EditorIndex Value="3"/>
         <WindowIndex Value="0"/>
-        <TopLine Value="26"/>
+        <TopLine Value="12"/>
         <CursorPos X="24" Y="12"/>
-        <UsageCount Value="192"/>
+        <UsageCount Value="195"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit68>
@@ -726,11 +728,11 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="ChangePass"/>
-        <EditorIndex Value="12"/>
+        <EditorIndex Value="15"/>
         <WindowIndex Value="0"/>
         <TopLine Value="3"/>
         <CursorPos X="88" Y="14"/>
-        <UsageCount Value="191"/>
+        <UsageCount Value="194"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit69>
@@ -741,11 +743,11 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="PermissionManage"/>
-        <EditorIndex Value="5"/>
+        <EditorIndex Value="6"/>
         <WindowIndex Value="0"/>
         <TopLine Value="432"/>
         <CursorPos X="25" Y="289"/>
-        <UsageCount Value="189"/>
+        <UsageCount Value="192"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit70>
@@ -756,11 +758,11 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="SQLHistory"/>
-        <EditorIndex Value="13"/>
+        <EditorIndex Value="16"/>
         <WindowIndex Value="0"/>
         <TopLine Value="56"/>
         <CursorPos X="20" Y="89"/>
-        <UsageCount Value="174"/>
+        <UsageCount Value="177"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit71>
@@ -788,7 +790,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="51" Y="14"/>
-        <UsageCount Value="145"/>
+        <UsageCount Value="148"/>
       </Unit74>
       <Unit75>
         <Filename Value="/usr/lib/lazarus/0.9.30/lcl/comctrls.pp"/>
@@ -978,11 +980,11 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="dbInfo"/>
-        <EditorIndex Value="8"/>
+        <EditorIndex Value="9"/>
         <WindowIndex Value="0"/>
         <TopLine Value="64"/>
         <CursorPos X="16" Y="66"/>
-        <UsageCount Value="113"/>
+        <UsageCount Value="116"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit98>
@@ -1016,11 +1018,11 @@
         <HasResources Value="True"/>
         <ResourceBaseClass Value="Form"/>
         <UnitName Value="Comparison"/>
-        <EditorIndex Value="4"/>
+        <EditorIndex Value="5"/>
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="15" Y="255"/>
-        <UsageCount Value="100"/>
+        <UsageCount Value="103"/>
         <Loaded Value="True"/>
         <LoadedDesigner Value="True"/>
       </Unit102>
@@ -1056,7 +1058,7 @@
         <WindowIndex Value="0"/>
         <TopLine Value="1"/>
         <CursorPos X="1" Y="1"/>
-        <UsageCount Value="46"/>
+        <UsageCount Value="49"/>
       </Unit106>
       <Unit107>
         <Filename Value="../../../lazarus/lcl/interfaces/win32/win32object.inc"/>
@@ -1088,124 +1090,146 @@
         <CursorPos X="23" Y="23"/>
         <UsageCount Value="23"/>
       </Unit110>
+      <Unit111>
+        <Filename Value="/usr/share/fpcsrc/2.6.0/packages/ibase/src/ibase60.inc"/>
+        <EditorIndex Value="12"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="2388"/>
+        <CursorPos X="3" Y="2406"/>
+        <UsageCount Value="12"/>
+        <Loaded Value="True"/>
+      </Unit111>
+      <Unit112>
+        <Filename Value="/usr/share/fpcsrc/2.6.0/rtl/unix/dynlibs.inc"/>
+        <EditorIndex Value="1"/>
+        <WindowIndex Value="0"/>
+        <TopLine Value="15"/>
+        <CursorPos X="1" Y="28"/>
+        <UsageCount Value="12"/>
+        <Loaded Value="True"/>
+      </Unit112>
     </Units>
-    <JumpHistory Count="29" HistoryIndex="28">
+    <JumpHistory Count="30" HistoryIndex="29">
       <Position1>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="1404" Column="21" TopLine="1310"/>
+        <Filename Value="dbinfo.pas"/>
+        <Caret Line="64" Column="21" TopLine="41"/>
       </Position1>
       <Position2>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="1401" Column="3" TopLine="1398"/>
+        <Filename Value="dbinfo.pas"/>
+        <Caret Line="43" Column="8" TopLine="33"/>
       </Position2>
       <Position3>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="242" Column="32" TopLine="232"/>
+        <Filename Value="dbinfo.pas"/>
+        <Caret Line="81" Column="1" TopLine="73"/>
       </Position3>
       <Position4>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="679" Column="74" TopLine="664"/>
+        <Filename Value="dbinfo.pas"/>
+        <Caret Line="56" Column="21" TopLine="24"/>
       </Position4>
       <Position5>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="1429" Column="3" TopLine="1427"/>
+        <Filename Value="dbinfo.pas"/>
+        <Caret Line="129" Column="1" TopLine="99"/>
       </Position5>
       <Position6>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="803" Column="11" TopLine="649"/>
+        <Filename Value="main.pas"/>
+        <Caret Line="436" Column="24" TopLine="408"/>
       </Position6>
       <Position7>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="1418" Column="25" TopLine="1373"/>
+        <Filename Value="main.pas"/>
+        <Caret Line="3504" Column="3" TopLine="3502"/>
       </Position7>
       <Position8>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="761" Column="45" TopLine="742"/>
+        <Filename Value="backuprestore.pas"/>
+        <Caret Line="73" Column="3" TopLine="70"/>
       </Position8>
       <Position9>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="237" Column="10" TopLine="232"/>
+        <Filename Value="backuprestore.pas"/>
+        <Caret Line="98" Column="3" TopLine="92"/>
       </Position9>
       <Position10>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="615" Column="54" TopLine="600"/>
+        <Filename Value="unitfirebirdservices.pas"/>
+        <Caret Line="306" Column="3" TopLine="284"/>
       </Position10>
       <Position11>
         <Filename Value="querywindow.pas"/>
-        <Caret Line="1435" Column="17" TopLine="1424"/>
+        <Caret Line="1080" Column="61" TopLine="1074"/>
       </Position11>
       <Position12>
-        <Filename Value="querywindow.pas"/>
-        <Caret Line="687" Column="76" TopLine="661"/>
+        <Filename Value="TurboBird.lpr"/>
+        <Caret Line="27" Column="1" TopLine="10"/>
       </Position12>
       <Position13>
         <Filename Value="querywindow.pas"/>
-        <Caret Line="1447" Column="37" TopLine="1427"/>
+        <Caret Line="1083" Column="52" TopLine="1072"/>
       </Position13>
       <Position14>
         <Filename Value="querywindow.pas"/>
-        <Caret Line="633" Column="30" TopLine="615"/>
+        <Caret Line="419" Column="3" TopLine="417"/>
       </Position14>
       <Position15>
         <Filename Value="querywindow.pas"/>
-        <Caret Line="418" Column="3" TopLine="416"/>
+        <Caret Line="788" Column="22" TopLine="762"/>
       </Position15>
       <Position16>
         <Filename Value="querywindow.pas"/>
-        <Caret Line="346" Column="50" TopLine="72"/>
+        <Caret Line="830" Column="38" TopLine="786"/>
       </Position16>
       <Position17>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="64" Column="21" TopLine="41"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="823" Column="58" TopLine="635"/>
       </Position17>
       <Position18>
-        <Filename Value="main.pas"/>
-        <Caret Line="421" Column="3" TopLine="408"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="1087" Column="11" TopLine="1058"/>
       </Position18>
       <Position19>
-        <Filename Value="systables.pas"/>
-        <Caret Line="689" Column="3" TopLine="684"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="419" Column="3" TopLine="416"/>
       </Position19>
       <Position20>
-        <Filename Value="systables.pas"/>
-        <Caret Line="104" Column="25" TopLine="99"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="1438" Column="3" TopLine="1435"/>
       </Position20>
       <Position21>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="64" Column="21" TopLine="41"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="628" Column="3" TopLine="621"/>
       </Position21>
       <Position22>
-        <Filename Value="main.pas"/>
-        <Caret Line="486" Column="70" TopLine="469"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="1086" Column="1" TopLine="1068"/>
       </Position22>
       <Position23>
-        <Filename Value="main.pas"/>
-        <Caret Line="426" Column="65" TopLine="409"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="419" Column="3" TopLine="416"/>
       </Position23>
       <Position24>
-        <Filename Value="systables.pas"/>
-        <Caret Line="736" Column="25" TopLine="705"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="1438" Column="3" TopLine="1435"/>
       </Position24>
       <Position25>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="64" Column="21" TopLine="41"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="1438" Column="3" TopLine="1435"/>
       </Position25>
       <Position26>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="43" Column="8" TopLine="33"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="649" Column="15" TopLine="633"/>
       </Position26>
       <Position27>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="81" Column="1" TopLine="73"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="648" Column="1" TopLine="633"/>
       </Position27>
       <Position28>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="56" Column="21" TopLine="24"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="629" Column="9" TopLine="584"/>
       </Position28>
       <Position29>
-        <Filename Value="dbinfo.pas"/>
-        <Caret Line="129" Column="1" TopLine="99"/>
+        <Filename Value="querywindow.pas"/>
+        <Caret Line="147" Column="10" TopLine="138"/>
       </Position29>
+      <Position30>
+        <Filename Value="TurboBird.lpr"/>
+        <Caret Line="29" Column="28" TopLine="10"/>
+      </Position30>
     </JumpHistory>
   </ProjectOptions>
   <CompilerOptions>

+ 3 - 3
TurboBird.lpr

@@ -2,7 +2,7 @@
 {  TurboBird: FireBird database administration and management tool          }
 {  Developed by: Motaz Abdel Azeem http://code.sd/                          }
 {  Start development :  5.Dec.2009                                          }
-{  Last updated      :  2.Jan.2013                                          }
+{  Last updated      : 14.Feb.2013                                          }
 {  License           : GPL for GUI, LGPL for Units                          }
 {***************************************************************************}
 
@@ -25,8 +25,8 @@ uses
   sysutils, Comparison;
 
 const
-  Version = '0.9.8';
-  VersionDate = '2010 - Jan 2013';
+  Version = '0.9.9';
+  VersionDate = '2010 - Feb 2013';
 {$IFDEF Unix}
 {$DEFINE extdecl:=cdecl}
     fbclib = 'libfbclient.' + sharedsuffix;

+ 1 - 1
querywindow.lfm

@@ -13,7 +13,7 @@ object fmQueryWindow: TfmQueryWindow
   OnShow = FormShow
   PopupMenu = pmTab
   Position = poScreenCenter
-  LCLVersion = '1.0.4.0'
+  LCLVersion = '1.0.6.0'
   object Panel1: TPanel
     Left = 0
     Height = 60

+ 1 - 1
querywindow.lrs

@@ -6,7 +6,7 @@ LazarusResources.Add('TfmQueryWindow','FORMDATA',[
   +'fmQueryWindow'#12'ClientHeight'#3'Y'#2#11'ClientWidth'#3#208#2#5'Color'#7#6
   +'clForm'#4'Menu'#7#9'MainMenu1'#7'OnClose'#7#9'FormClose'#6'OnShow'#7#8'Form'
   +'Show'#9'PopupMenu'#7#5'pmTab'#8'Position'#7#14'poScreenCenter'#10'LCLVersio'
-  +'n'#6#7'1.0.4.0'#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#2'<'#3'Top'#2#0
+  +'n'#6#7'1.0.6.0'#0#6'TPanel'#6'Panel1'#4'Left'#2#0#6'Height'#2'<'#3'Top'#2#0
   +#5'Width'#3#208#2#5'Align'#7#5'alTop'#12'ClientHeight'#2'<'#11'ClientWidth'#3
   +#208#2#5'Color'#7#6'clForm'#11'ParentColor'#8#8'TabOrder'#2#1#0#7'TBitBtn'#7
   +'bbClose'#4'Left'#3#180#2#6'Height'#2#24#3'Top'#2#253#5'Width'#2#27#7'Anchor'

+ 80 - 52
querywindow.pas

@@ -144,7 +144,7 @@ type
     fStartLine: Integer;
     fList: TStringList;
     fQuery: string;
-    fQueryType: Integer;
+    fOrigQueryType: Integer;
     fFinished: Boolean;
     fQT: TQueryThread;
     fQueryPart: string;
@@ -624,11 +624,12 @@ var
   Command: string;
   IsDDL: Boolean;
   Affected: Integer;
+  fQueryType: Integer;
 begin
   try
 
     // Script
-    if (fQueryType = 3) then
+    if (fOrigQueryType = 3) then
     begin
       ExecuteScript(fQuery);
       Inc(fModifyCount);
@@ -646,9 +647,9 @@ begin
         Exit;
       end;
 
-      if EndLine < fStartLine then
+      {if EndLine < fStartLine then
         fStartLine:= fStartLine + 1
-      else
+      else}
         fStartLine:= EndLine + 1;
 
       if Trim(fQueryPart) <> '' then   // Select
@@ -784,6 +785,8 @@ begin
               fmeResult.Lines.Add('Rows affected: ' + Format('%3.0n', [Affected / 1]));
 
             end;
+            fmeResult.Lines.Add('----');
+            fmeResult.Lines.Add(fQueryPart);
 
           except
           on e: exception do
@@ -803,12 +806,30 @@ begin
         end
         else  // Script
         begin
+          try
           if ExecuteScript(fQueryPart) then
           begin
             Inc(fModifyCount);
             SqlType:= GetSQLType(fQueryPart, Command);
             fmMain.AddToSQLHistory(RegRec.Title, SqlType, fQueryPart);
           end;
+
+          except
+          on e: exception do
+          begin
+            if Assigned(fTab) then
+              fTab.TabVisible:= False;
+            fTab:= CreateResultTab(2, fSqlQuery, fSqlScript, fmeResult);
+            PageControl1.ActivePage:= fTab;
+            fmeResult.Text:= e.message;
+            fmeResult.Lines.Add(fQueryPart);
+            fmeResult.Lines.Add('--------');
+            fmeResult.Font.Color:= clRed;
+            fTab.Font.Color:= clRed;
+            fTab.ImageIndex:= 3;
+          end;
+        end;
+
         end;
         if (fModifyCount > 50) then
         if (MessageDlg('Commit', 'There are too many transactions, did you want to commit',
@@ -834,6 +855,7 @@ begin
     PageControl1.ActivePage:= fTab;
 
     fmeResult.Text:= e.message;
+    fmeResult.Lines.Add('--------');
     fmeResult.Lines.Add(fQueryPart);
     fmeResult.Font.Color:= clRed;
     fFinished:= True;
@@ -860,6 +882,8 @@ begin
     Result:= True;
     meResult.Lines.Text:= FormatDateTime('hh:nn:ss.z', Now) + ' - Script Executed. It takes (H:M:S.MS) ' +
       FormatDateTime('HH:nn:ss.z', Now - StartTime);
+    meResult.Lines.Add('--------');
+    meResult.Lines.Add(Script);
 
   except
   on e: exception do
@@ -870,6 +894,7 @@ begin
     ATab:= CreateResultTab(2, SqlQuery, SqlScript, meResult);
     PageControl1.ActivePage:= ATab;
     meResult.Text:= e.Message;
+    meResult.Lines.Add('--------');
     meResult.Lines.Add(Script);
     meResult.Font.Color:= clRed;
     ATab.Font.Color:= clRed;
@@ -956,7 +981,7 @@ begin
   MultiComment:= False;
   SQLSegment:= '';
   RealStartLine:= StartLine;
-  SecondRealStart:= -1;
+  SecondRealStart:= RealStartLine;
   Result:= False;
 
   // Remove comment
@@ -995,11 +1020,11 @@ begin
   // remove empty lines
   for i:= RealStartLine to QueryList.Count - 1 do
   begin
-     if Trim(QueryList[i]) <> '' then
-     begin
-       SecondRealStart:= i;
-       Break;
-     end;
+    if Trim(QueryList[i]) <> '' then
+    begin
+      SecondRealStart:= i;
+      Break;
+    end;
   end;
 
   // Get SQL type
@@ -1024,44 +1049,44 @@ begin
   // Concatinate
   SQLSegment:= '';
   BeginExist:= False;
-    for i:= SecondRealStart to QueryList.Count - 1 do
-    begin
-      if Pos('begin', Trim(LowerCase(QueryList[i]))) > 0 then
-        BeginExist:= True;
+  for i:= SecondRealStart to QueryList.Count - 1 do
+  begin
+    if Pos('begin', Trim(LowerCase(QueryList[i]))) > 0 then
+      BeginExist:= True;
 
-      SQLSegment:= SQLSegment + QueryList[i] + #10;
+    SQLSegment:= SQLSegment + QueryList[i] + #10;
 
-      if (QueryType in [1, 2]) and
-        (((Pos(';', QueryList[i]) > 0) and (Not BeginExist)) or
-        ((Pos('end', LowerCase(Trim(QueryList[i]))) = 1) and BeginExist)
-        or (i = QueryList.Count - 1)) then
+    if (QueryType in [1, 2]) and
+      (((Pos(';', QueryList[i]) > 0) and (Not BeginExist)) or
+      ((Pos('end', LowerCase(Trim(QueryList[i]))) = 1) and BeginExist)
+      or (i = QueryList.Count - 1)) then
+    begin
+      Result:= True;
+      if (not BeginExist) and (Pos(';', QueryList[i]) > 0) then
       begin
-        Result:= True;
-        if (not BeginExist) and (Pos(';', QueryList[i]) > 0) then
-        begin
-          QueryList[i]:= Trim(Copy(QueryList[i],  Pos(';', QueryList[i]) + 1, Length(QueryList[i])));
-          if QueryList[i] = '' then
-           EndLine:= i
-          else
-          begin
-            EndLine:= i - 1;
-            SQLSegment:= Trim(Copy(SQLSegment, 1, Pos(';',  SQLSegment)));
-          end;
-
-        end
+        QueryList[i]:= Trim(Copy(QueryList[i],  Pos(';', QueryList[i]) + 1, Length(QueryList[i])));
+        if QueryList[i] = '' then
+        EndLine:= i
         else
-          EndLine:= i;
-        Break;
+        begin
+          EndLine:= i - 1;
+          SQLSegment:= Trim(Copy(SQLSegment, 1, Pos(';',  SQLSegment)));
+        end;
       end
       else
-      if (QueryType = 3) and (i > SecondRealStart) and (Pos('setterm', LowerCase(StringReplace(QueryList[i],
-        ' ', '', [rfReplaceAll]))) > 0) then
-      begin
-        Result:= True;
         EndLine:= i;
-        Break;
-      end;
+
+      Break;
+    end
+    else
+    if (QueryType = 3) and ((i > SecondRealStart) and (Pos('setterm', LowerCase(StringReplace(QueryList[i],
+      ' ', '', [rfReplaceAll]))) > 0)) or (i = QueryList.Count - 1) then
+    begin
+      Result:= True;
+      EndLine:= i;
+      Break;
     end;
+  end;
 
 end;
 
@@ -1075,21 +1100,24 @@ end;
 procedure TfmQueryWindow.DBGrid1DblClick(Sender: TObject);
 begin
   if (Sender as TDBGrid).SelectedField.DataType in [ftBlob, ftMemo] then
-    ShowMessage((Sender as TDBGrid).SelectedField.AsString);
+    ShowMessage((Sender as TDBGrid).SelectedField.AsString)
+  else
+    ShowMessage((Sender as TDBGrid).SelectedField.KeyFields);
 end;
 
 procedure TfmQueryWindow.DBGridTitleClick(column: TColumn);
-var   SqlQuery: TSQLQuery;
+var
+  SqlQuery: TSQLQuery;
 //    indexoption : TIndexOptions;
 begin
-SqlQuery:= FindSqlQuery;
-if  SqlQuery <> Nil then
- if SqlQuery.IndexFieldNames = Column.Field.FieldName then
-  SqlQuery.IndexFieldNames := Column.Field.FieldName //+ 'DESC'
-//   indexoption :=[ixDescending];
-//   SqlQuery.AddIndex('',Column.Field.FieldName,indexoption,'');
- else
-  SqlQuery.IndexFieldNames := Column.Field.FieldName
+  SqlQuery:= FindSqlQuery;
+  if  SqlQuery <> Nil then
+  if SqlQuery.IndexFieldNames = Column.Field.FieldName then
+    SqlQuery.IndexFieldNames := Column.Field.FieldName //+ 'DESC'
+  //   indexoption :=[ixDescending];
+  //   SqlQuery.AddIndex('',Column.Field.FieldName,indexoption,'');
+  else
+    SqlQuery.IndexFieldNames := Column.Field.FieldName
 
 end;
 
@@ -1427,9 +1455,9 @@ begin
 
   // Get initial query type, it could be changed later in the next parts
   if aQueryType = 0 then // Auto
-    fQueryType:= GetQueryType(fQuery)
+    fOrigQueryType:= GetQueryType(fQuery)
   else
-    fQueryType:= aQueryType;
+    fOrigQueryType:= aQueryType;
 
   // Call execute query for each parts until finished
   fCnt:= 0;