{"id":325205,"date":"2021-06-20T15:00:31","date_gmt":"2021-06-20T15:00:31","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=325205"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=325205","title":{"rendered":"Delphi \u0438 SQLite. \u0410\u043b\u044c\u0442\u0435\u0440\u043d\u0430\u0442\u0438\u0432\u0430 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u043c \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c"},"content":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>SQLite \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0434\u043e\u0431\u043d\u044b\u043c, \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u042f \u0443\u0436\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u0435\u0431\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c &#8212; \u043a\u0430\u043a \u043c\u044b \u0432\u0441\u0435 \u0436\u0438\u043b\u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u0430\u044f \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0421\u0423\u0411\u0414.<\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043a\u0430\u043a Delphi-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 &#8212; \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440. \u042f \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u043b\u044e\u0431\u043b\u044e \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c Delphi-\u043a\u043e\u0434 \u0438 SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u044b. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c, \u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 Delphi \u0438 \u0442\u0435\u043a\u0441\u0442\u044b SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432.<\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u043d\u043e\u0441\u0438\u043c \u0432\u0435\u0441\u044c SQL-\u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0432 SQL-\u0444\u0430\u0439\u043b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u0440\u043a\u0435\u0440\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u043c\u0430\u0440\u043a\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0446\u0430. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043c\u0430\u0440\u043a\u0435\u0440\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 &#8212; <em>\/\/SQL \u0418\u043c\u044f\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b. <\/em>\u041c\u0430\u0440\u043a\u0435\u0440 \u043a\u043e\u043d\u0446\u0430 <em>&#8212; GO.<\/em><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 &#8212; \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 SQL-\u0444\u0430\u0439\u043b \u0438\u0437 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438-\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u0434\u0435\u0436\u0435\u0440 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e \u0435\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0432\u044b\u0437\u043e\u0432\u0443 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<p><strong>\u041a\u043e\u0434 \u044e\u043d\u0438\u0442\u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/strong><\/p>\n<pre><code class=\"delphi\">unit uSqlList;  interface  uses System.Classes, Winapi.Windows, System.SysUtils,   System.Generics.Collections;  type   TSqlList = class(TObjectDictionary&lt;string, TStrings&gt;)   const     SCRIPTS_RCNAME = 'SqlList';   private     function GetScripts(const AName: string): TStrings;     procedure FillList;     function GetItem(const AKey: string): string;   public     constructor Create;   public     property Sql[const Key: string]: string read GetItem; default;   end;  var   SqlList: TSqlList;  implementation  function GetStringResource(const AName: string): string; var   LResource: TResourceStream; begin   LResource := TResourceStream.Create(hInstance, AName, RT_RCDATA);    with TStringList.Create do     try       LoadFromStream(LResource);       Result := Text;     finally       Free;       LResource.Free;     end; end;  { TScriptList }  constructor TSqlList.Create; begin   inherited Create([doOwnsValues]);   FillList; end;  procedure TSqlList.FillList; var   LScripts: TStrings;   I: Integer;   S, LKey: string;   LStarted: Boolean;   LSql: TStrings; begin   LScripts := GetScripts(SCRIPTS_RCNAME);   try     LStarted := False;     LSql := nil;     for I := 0 to LScripts.Count - 1 do     begin       S := LScripts[I];       if LStarted then       begin         if S = 'GO' then         begin           LStarted := False;           Continue;         end         else if not S.StartsWith('\/\/') then           LSql.Add(S);       end       else       begin         LStarted := S.StartsWith('\/\/SQL ');         if LStarted then         begin           LKey := S.Substring(6);           LSql := TStringList.Create;           Add(LKey, LSql);         end;         Continue;       end;     end;   finally     LScripts.Free;   end; end;  function TSqlList.GetItem(const AKey: string): string; begin   Result := Items[AKey].Text; end;  function TSqlList.GetScripts(const AName: string): TStrings; begin   Result := TStringList.Create;   try     Result.Text := GetStringResource(AName);   except     FreeAndNil(Result);     raise;   end; end;  initialization  SqlList := TSqlList.Create;  finalization  FreeAndNil(SqlList);  end.<\/code><\/pre>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432:<\/strong><\/p>\n<pre><code class=\"sql\">\/\/SQL GetOrder SELECT * FROM Orders WHERE ID = :ID GO  \/\/SQL DeleteOpenedOrders DELETE FROM Orders WHERE Closed = 0 GO<\/code><\/pre>\n<p><strong>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443:<\/strong><\/p>\n<pre><code class=\"delphi\">{$R 'SqlList.res' '..\\Common\\DataBase\\SqlList.rc'}<\/code><\/pre>\n<p><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c TFDConnection:<\/strong><\/p>\n<pre><code class=\"delphi\">  Connection.ExecSQL(SqlList['GetOrder'], ['123']);<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0451. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u043c\u043d\u0435 \u043e\u043d\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u0441\u043e\u0432\u0435\u0442\u044b \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f. \u0420\u0430\u0434, \u0435\u0441\u043b\u0438 \u043c\u043e\u0439 \u043f\u043e\u0441\u0442\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/563690\/\"> https:\/\/habr.com\/ru\/post\/563690\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text_v2\" id=\"post-content-body\">\n<p>SQLite \u0432\u043e \u043c\u043d\u043e\u0433\u0438\u0445 \u0441\u043b\u0443\u0447\u0430\u044f\u0445 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0443\u0434\u043e\u0431\u043d\u044b\u043c, \u043d\u0435\u0437\u0430\u043c\u0435\u043d\u0438\u043c\u044b\u043c \u0438\u043d\u0441\u0442\u0440\u0443\u043c\u0435\u043d\u0442\u043e\u043c. \u042f \u0443\u0436\u0435 \u043d\u0435 \u043c\u043e\u0433\u0443 \u0441\u0435\u0431\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c &#8212; \u043a\u0430\u043a \u043c\u044b \u0432\u0441\u0435 \u0436\u0438\u043b\u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e. \u0422\u0435\u043c \u043d\u0435 \u043c\u0435\u043d\u0435\u0435, \u0435\u0441\u0442\u044c \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u0438 \u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438, \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u0442\u0435\u043c, \u0447\u0442\u043e \u044d\u0442\u043e \u043b\u0435\u0433\u043a\u0430\u044f \u0432\u0441\u0442\u0440\u0430\u0438\u0432\u0430\u0435\u043c\u0430\u044f \u0421\u0423\u0411\u0414.<\/p>\n<p>\u0421\u0430\u043c\u043e\u0435 \u0431\u043e\u043b\u044c\u0448\u043e\u0435 \u043d\u0435\u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u0434\u043b\u044f \u043c\u0435\u043d\u044f, \u043a\u0430\u043a Delphi-\u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430 &#8212; \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440. \u042f \u043e\u0447\u0435\u043d\u044c \u043d\u0435 \u043b\u044e\u0431\u043b\u044e \u0441\u043c\u0435\u0448\u0438\u0432\u0430\u0442\u044c Delphi-\u043a\u043e\u0434 \u0438 SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u044b. \u042d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u043e\u0434 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u043c\u0435\u043d\u0435\u0435 \u0447\u0438\u0442\u0430\u0431\u0435\u043b\u044c\u043d\u044b\u043c, \u0438 \u0437\u0430\u0442\u0440\u0443\u0434\u043d\u044f\u0435\u0442 \u0435\u0433\u043e \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u0421\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u0443\u0436\u043d\u043e \u043a\u0430\u043a-\u0442\u043e \u0440\u0430\u0437\u043d\u0435\u0441\u0442\u0438 \u043a\u043e\u0434 Delphi \u0438 \u0442\u0435\u043a\u0441\u0442\u044b SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432.<\/p>\n<p><strong>\u041f\u0440\u0435\u0434\u043b\u0430\u0433\u0430\u044e \u0441\u0432\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b<\/strong><\/p>\n<ul>\n<li>\n<p>\u0412\u044b\u043d\u043e\u0441\u0438\u043c \u0432\u0435\u0441\u044c SQL-\u043a\u043e\u0434 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0442\u0435\u0441\u0442\u043e\u0432\u044b\u0439 \u0444\u0430\u0439\u043b \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432, \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u043d\u044b\u0439 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443.<\/p>\n<\/li>\n<li>\n<p>\u0417\u0430\u043f\u0440\u043e\u0441\u044b \u0432 SQL-\u0444\u0430\u0439\u043b\u0435 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c \u043c\u0430\u0440\u043a\u0435\u0440\u0430\u043c\u0438 \u043d\u0430\u0447\u0430\u043b\u0430 \u0441 \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438 \u0438 \u043c\u0430\u0440\u043a\u0435\u0440\u0430\u043c\u0438 \u043a\u043e\u043d\u0446\u0430. \u0412 \u043c\u043e\u0451\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043c\u0430\u0440\u043a\u0435\u0440\u0430 \u043d\u0430\u0447\u0430\u043b\u0430 &#8212; <em>\/\/SQL \u0418\u043c\u044f\u041f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u044b. <\/em>\u041c\u0430\u0440\u043a\u0435\u0440 \u043a\u043e\u043d\u0446\u0430 <em>&#8212; GO.<\/em><\/p>\n<\/li>\n<li>\n<p>\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043a\u043b\u0430\u0441\u0441 &#8212; \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432. \u041f\u0440\u0438 \u0437\u0430\u0433\u0440\u0443\u0437\u043a\u0435 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043e\u043d \u0447\u0438\u0442\u0430\u0435\u0442 SQL-\u0444\u0430\u0439\u043b \u0438\u0437 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0438 \u0441\u043e\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u043d\u0435\u0433\u043e \u0441\u043f\u0438\u0441\u043e\u043a \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u0441 \u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u043c\u0438 \u0438\u043c\u0435\u043d\u0430\u043c\u0438-\u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430\u043c\u0438.<\/p>\n<\/li>\n<li>\n<p>\u0412 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u043c\u0435\u043d\u0434\u0435\u0436\u0435\u0440 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0442\u0435\u043a\u0441\u0442 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e \u0435\u0433\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0443 \u0434\u043b\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0435\u0433\u043e \u043f\u0435\u0440\u0435\u0434\u0430\u0447\u0438 \u043d\u0430 \u0432\u044b\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435.<\/p>\n<\/li>\n<\/ul>\n<p>\u0413\u043b\u0430\u0432\u043d\u0430\u044f \u0438\u0434\u0435\u044f &#8212; \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u0430 \u0438 \u043b\u0435\u0433\u043a\u043e\u0441\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0434\u043e\u0431\u043d\u0430\u044f \u0432\u044b\u0437\u043e\u0432\u0443 \u0445\u0440\u0430\u043d\u0438\u043c\u044b\u0445 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440 \u0438 \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u043e \u043f\u0440\u0438 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0438 \u0438 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 SQL-\u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432<\/p>\n<p><strong>\u041a\u043e\u0434 \u044e\u043d\u0438\u0442\u0430 \u043c\u0435\u043d\u0435\u0434\u0436\u0435\u0440\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432:<\/strong><\/p>\n<pre><code class=\"delphi\">unit uSqlList;  interface  uses System.Classes, Winapi.Windows, System.SysUtils,   System.Generics.Collections;  type   TSqlList = class(TObjectDictionary&lt;string, TStrings&gt;)   const     SCRIPTS_RCNAME = 'SqlList';   private     function GetScripts(const AName: string): TStrings;     procedure FillList;     function GetItem(const AKey: string): string;   public     constructor Create;   public     property Sql[const Key: string]: string read GetItem; default;   end;  var   SqlList: TSqlList;  implementation  function GetStringResource(const AName: string): string; var   LResource: TResourceStream; begin   LResource := TResourceStream.Create(hInstance, AName, RT_RCDATA);    with TStringList.Create do     try       LoadFromStream(LResource);       Result := Text;     finally       Free;       LResource.Free;     end; end;  { TScriptList }  constructor TSqlList.Create; begin   inherited Create([doOwnsValues]);   FillList; end;  procedure TSqlList.FillList; var   LScripts: TStrings;   I: Integer;   S, LKey: string;   LStarted: Boolean;   LSql: TStrings; begin   LScripts := GetScripts(SCRIPTS_RCNAME);   try     LStarted := False;     LSql := nil;     for I := 0 to LScripts.Count - 1 do     begin       S := LScripts[I];       if LStarted then       begin         if S = 'GO' then         begin           LStarted := False;           Continue;         end         else if not S.StartsWith('\/\/') then           LSql.Add(S);       end       else       begin         LStarted := S.StartsWith('\/\/SQL ');         if LStarted then         begin           LKey := S.Substring(6);           LSql := TStringList.Create;           Add(LKey, LSql);         end;         Continue;       end;     end;   finally     LScripts.Free;   end; end;  function TSqlList.GetItem(const AKey: string): string; begin   Result := Items[AKey].Text; end;  function TSqlList.GetScripts(const AName: string): TStrings; begin   Result := TStringList.Create;   try     Result.Text := GetStringResource(AName);   except     FreeAndNil(Result);     raise;   end; end;  initialization  SqlList := TSqlList.Create;  finalization  FreeAndNil(SqlList);  end.<\/code><\/pre>\n<p><strong>\u041f\u0440\u0438\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u043c\u043e\u0433\u043e \u0444\u0430\u0439\u043b\u0430 SQL-\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432:<\/strong><\/p>\n<pre><code class=\"sql\">\/\/SQL GetOrder SELECT * FROM Orders WHERE ID = :ID GO  \/\/SQL DeleteOpenedOrders DELETE FROM Orders WHERE Closed = 0 GO<\/code><\/pre>\n<p><strong>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u0430 \u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0432 \u043a \u043f\u0440\u043e\u0435\u043a\u0442\u0443:<\/strong><\/p>\n<pre><code class=\"delphi\">{$R 'SqlList.res' '..\\Common\\DataBase\\SqlList.rc'}<\/code><\/pre>\n<p><strong>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0441 \u043a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442\u043e\u043c TFDConnection:<\/strong><\/p>\n<pre><code class=\"delphi\">  Connection.ExecSQL(SqlList['GetOrder'], ['123']);<\/code><\/pre>\n<p>\u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e, \u044d\u0442\u043e \u0432\u0441\u0451. \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e \u0434\u0430\u043d\u043d\u043e\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u0435 \u0443\u0436\u0435 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430\u0445 \u0438 \u043c\u043d\u0435 \u043e\u043d\u043e \u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u044b\u043c. \u0411\u0443\u0434\u0443 \u0431\u043b\u0430\u0433\u043e\u0434\u0430\u0440\u0435\u043d \u0437\u0430 \u0441\u043e\u0432\u0435\u0442\u044b \u0438 \u0437\u0430\u043c\u0435\u0447\u0430\u043d\u0438\u044f. \u0420\u0430\u0434, \u0435\u0441\u043b\u0438 \u043c\u043e\u0439 \u043f\u043e\u0441\u0442\u043e \u043a\u043e\u043c\u0443-\u0442\u043e \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u043b\u0435\u0437\u0435\u043d!<\/p>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/563690\/\"> https:\/\/habr.com\/ru\/post\/563690\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-325205","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325205","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=325205"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/325205\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=325205"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=325205"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=325205"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}