home *** CD-ROM | disk | FTP | other *** search
/ Chip 2001 October / Chip_2001-10_cd1.bin / zkuste / delphi / nastroje / SNAPPER.ZIP / mainp.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  2001-07-23  |  19.4 KB  |  673 lines

  1. unit mainp;
  2.  
  3. interface
  4.  
  5. uses
  6.   Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  7.   fcOutlookList, fcButton, fcImgBtn, fcShapeBtn, Menus, ExtCtrls,
  8.   fcClearPanel, fcButtonGroup, fcOutlookBar, OraScript, Db, MemDS,
  9.   DBAccess, Ora, StdCtrls, Grids, DBGrids, ComCtrls, 
  10.    Buttons, DBCtrls,  FileCtrl;
  11.  
  12. type
  13.   TfrmMain = class(TForm)
  14.     OraSession1: TOraSession;
  15.     OraQuery1: TOraQuery;
  16.     OraScript1: TOraScript;
  17.     MainMenu1: TMainMenu;
  18.     Output1: TMenuItem;
  19.     Screen1: TMenuItem;
  20.     Panel2: TPanel;
  21.     Panel3: TPanel;
  22.     fcOutlookBar1: TfcOutlookBar;
  23.     GeneralBTN: TfcShapeBtn;
  24.     TableSpaceBTN: TfcShapeBtn;
  25.     RollbackBTN: TfcShapeBtn;
  26.     Users: TfcShapeBtn;
  27.     TableIndex: TfcShapeBtn;
  28.     Objects: TfcShapeBtn;
  29.     HitMiss: TfcShapeBtn;
  30.     DiskIO: TfcShapeBtn;
  31.     FullTable: TfcShapeBtn;
  32.     Datadict: TfcShapeBtn;
  33.     CursorSQL: TfcShapeBtn;
  34.     Locks: TfcShapeBtn;
  35.     SessionStats: TfcShapeBtn;
  36.     SharedPool: TfcShapeBtn;
  37.     RedoLogs: TfcShapeBtn;
  38.     TwoPhaseCommits: TfcShapeBtn;
  39.     Miscellaneous: TfcShapeBtn;
  40.     fcOutlookBar1OutlookList1: TfcOutlookList;
  41.     fcOutlookBar1OutlookList2: TfcOutlookList;
  42.     fcOutlookBar1OutlookList3: TfcOutlookList;
  43.     fcOutlookBar1OutlookList4: TfcOutlookList;
  44.     fcOutlookBar1OutlookList5: TfcOutlookList;
  45.     fcOutlookBar1OutlookList6: TfcOutlookList;
  46.     fcOutlookBar1OutlookList7: TfcOutlookList;
  47.     fcOutlookBar1OutlookList8: TfcOutlookList;
  48.     fcOutlookBar1OutlookList9: TfcOutlookList;
  49.     fcOutlookBar1OutlookList10: TfcOutlookList;
  50.     fcOutlookBar1OutlookList11: TfcOutlookList;
  51.     fcOutlookBar1OutlookList12: TfcOutlookList;
  52.     fcOutlookBar1OutlookList13: TfcOutlookList;
  53.     fcOutlookBar1OutlookList14: TfcOutlookList;
  54.     fcOutlookBar1OutlookList15: TfcOutlookList;
  55.     fcOutlookBar1OutlookList16: TfcOutlookList;
  56.     fcOutlookBar1OutlookList17: TfcOutlookList;
  57.     Panel1: TPanel;
  58.     Panel4: TPanel;
  59.     Splitter1: TSplitter;
  60.     Memo1: TMemo;
  61.     Connection1: TMenuItem;
  62.     Oracleclient1: TMenuItem;
  63.     Direct1: TMenuItem;
  64.     Disconnect1: TMenuItem;
  65.     N2: TMenuItem;
  66.     Exit2: TMenuItem;
  67.     StatusBar1: TStatusBar;
  68.     OraDataSource1: TOraDataSource;
  69.     ConnectDialog1: TConnectDialog;
  70.     Help1: TMenuItem;
  71.     About1: TMenuItem;
  72.     Usage1: TMenuItem;
  73.     fcOutlookBar1OutlookList18: TfcOutlookList;
  74.     Partitions: TfcShapeBtn;
  75.     Panel5: TPanel;
  76.     Panel6: TPanel;
  77.     DTLabel: TLabel;
  78.     ServerLabel: TLabel;
  79.     QryLabel: TLabel;
  80.     SpeedButton1: TSpeedButton;
  81.     ToTextBTN: TSpeedButton;
  82.     ToHTMLBTN: TSpeedButton;
  83.     DBNavigator1: TDBNavigator;
  84.     DBGrid1: TDBGrid;
  85.     Batch1: TMenuItem;
  86.     SQLbtn: TSpeedButton;
  87.     SpeedButton2: TSpeedButton;
  88.     procedure fcOutlookBar1OutlookList1ItemClick(
  89.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  90.     procedure Oracleclient1Click(Sender: TObject);
  91.     procedure Exit2Click(Sender: TObject);
  92.     procedure Direct1Click(Sender: TObject);
  93.     procedure Disconnect1Click(Sender: TObject);
  94.     procedure fcOutlookBar1OutlookList2ItemClick(
  95.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  96.     procedure fcOutlookBar1OutlookList3ItemClick(
  97.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  98.     procedure fcOutlookBar1OutlookList4ItemClick(
  99.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  100.     procedure fcOutlookBar1OutlookList5ItemClick(
  101.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  102.     procedure fcOutlookBar1OutlookList6ItemClick(
  103.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  104.     procedure fcOutlookBar1OutlookList18ItemClick(
  105.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  106.     procedure fcOutlookBar1OutlookList7ItemClick(
  107.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  108.     procedure fcOutlookBar1OutlookList8ItemClick(
  109.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  110.     procedure fcOutlookBar1OutlookList9ItemClick(
  111.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  112.     procedure fcOutlookBar1OutlookList10ItemClick(
  113.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  114.     procedure fcOutlookBar1OutlookList11ItemClick(
  115.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  116.     procedure fcOutlookBar1OutlookList12ItemClick(
  117.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  118.     procedure fcOutlookBar1OutlookList13ItemClick(
  119.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  120.     procedure fcOutlookBar1OutlookList14ItemClick(
  121.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  122.     procedure fcOutlookBar1OutlookList15ItemClick(
  123.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  124.     procedure fcOutlookBar1OutlookList16ItemClick(
  125.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  126.     procedure fcOutlookBar1OutlookList17ItemClick(
  127.       OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  128.     procedure SpeedButton1Click(Sender: TObject);
  129.     procedure ToTextBTNClick(Sender: TObject);
  130.     procedure ToHTMLBTNClick(Sender: TObject);
  131.     procedure Batch1Click(Sender: TObject);
  132.     procedure OraScript1Error(Sender: TObject; E: Exception; SQL: String;
  133.       var Action: TErrorAction);
  134.     procedure SQLbtnClick(Sender: TObject);
  135.     procedure SpeedButton2Click(Sender: TObject);
  136.     procedure FormCreate(Sender: TObject);
  137.     procedure About1Click(Sender: TObject);
  138.   private
  139.     { Private declarations }
  140.   public
  141.     { Public declarations }
  142.   end;
  143.  
  144.  
  145.  
  146.  
  147. var
  148.   frmMain: TfrmMain;
  149.   explainSlist : TStringList;
  150.   query_no : integer;        // the nr of the current query
  151.   batch    : boolean;        // is this a batch process?
  152.  
  153. procedure ExportToAscii;
  154. procedure ExportToHTML;
  155.  
  156. implementation
  157.  
  158. uses snapsql, batchp, aboutp;
  159.  
  160.  
  161. {$R *.DFM}
  162.  
  163. procedure CheckOutputDir;
  164. begin
  165.   if not DirectoryExists('output') then
  166.     if not CreateDir('Output') then
  167.     raise Exception.Create('Cannot create output directory');
  168.  
  169. end;
  170.  
  171.  
  172. procedure TfrmMain.Oracleclient1Click(Sender: TObject);
  173. begin
  174.   OraSession1.Connected := True;
  175.   If OraSession1.Connected then
  176.   begin
  177.     CheckOutputDir;
  178.     OracleClient1.Enabled := False;
  179.     Direct1.Enabled := False;
  180.     Disconnect1.Enabled := True;
  181.     fcOutLookBar1.Visible := True;
  182.     Batch1.Enabled := True;
  183.   end;
  184. end;
  185.  
  186. procedure TfrmMain.Direct1Click(Sender: TObject);
  187. begin
  188.   OraSession1.ConnectDialog := Nil;
  189.   OraSession1.Options.Net := True;
  190.   OraSession1.Connected := True;
  191.   If OraSession1.Connected then
  192.   begin
  193.     CheckOutputDir;
  194.     OracleClient1.Enabled := False;
  195.     Direct1.Enabled := False;
  196.     Disconnect1.Enabled := True;
  197.     fcOutLookBar1.Visible := True;
  198.     Batch1.Enabled := True;
  199.   end
  200.   else
  201.   begin
  202.     OraSession1.Options.Net := False;
  203.     OraSession1.ConnectDialog := ConnectDialog1;
  204.   end;
  205. end;
  206.  
  207. procedure TfrmMain.Disconnect1Click(Sender: TObject);
  208. begin
  209.   OraSession1.Connected := False;
  210.   OraSession1.Options.Net := False;
  211.   OraSession1.ConnectDialog := ConnectDialog1;
  212.   OracleClient1.Enabled := True;
  213.   Direct1.Enabled := True;
  214.   Disconnect1.Enabled := False;
  215.   fcOutLookBar1.Visible := False;
  216.   Batch1.Enabled := False;
  217. end;
  218.  
  219. procedure TfrmMain.Exit2Click(Sender: TObject);
  220. begin
  221.   If OraSession1.Connected then
  222.   begin
  223.     Delete_Views;
  224.     OraSession1.Disconnect;
  225.   end;
  226.   Halt;
  227. end;
  228.  
  229. procedure TfrmMain.fcOutlookBar1OutlookList1ItemClick(
  230.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  231.  
  232. begin
  233. // general
  234. //  ShowMessage('Tag :'+IntToStr(Item.Tag));
  235.   case Item.Tag of
  236.     0 : Snap_SQL(0,OraQuery1,Memo1);
  237.     1 : Snap_SQL(1,OraQuery1,Memo1);
  238.     2 : Snap_SQL(2,OraQuery1,Memo1);
  239.     3 : Snap_SQL(3,OraQuery1,Memo1);
  240.     4 : Snap_SQL(4,OraQuery1,Memo1);
  241.     5 : Snap_SQL(5,OraQuery1,Memo1);
  242.     6 : Snap_SQL(6,OraQuery1,Memo1);
  243.     7 : Snap_SQL(7,OraQuery1,Memo1);
  244.     8 : Snap_SQL(8,OraQuery1,Memo1);
  245.     9 : Snap_SQL(9,OraQuery1,Memo1);
  246.   end;
  247.  
  248. end;
  249.  
  250.  
  251. procedure TfrmMain.fcOutlookBar1OutlookList2ItemClick(
  252.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  253. begin
  254. // tablespaces
  255. //  ShowMessage('Tag :'+IntToStr(Item.Tag));
  256.   case Item.Tag of
  257.     0 : Snap_SQL(10,OraQuery1,Memo1);
  258.     1 : Snap_SQL(11,OraQuery1,Memo1);
  259.     2 : Snap_SQL(12,OraQuery1,Memo1);
  260.     3 : begin
  261.           Create_View(1);
  262.           Create_View(2);
  263.           Snap_SQL(13,OraQuery1,Memo1);
  264.         end;  
  265.     4 : Snap_SQL(14,OraQuery1,Memo1);
  266.     5 : Snap_SQL(15,OraQuery1,Memo1);
  267.     6 : Snap_SQL(16,OraQuery1,Memo1);
  268.     7 : Snap_SQL(17,OraQuery1,Memo1);
  269.   end;
  270. end;
  271.  
  272.  
  273.  
  274.  
  275. procedure TfrmMain.fcOutlookBar1OutlookList3ItemClick(
  276.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  277. begin
  278. // rollbacks
  279.   case Item.Tag of
  280.     0 : Snap_SQL(18,OraQuery1,Memo1);
  281.     1 : Snap_SQL(19,OraQuery1,Memo1);
  282.     2 : Snap_SQL(20,OraQuery1,Memo1);
  283.     3 : Snap_SQL(21,OraQuery1,Memo1);
  284.     4 : Snap_SQL(22,OraQuery1,Memo1);
  285.   end;
  286. end;
  287.  
  288. procedure TfrmMain.fcOutlookBar1OutlookList4ItemClick(
  289.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  290. begin
  291. // Users
  292.   case Item.Tag of
  293.     0 : Snap_SQL(23,OraQuery1,Memo1);
  294.     1 : Snap_SQL(24,OraQuery1,Memo1);
  295.     2 : Snap_SQL(25,OraQuery1,Memo1);
  296.     3 : Snap_SQL(26,OraQuery1,Memo1);
  297.     4 : Snap_SQL(27,OraQuery1,Memo1);
  298.     5 : Snap_SQL(28,OraQuery1,Memo1);
  299.     6 : Snap_SQL(29,OraQuery1,Memo1);
  300.     7 : Snap_SQL(30,OraQuery1,Memo1);
  301.     8 : Snap_SQL(31,OraQuery1,Memo1);
  302.   end;
  303. end;
  304.  
  305. procedure TfrmMain.fcOutlookBar1OutlookList5ItemClick(
  306.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  307. begin
  308. // Tables & indexes
  309.   case Item.Tag of
  310.     0 : Snap_SQL(32,OraQuery1,Memo1);
  311.     1 : Snap_SQL(33,OraQuery1,Memo1);
  312.     2 : Snap_SQL(34,OraQuery1,Memo1);
  313.     3 : begin
  314.           Create_view(3);
  315.           Snap_SQL(35,OraQuery1,Memo1);
  316.         end;  
  317.     4 : begin
  318.           Create_view(4);
  319.           Snap_SQL(36,OraQuery1,Memo1);
  320.         end;  
  321.     5 : Snap_SQL(37,OraQuery1,Memo1);
  322.     6 : Snap_SQL(38,OraQuery1,Memo1);
  323.     7 : Snap_SQL(39,OraQuery1,Memo1);
  324.     8 : Snap_SQL(40,OraQuery1,Memo1);
  325.     9 : Snap_SQL(41,OraQuery1,Memo1);
  326.    10 : begin
  327.           Create_View(5);
  328.           Snap_SQL(42,OraQuery1,Memo1);
  329.         end;
  330.    11 : Snap_SQL(43,OraQuery1,Memo1);
  331.    12 : Snap_SQL(44,OraQuery1,Memo1);
  332.    13 : Snap_SQL(45,OraQuery1,Memo1);
  333.    14 : Snap_SQL(46,OraQuery1,Memo1);
  334.    15 : Snap_SQL(47,OraQuery1,Memo1);
  335.   end;
  336. end;
  337.  
  338.  
  339. procedure TfrmMain.fcOutlookBar1OutlookList18ItemClick(
  340.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  341. begin
  342. // Partitions
  343.   case Item.Tag of
  344.     0 : Snap_SQL(48,OraQuery1,Memo1);
  345.     1 : Snap_SQL(49,OraQuery1,Memo1);
  346.     2 : Snap_SQL(50,OraQuery1,Memo1);
  347.     3 : Snap_SQL(51,OraQuery1,Memo1);
  348.     4 : Snap_SQL(52,OraQuery1,Memo1);
  349.   end;
  350. end;
  351.  
  352. procedure TfrmMain.fcOutlookBar1OutlookList6ItemClick(
  353.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  354. begin
  355. // Objects
  356.   case Item.Tag of
  357.     0 : Snap_SQL(53,OraQuery1,Memo1);
  358.     1 : Snap_SQL(54,OraQuery1,Memo1);
  359.     2 : Snap_SQL(55,OraQuery1,Memo1);
  360.     3 : Snap_SQL(56,OraQuery1,Memo1);
  361.     4 : Snap_SQL(57,OraQuery1,Memo1);
  362.     5 : Snap_SQL(58,OraQuery1,Memo1);
  363.     6 : Snap_SQL(59,OraQuery1,Memo1);
  364.     7 : Snap_SQL(60,OraQuery1,Memo1);
  365.     8 : Snap_SQL(61,OraQuery1,Memo1);
  366.   end;
  367. end;
  368.  
  369. procedure TfrmMain.fcOutlookBar1OutlookList7ItemClick(
  370.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  371. begin
  372. // Hit & Miss Ratio's
  373.   case Item.Tag of
  374.     0 : Snap_SQL(62,OraQuery1,Memo1);
  375.     1 : Snap_SQL(63,OraQuery1,Memo1);
  376.     2 : Snap_SQL(64,OraQuery1,Memo1);
  377.   end;
  378. end;
  379.  
  380. procedure TfrmMain.fcOutlookBar1OutlookList8ItemClick(
  381.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  382. begin
  383. // Disk I/O, Events & Waits
  384.   case Item.Tag of
  385.     0 :  Snap_SQL(65,OraQuery1,Memo1);
  386.     1 :  Snap_SQL(66,OraQuery1,Memo1);
  387.     2 :  Snap_SQL(67,OraQuery1,Memo1);
  388.     3 :  Snap_SQL(68,OraQuery1,Memo1);
  389.     4 :  Snap_SQL(69,OraQuery1,Memo1);
  390.     5 :  begin
  391.            Create_view(6);
  392.            Snap_SQL(70,OraQuery1,Memo1);
  393.          end;
  394.  
  395.   end;
  396. end;
  397.  
  398. procedure TfrmMain.fcOutlookBar1OutlookList9ItemClick(
  399.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  400. begin
  401. // Full Table Scans
  402.   case Item.Tag of
  403.     0 :  Snap_SQL(71,OraQuery1,Memo1);
  404.     1 :  Begin
  405.            Create_view(7);
  406.            Snap_SQL(72,OraQuery1,Memo1);
  407.          End;
  408.     2 :  Begin
  409.            Create_view(7);
  410.            Snap_SQL(73,OraQuery1,Memo1);
  411.          End;
  412.   end;
  413. end;
  414.  
  415. procedure TfrmMain.fcOutlookBar1OutlookList10ItemClick(
  416.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  417. begin
  418. // Data Dictionary
  419.   case Item.Tag of
  420.     0 :  Snap_SQL(74,OraQuery1,Memo1);
  421.     1 :  Snap_SQL(75,OraQuery1,Memo1);
  422.   end;
  423. end;
  424.  
  425. procedure TfrmMain.fcOutlookBar1OutlookList11ItemClick(
  426.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  427. begin
  428. // Cursor & SQL processing
  429.   case Item.Tag of
  430.     0 : Snap_SQL(76,OraQuery1,Memo1);
  431.     1 : Snap_SQL(77,OraQuery1,Memo1);
  432.     2 : Snap_SQL(78,OraQuery1,Memo1);
  433.     3 : Snap_SQL(79,OraQuery1,Memo1);
  434.     4 : Snap_SQL(80,OraQuery1,Memo1);
  435.     5 : Begin
  436.           Create_view(8);
  437.           Snap_SQL(81,OraQuery1,Memo1);
  438.         end;
  439.     6 : Begin
  440.           Create_view(8);
  441.           Snap_SQL(82,OraQuery1,Memo1);
  442.         End;
  443.     7 : Begin
  444.           Create_view(8);
  445.           Snap_SQL(83,OraQuery1,Memo1);
  446.         End;
  447.   end;
  448. end;
  449.  
  450. procedure TfrmMain.fcOutlookBar1OutlookList12ItemClick(
  451.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  452. begin
  453. // Locks
  454.   case Item.Tag of
  455.     0 :  Snap_SQL(84,OraQuery1,Memo1);
  456.     1 :  Snap_SQL(85,OraQuery1,Memo1);
  457.   end;
  458.  
  459. end;
  460.  
  461.  
  462.  
  463. procedure TfrmMain.fcOutlookBar1OutlookList13ItemClick(
  464.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  465. begin
  466. // Session statistics
  467.   case Item.Tag of
  468.     0 : Snap_SQL(86,OraQuery1,Memo1);
  469.     1 : Snap_SQL(87,OraQuery1,Memo1);
  470.     2 : Snap_SQL(88,OraQuery1,Memo1);
  471.     3 : Snap_SQL(89,OraQuery1,Memo1);
  472.     4 : Snap_SQL(90,OraQuery1,Memo1);
  473.     5 : begin
  474.           Create_view(9);
  475.           Snap_SQL(91,OraQuery1,Memo1);
  476.         end;
  477.   end;
  478. end;
  479.  
  480. procedure TfrmMain.fcOutlookBar1OutlookList14ItemClick(
  481.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  482. begin
  483. // Shared Pool
  484.   case Item.Tag of
  485.     0 : Snap_SQL(92,OraQuery1,Memo1);
  486.     1 : Snap_SQL(93,OraQuery1,Memo1);
  487.     2 : Snap_SQL(94,OraQuery1,Memo1);
  488.     3 : Snap_SQL(95,OraQuery1,Memo1);
  489.     4 : Snap_SQL(96,OraQuery1,Memo1);
  490.     5 : Snap_SQL(97,OraQuery1,Memo1);
  491.     6 : Snap_SQL(98,OraQuery1,Memo1);
  492.   end;
  493. end;
  494.  
  495. procedure TfrmMain.fcOutlookBar1OutlookList15ItemClick(
  496.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  497. begin
  498. // Redo Logs
  499.   case Item.Tag of
  500.     0 : Snap_SQL(99,OraQuery1,Memo1);
  501.     1 : Snap_SQL(100,OraQuery1,Memo1);
  502.     2 : Snap_SQL(101,OraQuery1,Memo1);
  503.     3 : Snap_SQL(102,OraQuery1,Memo1);
  504.   end;
  505. end;
  506.  
  507. procedure TfrmMain.fcOutlookBar1OutlookList16ItemClick(
  508.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  509. begin
  510. // Two phase commits
  511.   case Item.Tag of
  512.     0 : Snap_SQL(103,OraQuery1,Memo1);
  513.     1 : Snap_SQL(104,OraQuery1,Memo1);
  514.   end;
  515.  
  516. end;
  517.  
  518. procedure TfrmMain.fcOutlookBar1OutlookList17ItemClick(
  519.   OutlookList: TfcCustomOutlookList; Item: TfcOutlookListItem);
  520. begin
  521. // Miscellaneous
  522.   case Item.Tag of
  523.     0 : Snap_SQL(105,OraQuery1,Memo1);
  524.     1 : Snap_SQL(106,OraQuery1,Memo1);
  525.     2 : Snap_SQL(107,OraQuery1,Memo1);
  526.   end;
  527.  
  528. end;
  529.  
  530. procedure TfrmMain.SpeedButton1Click(Sender: TObject);
  531. begin
  532.   Snap_SQL(Query_no,OraQuery1,Memo1);
  533. end;
  534.  
  535. Procedure ExportToAscii;
  536. var f: Text;
  537.     i,j : integer;
  538. begin
  539. // filename : queryno.txt
  540.   AssignFile( F,'output\'+IntToStr(query_no)+'.txt' );
  541.   Rewrite( f );
  542.    j := frmMain.OraQuery1.Fields.Count - 1;
  543.   for i := 0 to j do
  544.   begin
  545.     write( f,  frmMain.OraQuery1.Fields.Fields[i].DisplayName );
  546.     if i<>j then write( f,' , ');
  547.   end;
  548.   writeln( f );
  549.   frmMain.OraQuery1.First;
  550.   repeat
  551.     for i := 0 to j do
  552.     begin
  553.       write( f,  frmMain.OraQuery1.Fields.Fields[i].DisplayText );
  554.       if i<>j then write( f,' , ');
  555.     end;
  556.     writeln( f );
  557.     frmMain.OraQuery1.Next;
  558.   until frmMain.OraQuery1.Eof;
  559.   Close(F);
  560. end;
  561.  
  562. Procedure ExportToHTML;
  563. var f: Text;
  564.     i,j : integer;
  565. begin
  566. // filename : queryno.txt
  567.   AssignFile( F,'output\'+IntToStr(query_no)+'.html' );
  568.   Rewrite( f );
  569.   writeln(f,'<HTML>');
  570.   writeln(f,'<HEAD>');
  571.   writeln(f,'<META HTTP-EQUIV="Expires" CONTENT="Mon, 06 Jan 1990 00:00:01 GMT">');
  572.   writeln(f,'<META HTTP-EQUIV="Pragma" CONTENT="no-cache">');
  573.   writeln(f,'<TITLE>'+qry_label[query_no]+'</TITLE>');
  574.   writeln(f,'</HEAD>');
  575.   writeln(f,'<BODY BGCOLOR="#C0C0C0">');
  576.   writeln(f,'<CENTER><FONT FACE="Arial" SIZE="2">');
  577.   writeln(f,'<TABLE WIDTH="100%">');
  578.   writeln(f,'<TR>');
  579.   writeln(f,'<TD><B><FONT FACE="Arial" SIZE="2">'+DateTimeToStr(Now)+'</FONT></B></TD>');
  580.   writeln(f,'<TD ALIGN="RIGHT"><B><FONT FACE="Arial" SIZE="2">'+frmMain.OraSession1.Server+'</FONT></B></TD>');
  581.   writeln(f,'</TR>');
  582.   writeln(f,'</TABLE><BR>');
  583.   writeln(f,'<TABLE BORDER=1 CELLPADDING=5>');
  584.   writeln(f,'<TR>');
  585.   writeln(f,'<TD ALIGN="CENTER" BGCOLOR="#FFFFFF" COLSPAN='+IntToStr(frmMain.OraQuery1.Fields.Count)+'>');
  586.   writeln(f,'<FONT SIZE="4"><B>'+qry_label[query_no]+'</B></FONT>');
  587.   writeln(f,'</TD>');
  588.   writeln(f,'</TR>');
  589.   writeln(f,'<TR>');
  590.   j := frmMain.OraQuery1.Fields.Count - 1;
  591.   for i := 0 to j do
  592.   begin
  593.     writeln( f,'<TD ALIGN="RIGHT" BGCOLOR="#CCCC99"><FONT FACE="Arial" SIZE="2"><B>'+ frmMain.OraQuery1.Fields.Fields[i].DisplayName+'</B></FONT></TD>' );
  594.   end;
  595.   writeln( f, '</TR>' );
  596.   frmMain.OraQuery1.First;
  597.   repeat
  598.     writeln(f,'<TR>');
  599.     for i := 0 to j do
  600.     begin
  601.       writeln( f, '<TD><FONT FACE="Arial" SIZE="2">'+ frmMain.OraQuery1.Fields.Fields[i].DisplayText+'</FONT></TD>' );
  602.  
  603.     end;
  604.     writeln( f, '</TR>' );
  605.     frmMain.OraQuery1.Next;
  606.   until frmMain.OraQuery1.Eof;
  607.   writeln(f,'</TABLE>');
  608.   writeln(f,'<BR><BR><BR><BR>');
  609.   writeln(f,'</TABLE>');
  610.   writeln(f,'<b>OraSnapper version 1.0</b><br>');
  611.   writeln(f,'based upon <a href="http://www.stewartmc.com/oracle/orasnap/">Orasnap 2.4.0</a>');
  612.   Close(F);
  613. end;
  614.  
  615.  
  616. procedure TfrmMain.ToTextBTNClick(Sender: TObject);
  617. begin
  618.   ExportToAscii;
  619. end;
  620.  
  621. procedure TfrmMain.ToHTMLBTNClick(Sender: TObject);
  622. begin
  623.   ExportToHTML;
  624. end;
  625.  
  626. procedure TfrmMain.Batch1Click(Sender: TObject);
  627. begin
  628.   Application.CreateForm(TfrmBatch, frmBatch);
  629.   frmBatch.ShowModal;
  630.   Batch := False;
  631. end;
  632.  
  633. procedure TfrmMain.OraScript1Error(Sender: TObject; E: Exception;
  634.   SQL: String; var Action: TErrorAction);
  635. begin
  636.   Action := eaContinue;
  637. end;
  638.  
  639. procedure TfrmMain.SQLbtnClick(Sender: TObject);
  640. begin
  641.  if OraQuery1.Active then
  642.  begin
  643.    Memo1.Clear;
  644.    Memo1.Text := OraQuery1.SQL.Text;
  645.  end;
  646. end;
  647.  
  648. procedure TfrmMain.SpeedButton2Click(Sender: TObject);
  649. begin
  650.   if OraQuery1.Active then
  651.   Begin
  652.     Memo1.Clear;
  653.     if query_no < 100 then
  654.       Memo1.Text := Create_explain(query_no).text
  655.     else
  656.       Memo1.Text := Create_explain2(query_no).Text;
  657.   end;
  658. end;
  659.  
  660. procedure TfrmMain.FormCreate(Sender: TObject);
  661. begin
  662.   Batch := False;
  663. end;
  664.  
  665. procedure TfrmMain.About1Click(Sender: TObject);
  666. begin
  667.   Application.CreateForm(TAboutBox, AboutBox);
  668.   AboutBox.ShowModal;
  669. end;
  670.  
  671. end.
  672.  
  673.