-
MY PROJECTS
-
Recent Posts
- SQL.How can you compare two nullable values safely, and how does IS DISTINCT FROM differ from <>?
- SQL.How are NULL values ordered by ORDER BY, how do defaults differ between databases, and how can you control their placement?
- SQL.How does NULL propagate through arithmetic expressions, and how can COALESCE and NULLIF help handle missing values and division by zero?
- SQL.How does NULL affect join conditions, and why can filtering the right-hand table in WHERE remove unmatched rows from a LEFT JOIN?
- SQL.How do GROUP BY and DISTINCT treat NULL values, even though NULL = NULL evaluates to UNKNOWN?
- SQL.How do aggregate functions handle NULL, and what is the difference between COUNT(*), COUNT(column), and COUNT(DISTINCT column)?
- SQL.How does NULL affect IN and NOT IN, and why can NOT EXISTS be a safer choice when a subquery returns nullable values?
- SQL.How do WHERE, HAVING, and CHECK constraints treat conditions that evaluate to UNKNOWN?
- SQL.Why do column = NULL and column <> NULL not work as expected, and when should you use IS NULL and IS NOT NULL?
- SQL.What is SQL’s three-valued logic (TRUE, FALSE, UNKNOWN), and how do AND, OR, and NOT behave with UNKNOWN?
- ChromeDevTools.Watch all failed requests
- SQL.What are domain types (or constraints on data types), and how do they help enforce data correctness?
- SQL.How does SQL handle comparisons between different data types (for example, string vs number), and why is this dangerous?
- SQL.What is the difference between DATE, TIME, TIMESTAMP, and TIMESTAMPTZ, and which one should be used for business events?
- SQL.How do numeric types like INTEGER, BIGINT, DECIMAL, and FLOAT differ in terms of precision and use cases?
- SQL.What problems can arise from implicit type casting in SQL, and how can it affect indexes?
- SQL.How does NULL differ from 0, an empty string, or FALSE in SQL?
- SQL.What is the difference between CHAR, VARCHAR, and TEXT, and when would you choose each?
- SQL.What is MVCC ?
- SQL.What is AutoVacuum Postgres ?
Categories
- Aptana
- Azure
- C#
- DataSnap
- DBExpress
- Delphi
- Delphi и сети
- Delphi. Язык программирования
- ExtJS
- FastReport
- FireDAC
- FireMonkey
- GIT
- ICS
- IDE
- IIS
- Indy
- InnoSetup
- javascript
- jQuery
- JSON
- LiveBindings
- MSHTML
- MySQL
- PHP
- REST
- Ribbons
- SMS
- SQL инструкции
- SVN
- TRichView
- UniGui
- WebBroker
- WinAPI
- Windows
- Алгоритмы
- Без рубрики
- Деревья
- Ищу ответ
- Компонентостроение
- Мои компоненты
- Начальный уровень
- Обработка исключений
- Парсинг
- Потоки(Threads)
- Регулярные выражения
- Тестирование приложений
Category Archives: Delphi
Delphi. UniGUI. Как узнать высоту текста в uniHTMLFrame?
Выстраивал высоту элементов, возник вопрос с определением высоты текста в UniHTMLFrame. Способ №1 от Delphi Developer
|
1 2 |
js:='alert('+HTMLFrame.JSName+'.body.el.dom.scrollHeight);'; UniSession.JSCode(js); |
Способ №2 Мой способ, менее эффективный, с оборачиванием в div, но тоже рабочий. Решил так. Сначала обернем наш HTML в div c известным … Continue reading
Delphi. UniGUI. Делаем товары месяца
Вот что у нас получится. Левая и правая панельки нужны для листания вправо и влево. Листание происходит за счет смещения на 1 плитку в ту или иную сторону. Стартовое размещение плиток при загрузке.
Posted in Delphi
Comments Off on Delphi. UniGUI. Делаем товары месяца
Delphi. UniGUI. Делаем витрину. Алгоритм выкладывания плиток
Здесь будет код из проекта и идеи алгоритма по шагам. Вот какой будет результат в конце. Оттолкнувшись от него, можно будет сделать в своем проекте аналогичное выкладывание плиток ШАГ 0 – рисуем на бумаге
Posted in Delphi
Comments Off on Delphi. UniGUI. Делаем витрину. Алгоритм выкладывания плиток
Delphi. MultiSelect. Gather field values
simple example….
|
1 2 3 4 5 6 7 8 9 10 11 12 |
invoicesIDSL := TStringList.Create; try if DBGrid.SelectedRows.Count > 0 then with DBGrid.DataSource.DataSet do for i := 0 to DBGrid.SelectedRows.Count - 1 do begin GotoBookmark(pointer(DBGrid.SelectedRows.Items[i])); invoicesIDSL.Add(FieldByName('id').AsInteger.ToString); end; finally invoicesIDSL.Free(); end; |
Posted in Delphi
Comments Off on Delphi. MultiSelect. Gather field values
OmniThread and Exceptions
OmniThread and exceptions… Example # 48 is good… from demos of omni lib…
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
procedure TOmniTasks.Test2; begin Parallel.Async( procedure begin Sleep(1000); raise Exception.Create('Exception in Async'); end, Parallel.TaskConfig.OnTerminated( procedure(const task: IOmniTaskControl) var e: Exception; begin if assigned(task.FatalException) then begin e := task.DetachException; FLogger.LogStr('foreCastSalesCount ' + e.Message, tlpError); // Log('Caught async exception %s:%s', [excp.ClassName, excp.Message]); FreeAndNil(e); end; end)); end; |
Posted in Delphi
Comments Off on OmniThread and Exceptions
Delphi. Omnithreads. ProgressBar with ForEach
Example with progress Bar on ForEach abstraction.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 |
unit test_55_ForEachProgress; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ComCtrls, OtlTask, OtlParallel; type TfrmForEachWithProgressBar = class(TForm) btnStart : TButton; pbForEach: TProgressBar; procedure btnStartClick(Sender: TObject); private FPosition: integer; FProgress: integer; FWorker : IOmniParallelLoop<integer>; procedure IncrementProgressBar; end; var frmForEachWithProgressBar: TfrmForEachWithProgressBar; implementation {$R *.dfm} const CNumLoop = 20000; procedure TfrmForEachWithProgressBar.btnStartClick(Sender: TObject); begin btnStart.Enabled := false; pbForEach.Max := 100; pbForEach.Position := 0; pbForEach.Update; FProgress := 0; FPosition := 0; // reference must be kept in a global field so that the task controller is not destroyed before the processing ends FWorker := Parallel .ForEach(1, CNumLoop) .NoWait // important, otherwise message loop will be blocked while ForEach waits for all tasks to terminate .OnStop( procedure (const task: IOmniTask) begin // because of NoWait, OnStop delegate is invoked from the worker code; we must not destroy the worker at that point or the program will block task.Invoke( procedure begin FWorker := nil; btnStart.Enabled := true; end ); end ); FWorker.Execute( procedure (const task: IOmniTask; const i: integer) begin // do some work Sleep(1); // update the progress bar // we cannot use 'i' for progress as it does not increase sequentially // IncrementProgressBar uses internal counter to follow the progress task.Invoke(IncrementProgressBar); end ); end; procedure TfrmForEachWithProgressBar.IncrementProgressBar; var newPosition: integer; begin Inc(FProgress); newPosition := Trunc((FProgress / CNumLoop)*pbForEach.Max); // make sure we don't overflow TProgressBar with messages if newPosition <> FPosition then begin pbForEach.Position := newPosition; FPosition := newPosition; end; end; end. |
Posted in Delphi
Comments Off on Delphi. Omnithreads. ProgressBar with ForEach
Delphi.Omnithreads.Future – hunting the value in backGroundThread
Future is good thread abstraction that hunts for the value in background thread. We can ask backGround thread what is value now. Calling VCL from backGround is bad idea in that case. For that pupose see http://www.thedelphigeek.com/2014/07/incrementing-progress-bar-from-foreach.html Below is example … Continue reading
Posted in Delphi
Comments Off on Delphi.Omnithreads.Future – hunting the value in backGroundThread
Delphi. OmniThreads.Async – most simple example
hi, most simple example of OmniThread lib looks like
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
procedure TfrmDemoParallelAsync.btnAsyncClick(Sender: TObject); begin btnAsync.Enabled := false; Parallel.Async( procedure begin // executed in background thread Caption := 'Work...'; Sleep(500); MessageBeep($FFFFFFFF); end, Parallel.TaskConfig.OnTerminated( procedure(const task: IOmniTaskControl) begin // executed in main thread btnAsync.Enabled := true; Caption := 'Ready'; end)); end; |
GUI is responsive during executing the code…
Posted in Delphi
Comments Off on Delphi. OmniThreads.Async – most simple example
Delphi. UniGUI. Emulation of Pages using Frames
UniGUI is SPA – single page application, but, emulation is possible. One option – use frames.
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
unit uPagesFramesDM; interface uses SysUtils, Classes, uPage1Frame, uPage2Frame; type TPagesFramesDM = class(TDataModule) private FCurrentPage: integer; FPage1: TPage1Frame; FPage2: TPage2Frame; FSomeParent: TObject; FHistory: TArray<integer>; procedure SetCurrentPage(const Value: integer); procedure KillFrames(); procedure AddHistory(AValue: integer); procedure SetMainForm(const Value: TObject); procedure SetHistory(const Value: TArray<integer>); { Private declarations } public { Public declarations } constructor Create(AOwner: TComponent); override; procedure Back(); procedure Next(); procedure Load(aIndex: integer); property SomeParent: TObject read FSomeParent write SetMainForm; property CurrentPage: integer read FCurrentPage write SetCurrentPage; property History: TArray<integer> read FHistory write SetHistory; end; implementation uses Vcl.Controls, Main, uniGUIApplication; {$R *.dfm} { TDataModule1 } procedure TPagesFramesDM.AddHistory(AValue: integer); begin SetLength(FHistory, length(FHistory) + 1); FHistory[high(FHistory)] := AValue; end; procedure TPagesFramesDM.Back; begin if FCurrentPage > 0 then begin FCurrentPage := FCurrentPage - 1; Load(CurrentPage); end; end; constructor TPagesFramesDM.Create(AOwner: TComponent); begin inherited; // loadCurrentPage FHistory := [0, 1]; end; procedure TPagesFramesDM.Next; begin if FCurrentPage < High(FHistory) then begin FCurrentPage := FCurrentPage + 1; Load(CurrentPage); end; end; procedure TPagesFramesDM.KillFrames; begin if assigned(FPage1) then FreeAndNil(FPage1); if assigned(FPage2) then FreeAndNil(FPage2); end; procedure TPagesFramesDM.Load(aIndex: integer); begin case aIndex of 0: begin // load first page killFrames(); FPage1 := TPage1Frame.Create(MainForm); with FPage1 do begin Parent := MainForm; Align := alClient; Show(); end; end; 1: begin // load second page killFrames(); FPage2 := TPage2Frame.Create(MainForm); with FPage2 do begin Parent := MainForm; Align := alClient; Show(); end; end; end; end; procedure TPagesFramesDM.SetCurrentPage(const Value: integer); begin FCurrentPage := Value; end; procedure TPagesFramesDM.SetHistory(const Value: TArray<integer>); begin FHistory := Value; end; procedure TPagesFramesDM.SetMainForm(const Value: TObject); begin FSomeParent := Value; end; end. |
Then call its in main like this
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
unit Main; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, uniGUITypes, uniGUIAbstractClasses, uniGUIClasses, uniGUIRegClasses, uniGUIForm, uniGUIBaseClasses, uniPanel, uniButton, uniBitBtn, uPagesFramesDM; type TMainForm = class(TUniForm) pMainMenuTop: TUniPanel; bPrevious: TUniBitBtn; bNext: TUniBitBtn; bPage1: TUniBitBtn; bPage2: TUniBitBtn; procedure bPreviousClick(Sender: TObject); procedure bNextClick(Sender: TObject); procedure bPage1Click(Sender: TObject); procedure bPage2Click(Sender: TObject); procedure UniFormAfterShow(Sender: TObject); private { Private declarations } FPages: TPagesFramesDM; public { Public declarations } constructor Create(AOwner: TComponent); override; end; function MainForm: TMainForm; implementation {$R *.dfm} uses uniGUIVars, MainModule, uniGUIApplication; function MainForm: TMainForm; begin Result := TMainForm(UniMainModule.GetFormInstance(TMainForm)); end; { TMainForm } procedure TMainForm.bPage1Click(Sender: TObject); begin FPages.Load(0); end; procedure TMainForm.bPage2Click(Sender: TObject); begin FPages.Load(1); end; procedure TMainForm.bPreviousClick(Sender: TObject); begin FPages.Back(); end; constructor TMainForm.Create(AOwner: TComponent); begin inherited; FPages := TPagesFramesDM.Create(UniApplication); FPages.SomeParent := Self; end; procedure TMainForm.UniFormAfterShow(Sender: TObject); begin FPages.Load(0); end; procedure TMainForm.bNextClick(Sender: TObject); begin FPages.Next() end; initialization RegisterAppFormClass(TMainForm); end. |
Posted in Delphi
Comments Off on Delphi. UniGUI. Emulation of Pages using Frames
RTTI Atributes
shows how to work with RTTI and attributes RTTI – Run Time Type Library – is approach that helps to manage code when program is running. Lets say we have code from someOne without docs. RTTI will help to find … Continue reading
Posted in Delphi
Comments Off on RTTI Atributes