-
Content Count
156 -
Joined
-
Last visited
-
Days Won
1
Posts posted by weirdo12
-
-
8 minutes ago, Squall_FF8 said:May we adapt it, if the text is in RichView (instead of Memo) and it is more complicated, like:
xxxxx [Ticket."ticket_date"] xxxxxx
If you double-click the RichView component is there a Format tab? If so, look in expressions and pick your date/time column and set the format string there. If the RichView contains multiple columns, each one will be listed in Expressions.
-
Add a BeforePrint handler to the memo control. Make sure that you clear the DataField and DataSet properties of the memo control or BeforePrint won't have any effect..
procedure Memo13OnBeforePrint(Sender: TfrxComponent);
begin
TfrxMemoView(Sender).Text := FormatDateTime('yyyy-mm-dd', <Ticket."ticket_date">);
end;No formatting:
With the BeforePrint:
-
1
-
-
4 hours ago, Brian Evans said:Had time to test it and using 32-bit client binaries from a newer PostgreSQL 32-bit ODBC driver version still works.
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.
-
2 hours ago, unitsistemas said:I'm asking for help. When I try to compile a 32-bit executable, in my 32-bit Delphi as well, in my 64-bit operating system, Windows 10 Home Single Language, Version 22H2, an error appears about libpq.dll, saying that it was found, but not loaded. I use Postgres 15.3
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.dllAnd you also need correct version of Microsoft Visual Studio 2013 (VC++ 12.0) C++ Redistributable run-time library. You can download it here:
-
1
-
-
Do you mean that you get that error when assigning a value to a date field that is part of a TDataSet?
-
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.
-
1
-
-
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'.
Quote[FireDAC][Phys][PG][libpq] ERROR: current transaction is aborted, commands ignored until end of transaction block
-
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...
-
20 hours ago, emileverh said:Thanks you helped me a lot!!
You should post your final syntax to help others who encounter that same issue.
-
1
-
-
-
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
-
1
-
-
The error you show is typical of what I see if the 32-bit Visual Studio C++ Runtime is not installed.
-
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.
-
5 minutes ago, egnew said:When I release the application, libpq.dll will be in the executable directory.
I found that the library files had to be in a sub-directory named lib but that may have changed since I originally started supporting PostgreSQL. I use 12.2 now and just put the files in Debug\lib and Release\lib out of habit.
-
I mentioned this in another thread. It may help. I don't open database or edit queries in the IDE so it may not.
QuoteIn my experience, putting libpg.dll and its dependencies in debug\lib and release\lib works and eliminates having to specify a folder in the driver component.
-
18 hours ago, egnew said:Copying libpq.dll from c:\Program Files\PostgreSQL\17\bin into the win64\debug folder did not work.
In my experience, putting libpg.dll and its dependencies in debug\lib and release\lib works and eliminates having to specify a folder in the driver componenent.
-
7 hours ago, Anders Melander said:Having two list think they "own" the same object would be a very bad idea; The layers are already owned and managed by a layer collection.
So just to extend the conversation as it pertains to the original code, there is no need to store TBitmapLayer* at all (except for convenience as a temporary so that it can be initialized as required). The best practice is to always access a layer through ImageBackground->Layers->Items. Would that be good advice or overkill?
-
Another approach is to use std::vector<std::unique_ptr<TBitmapLayer>> created by std::make_unique instead of using an array of raw TBitmapLayer pointers which can lead to memory unsafe code. When the std::vector is destroyed (goes out of scope) everything gets cleaned up.
-
On 11/26/2024 at 2:02 PM, NamoRamana said:Is there any way to suppress the driver info from the actual exception text?
There isn't a property or global setting that will do that.
-
On 11/5/2024 at 5:51 AM, Fraser said:I am getting some compiling done now. Is per file overrides set by right clicking on a project file and selecting edit local options? I haven't looked at this before.
Right click on the source file and choose Edit local options.
MS SQL, How to make a TfdQuerry returns Date in a specific format?
in Databases
Posted · Edited by weirdo12
Try adding a variable. I included a bunch of screen shots because it's not exactly obvious that you have to create a new Category before you can create a variable.
Then add a Category:
Select the Category and click Variable and assign it a value:
Close Edit Variables. Now you *should* be able to drop that variable into the Rich Edit control.