Registration disabled at the moment Read more...
×
-
Content Count
153 -
Joined
-
Last visited
-
Days Won
1
weirdo12 last won the day on July 13 2023
weirdo12 had the most liked content!
Community Reputation
26 ExcellentAbout weirdo12
- Currently Viewing Forum: Databases
Technical Information
-
Delphi-Version
Delphi 12 Athens
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
For sure. If there are 32-bit binaries from newer versions they will work. I will look into updating the ones I have been using too.
-
As was said above, you just need to connect to both servers (databases) simultaneously. You should have a look a using some of the built-in functionality you get with MyDAC - like TCRBatchMove. Let it do all the tedious INSERT work for you. https://docs.devart.com/mydac/devart.dac.tcrbatchmove.htm
-
You need the PostgreSQL 32-bit library files and that means you should install PostgreSQL 10.23. You can still get it here: https://get.enterprisedb.com/postgresql/postgresql-10.23-1-windows.exe These are the files you will need to copy from C:\Program Files (x86)\PostgreSQL\10\bin to the same directory as your exe: libssl-1_1.dll libcrypto-1_1.dll libiconv-2.dll libintl-8.dll libpq.dll And you also need correct version of Microsoft Visual Studio 2013 (VC++ 12.0) C++ Redistributable run-time library. You can download it here: https://aka.ms/highdpimfc2013x86enu
-
How do I avoid the error message 'is not a valid date.' ?
weirdo12 replied to JohnLM's topic in Databases
Do you mean that you get that error when assigning a value to a date field that is part of a TDataSet? -
FireDAC getting tripped up with PostgreSQL transactions
weirdo12 replied to FLDelphi's topic in Databases
Another thing: I totally get using TFDQuery out of habit but don't forget that there is the more lightweight TFDCommand or TFDConnection.ExecSQL for doing INSERT, UPDATE and DELETE. -
FireDAC getting tripped up with PostgreSQL transactions
weirdo12 replied to FLDelphi's topic in Databases
If you use TFDScript you can use macros and and parameters. I tested this text and it works as expected. You end up with 2 rows in the table. DROP TABLE "&table_name" CASCADE; CREATE TABLE "&table_name" ( serial_number serial, ticket_date timestamp NULL DEFAULT LOCALTIMESTAMP, PRIMARY KEY (serial_number) ); BEGIN; INSERT INTO "&table_name" (serial_number, ticket_date) VALUES (1, CAST(:start_date AS TIMESTAMP)); INSERT INTO "&table_name" (serial_number, ticket_date) VALUES (2, CAST(:start_date AS TIMESTAMP)); END; BEGIN; INSERT INTO "&table_name" (serial_number, ticket_date) VALUES (3, CAST(:start_date AS TIMESTAMP)); INSERT INTO "&table_name" (serial_number, ticket_date) VALUES (1, CAST(:start_date AS TIMESTAMP)); END; The TFDScript.OnScriptError event is called when an attempt to INSERT serial_number 1 again and serial_number 3 does not exist in the table. [FireDAC][Phys][PG][libpq] ERROR: duplicate key value violates unique constraint "receipt_ticket_pkey". Key (serial_number)=(1) already exists. The TDScript.Status value at the completion of the TDScript.ExecuteAll is ssFinishedWithErrors. FDScript->ScriptOptions->CommandSeparator = ";"; FDScript->SQLScripts->Clear(); auto sql_script {FDScript->SQLScripts->Add()}; sql_script->SQL->Assign(cxMemoSQL->Lines); if (FDScript->Macros->FindMacro("table_name") == nullptr) { auto macro_ {FDScript->Macros->Add()}; macro_->Name = "table_name"; } FDScript->Macros->MacroByName("table_name")->AsRaw = FFrameTicketDateFilter->TableName; if (FDScript->Params->FindParam("start_date") == nullptr) { FDScript->Params->Add("start_date", ftString); } FDScript->Params->ParamByName("start_date")->AsString = FFrameTicketDateFilter->StartDate(); if (FDScript->Params->FindParam("end_date") == nullptr) { FDScript->Params->Add("end_date", ftString); } FDScript->Params->ParamByName("end_date")->AsString = FFrameTicketDateFilter->EndDate(); FDScript->ValidateAll(); if (FDScript->Status == ssFinishSuccess) { #if defined(_CODESITE) // Don't time how long it take to make the previous CodeSite calls. _di_ICodeSiteTimer timer_ {CodeSite->Timer({}, TCodeSiteTimingFormat::tfMilliseconds, true, false)}; #endif FDScript->ExecuteAll(); #if defined(_CODESITE) timer_->Stop(); #endif if (FDScript->Status == ssFinishSuccess) { auto msg_ {"The SQL Source text executed successfully."}; cxMemoSQLText->Clear(); cxMemoSQLText->Lines->Add(msg_); Dxmessagedialog::dxMessageDlg(msg_, mtInformation, TMsgDlgButtons() << mbOK, 0); } } void __fastcall TFrameGridLoadSummary::FDScriptError(TObject *ASender, TObject *AInitiator, Exception *&AException) { cxMemoSQLText->Clear(); cxMemoSQLText->Lines->Add(AException->Message); Dxmessagedialog::dxMessageDlg(AException->Message, mtError, TMsgDlgButtons() << mbOK, 0); } //--------------------------------------------------------------------------- Edit: I just wanted to add if I execute this code: BEGIN; INSERT INTO "&table_name" (serial_number) VALUES (3); INSERT INTO "&table_name" (serial_number) VALUES (1); END; Using TFDQuery instead of TFDScript I get exactly the same issue that was initially reported if immediately after I execute something like 'SELECT * FROM &table_name'. -
FireDAC getting tripped up with PostgreSQL transactions
weirdo12 replied to FLDelphi's topic in Databases
Edit: I'm going check this again tomorrow but I am pretty sure I am actually running code like below in a TFDQuery 😉 You could use TFDScript. For example, you could put these commands in the script: BEGIN; INSERT INTO t1(id) VALUES ('1'); INSERT INTO t1(id) VALUES ('2'); -- to test it cause an error INSERT INTO t1(id) VALUES ('1'); END; And the in the exception handler call ExecSQL("ROLLBACK'); -
Are you calling the TFDQuery.ApplyUpdates() method somewhere after you call Post? https://docwiki.embarcadero.com/RADStudio/Athens/en/Caching_Updates_(FireDAC)
-
Like you, I used SQL Anywhere as the default for many, many years - starting when it was still known Watcom SQL and running on DOS. I switched to using SQLite as the default database that the product ships with because it provided the same kind of installation experience (along with maintaining SQL Anywhere support for existing customers). When a new multi-user server is required, I use PostgreSQL.
-
Just to be clear, are you referring to renaming controls that you drag and drop or naming ones you are creating dynamically? I missed the previous post...
-
Type mismatch for field 'SumVal', expecting: FMTBcd actual: Float'.
weirdo12 replied to emileverh's topic in Databases
You should post your final syntax to help others who encounter that same issue. -
I did some quick searching about this 32-bit/64-bit client libraries and old version/new version server issue as it relates to PostgreSQL. For the record, here's what Tom Lane (core PostgreSQL developer) has to say:
- 6 replies
-
- firedac
- postgresql
-
(and 1 more)
Tagged with:
-
In case you need the final 32-bit version of PostgreSQL to get the correct libraries, here is a link: https://get.enterprisedb.com/postgresql/postgresql-10.23-1-windows.exe
-
The error you show is typical of what I see if the 32-bit Visual Studio C++ Runtime is not installed. https://www.canscale.com/support/software/dispatch/docs/3.1/webhelp/dsptch31.htm?postgresql_troubleshooting.htm
- 6 replies
-
- firedac
- postgresql
-
(and 1 more)
Tagged with:
-
The other thing to remember is that you need to have the 32-bit version of the Visual Studio run-time library installed or the 32-bit PostgreSQL libraries won't work. https://learn.microsoft.com/en-US/cpp/windows/latest-supported-vc-redist?view=msvc-170#visual-studio-2013-vc-120