

Rafael Dipold
Members-
Content Count
16 -
Joined
-
Last visited
Community Reputation
0 NeutralAbout Rafael Dipold
- Birthday 06/10/1982
Technical Information
-
Delphi-Version
Delphi 11 Alexandria
-
Hi, I can consider now this problem solved. As you can read here: Currently, explicit transaction object assignment is supported only for InterBase and Firebird. I have always worked with Firebird and I was guided by the same logic to manage PostgreSQL transactions. And now I see that I will have to redesign my connection layer. Thanks
-
Here is a verifiable example, just enter a valid database and table. I don't see anything that could be wrong here, it seems to be a Firedac bug: program Project1; {$APPTYPE CONSOLE} {$R *.res} uses FireDAC.Comp.Client, FireDAC.DApt, FireDAC.Phys.PG, FireDAC.Phys.PGDef, FireDAC.Stan.Async, FireDAC.Stan.Def, FireDAC.Stan.Intf, System.SysUtils; var LConnectionDef: IFDStanConnectionDef; LQueryRO: TFDQuery; LQueryRW: TFDQuery; LTransactionRO: TFDTransaction; LTransactionRW: TFDTransaction; begin try FDManager.DriverDefFileAutoLoad := False; FDManager.ConnectionDefs.AutoLoad := False; FDManager.ConnectionDefs.Clear; FDManager.ConnectionDefs.BeginWrite; try LConnectionDef := FDManager.ConnectionDefs.AddConnectionDef; LConnectionDef.Name := 'MY_DB'; with TFDPhysPGConnectionDefParams(LConnectionDef.Params) do begin DriverID := 'PG'; CharacterSet := TFDPGCharacterSet.csUTF8; Server := '127.0.0.1'; Database := 'MY_DB'; Port := 11786; UserName := 'myuser'; Password := '123456'; end; finally FDManager.ConnectionDefs.EndWrite; end; LTransactionRO := TFDTransaction.Create(nil); LQueryRO := TFDQuery.Create(nil); try LTransactionRO.Connection := FDManager.AcquireConnection('MY_DB', ''); LTransactionRO.Options.ReadOnly := True; LQueryRO.Connection := FDManager.AcquireConnection('MY_DB', ''); LQueryRO.Transaction := LTransactionRO; LQueryRO.Open('SELECT * FROM MY_TABLE'); finally LQueryRO.Free; LTransactionRO.Free; end; LTransactionRW := TFDTransaction.Create(nil); LQueryRW := TFDQuery.Create(nil); try LTransactionRW.Connection := FDManager.AcquireConnection('MY_DB', ''); LTransactionRW.Options.ReadOnly := False; LQueryRW.Connection := FDManager.AcquireConnection('MY_DB', ''); LQueryRW.Transaction := LTransactionRW; //ERROR: cannot execute UPDATE in a read-only transaction. LQueryRW.ExecSQL('UPDATE MY_TABLE SET COLUMN_1 = COLUMN_1 WHERE 1=1'); finally LQueryRW.Free; LTransactionRW.Free; end; Writeln('OK'); Readln; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end.
-
Yes, same thing. In my project transactions are always started and finished, I removed everything I could in the example above for simplification.
-
Hello friends, Would anyone have a tip why the read-only error happens when I run the FireDAC commands in this order, like the MRE below? //READ ONLY TRANSACTION LTransactionRO := TFDTransaction.Create(nil); LQueryRO := TFDQuery.Create(nil); try LTransactionRO.Connection := FDManager.AcquireConnection('MY_DB', ''); LTransactionRO.Options.ReadOnly := True; LQueryRO.Connection := FDManager.AcquireConnection('MY_DB', ''); LQueryRO.Transaction := LTransactionRO; LQueryRO.Open('SELECT * FROM mY_TABLE'); //OK finally LQueryRO.Free; LTransactionRO.Free; end; //READ WRITE TRANSACTION LTransactionRW := TFDTransaction.Create(nil); LQueryRW := TFDQuery.Create(nil); try LTransactionRW.Connection := FDManager.AcquireConnection('MY_DB', ''); LTransactionRW.Options.ReadOnly := False; LQueryRW.Connection := FDManager.AcquireConnection('MY_DB', ''); LQueryRW.Transaction := LTransactionRW; //ERROR: cannot execute UPDATE in a read-only transaction. LQueryRW.ExecSQL('UPDATE MY_TABLE SET COLUM1 = COLUM1 WHERE 1 = 1'); finally LQueryRW.Free; LTransactionRW.Free; end; if I comment the line `//LTransactionRO.Options.ReadOnly := True;`, the SQL UPDATE run without errors. Thanks for any tips!
-
Windows App Store icon sizes - unplated?
Rafael Dipold replied to Incus J's topic in Delphi IDE and APIs
Hi, I got around the problem, manually performing the procedure in the link below, generating the .pri files: https://learn.microsoft.com/en-us/windows/msix/desktop/desktop-to-uwp-manual-conversion#generate-a-package-resource-index-pri-file-using-makepri- 9 replies
-
- appx
- windows store app
-
(and 3 more)
Tagged with:
-
In fact there was a trojan installed, it must have been a few days ago when I tried to install software downloaded via torrent Thank you, problem solved
-
I updated Windows to 22H2, no programs running in the background, and even copying this string from notepad, my string has only memory garbage.. Initially I thought it was a bug in Delphi, that's why I posted it here, but now I see that my computer has some glitch, as I tested it on another computer and the bug doesn't happen
-
42 N N =DOLLAR(4967.32, 2) =DOLLAR(1515.61, 2) =DOLLAR(0, 2) =DOLLAR(58054.89, 2) =DOLLAR(4084.55, 2) 42 N N =DOLLAR(4B8r3B4p7yhRXuBWLqsQ546WR43cqQwrbXMDFnBi6vSJBeif8tPW85a7r7DM961Jvk4hdryZoByEp8GC8HzsqJpRN4FxGM9, 2) For me, even if I copy and paste here on the Forum, it pastes garbage from memory... see second line above. I will try to install the latest windows updates.. seems to be a windows bug
-
Hi, Can anyone explain to me why this specific sequence of characters, when copying to clipboard and pasting to notepad, windows pastes memory garbage? If I change '42' to '32', for example, this issue not happen procedure TForm1.Button1Click(Sender: TObject); var C, R: TArray<String>; begin C := []; C := C + ['42']; C := C + ['N']; C := C + ['N']; C := C + ['=DOLLAR(4967.32, 2)']; C := C + ['=DOLLAR(1515.61, 2)']; C := C + ['=DOLLAR(0, 2)']; C := C + ['=DOLLAR(58054.89, 2)']; C := C + ['=DOLLAR(4084.55, 2)']; R := R + [''.Join(#9, C)]; Clipboard.AsText := ''.Join(#13#10, R); ShowMessage('Copy to Clipboard!'); end;
-
Exec JS scripts in TEdgeBrowser
Rafael Dipold replied to Rafael Dipold's topic in RTL and Delphi Object Pascal
Thanks! In this example above I'm exactly queuing the JS calls in series because Script2 (in my application) depends on values returned from Script1. As you said, if you run the JS calls in parallel, the results in EdgeBrowserWebMessageReceived() won't necessarily come in the order they were called. -
Exec JS scripts in TEdgeBrowser
Rafael Dipold replied to Rafael Dipold's topic in RTL and Delphi Object Pascal
Exactly. I did some workarounds to get around this problem. It works, but it's not an ideal code... type TForm1 = class(TForm) EdgeBrowser: TEdgeBrowser; procedure EdgeBrowserWebMessageReceived(Sender: TCustomEdgeBrowser; Args: TWebMessageReceivedEventArgs); private FQueue: TQueue<String>; FMyResult1: String; FMyResult2: String; procedure JSExec; procedure ShowResult; end; procedure TForm1.Button1Click(Sender: TObject); begin FQueue.Enqueue('JSExec1'); FQueue.Enqueue('JSExec2'); JSExec; end; procedure TForm1.EdgeBrowserWebMessageReceived(Sender: TCustomEdgeBrowser; Args: TWebMessageReceivedEventArgs); begin if (JSON.messageType = 'R1') then //Get from Args (omitted for simplification) FMyResult1 := JSON.value; if (JSON.messageType = 'R2') then FMyResult2 := JSON.value; JSExec; end; procedure TForm1.JSExec; var LExec: String; LMyScript: String; begin if (FQueue.Count = 0) then begin ShowResult; Exit; end; LExec := FQueue.Dequeue(); if (LExec = 'JSExec1') then begin LMyScript := 'window.chrome.webview.postMessage({messageType: "R1", value: "MyResult1"});'; EdgeBrowser.ExecuteScript(LMyScript); Exit; end; if (LExec = 'JSExec2') then begin LMyScript := 'window.chrome.webview.postMessage({messageType: "R2", value: "MyResult2"});'; EdgeBrowser.ExecuteScript(LMyScript); Exit; end; end; procedure TForm1.ShowResult; begin ShowMessage(FResult1); ShowMessage(FResult2); end; -
Hi, lay questions are accepted? I need to run some scripts in a sequence on a document, where the result of the previous script is used to the next script. I created a simplified example for better understanding: type TForm1 = class(TForm) EdgeBrowser: TEdgeBrowser; procedure EdgeBrowserWebMessageReceived(Sender: TCustomEdgeBrowser; Args: TWebMessageReceivedEventArgs); private FMyResult: String; end; procedure TForm1.Button1Click(Sender: TObject); var LMyScript: String; begin LMyScript := 'window.chrome.webview.postMessage("MyResult");'; EdgeBrowser.ExecuteScript(LMyScript); //How wait for EdgeBrowserWebMessageReceived() to get FMyResult? ShowMessage(FMyResult); end; procedure TForm1.EdgeBrowserWebMessageReceived(Sender: TCustomEdgeBrowser; Args: TWebMessageReceivedEventArgs); begin FMyResult := '"MyResult"'; //Get from Args (omitted for simplification) end; The comment in the code shows my need. I tried several workarounds like run ExecuteScript() on a TTask.Future(), but EdgeBrowserWebMessageReceived() only executes when the thread finalize. Does anyone have any suggestions? It doesn't have to be an elegant solution, because this is for internal use. Thanks in advance
-
Thanks, the solution 1 works fine for me.
-
@WillH Thanks for help. For now, I'm registering all my 53 events at software startup, but ideally I'd like to register only when it's needed. I'm going to post this problem on Embarcadero's Quality Portal, but without much hope that the Embarcadero will comment on it. Update: https://quality.embarcadero.com/browse/RSP-24789
-
FEvents.Options.Synchronize := True; I had already tried this option without success. I also tried to force the registration of the event on a Thread Synchronize, but if more than on event register or trigger in the same cycle, the software also freezes: TThread.CreateAnonymousThread( procedure begin TThread.Synchronize(nil, procedure begin FBEvents.Events.Add('EVENT_2'); end); end).Start; @WillH PostMessage() happens the same as Thread.Synchronize() if more than one event trigger. Both only minimize the problem: procedure TForm1.Button1Click(Sender: TObject); begin FConn.ExecSQL('EXECUTE BLOCK AS BEGIN POST_EVENT ''EVENT_1''; END'); FConn.ExecSQL('EXECUTE BLOCK AS BEGIN POST_EVENT ''EVENT_1''; END'); PostMessage(Handle, WM_EVENT_MESSAGE, Integer(PChar('EVENT_2')), 0); end;