Jump to content
Squamis

From Delphi+PostgresDAC (PostgresSQL) To Delphi+FireDAC (PostgresSQL)

Recommended Posts

Helllo!

Last week I decided convert my big project from Delphi+PostgresDAC (PostgresSQL) to Delphi+FireDAC (PostgresSQL).

I find a lot of interesting things:

 

1. I can't add several "Insert" sql-queries into one TFDCommand. I've tried to use delimiter ';' - nothing. I want to use one command Execute to run several queries "Insert".

 

2. Some SQL-query works in different way (about speed)

in SQLManager works very fast

in Delphi+PostgresDAC mode works very fast

in Delphi+FireDAC mode - freeze

select * from vdata."systems" where ((fldidxsystem = any(:fldidxsystem::bigint[])) or (:fldidxsystem::bigint[] = '{}'))

only when I rewrite SQL-query - work very fast.

select * from vdata."systems" where ((fldidxsystem = any(:fldidxsystem::bigint[])) or (:fldidxsystem::varchar = '{}'))

Maybe someone have any answers about it?

Share this post


Link to post
2 minutes ago, programmerdelphi2k said:

I dont know if help you, but do you try use "Arrays DML"?

No. I mean fully different queries.

insert into table1....;

delete from table2...;

Share this post


Link to post
34 minutes ago, Squamis said:

No. I mean fully different queries.

insert into table1....;

delete from table2...;

The first point says something else.

Share this post


Link to post
4 minutes ago, Stano said:

The first point says something else

 

May be. But, I mean the next:

I want in one TFDCommand component set several different queries, for example:

insert into table1....;

delete from table2...;

 

and in code just run Qr1.Execute;

 

I don't want create two TFDComponent.

Edited by Squamis

Share this post


Link to post

Well, then the "Array DML technique" would allow multiple "DML commands" with parameters to be automated!
so if using:
"insert ....; "delete ...."   we could produce a "multiple executions to 2 commands" ... with each execution of the array!

Share this post


Link to post

Thank for all! Thank for your time!

It is really fine solution fo me:

DO $$
BEGIN
INSERT INTO vdata.sides(fldside_art, fldside_name) VALUES('a','b');
INSERT INTO vdata.sides(fldside_art, fldside_name) VALUES('c','d');
delete from vdata.sides where fldside_art = 'a';
END $$

Tommorow I''l try "Array DML" and "TFDScript"

Edited by Squamis

Share this post


Link to post
6 hours ago, Squamis said:

Thank for all! Thank for your time!

It is really fine solution fo me:


DO $$
BEGIN
INSERT INTO vdata.sides(fldside_art, fldside_name) VALUES('a','b');
INSERT INTO vdata.sides(fldside_art, fldside_name) VALUES('c','d');
delete from vdata.sides where fldside_art = 'a';
END $$

Tommorow I''l try "Array DML" and "TFDScript"

Use TFDScript with just the INSERT and DELETE statements.

 

Edited by weirdo12

Share this post


Link to post

Next problem

I very often use next type of queries

select id from orders where id = any(:id)

and set parameter like '{1,2}' for example

but FireDAC can't recognize that paramtype

 

I should rewrite sql-query like this

select id from orders where id = any(cast(:id as bigint[]))

but in this mode query freezes...

What you can recommend for me?

Share this post


Link to post

I don't know Postgre. Well, it wouldn't help in (...)

Share this post


Link to post
24 minutes ago, Squamis said:

In this sample I can't find sample with using query with parameters

It does an INSERT using parameters with the third parameter :items being an array parameter it puts four values in for each of the five INSERTS it does (the for loop). 

Edited by Brian Evans

Share this post


Link to post
49 minutes ago, Stano said:

I don't know Postgre. Well, it wouldn't help in (...)

if wouldnt help, please refrain from posting messages without any contribution.  😂:classic_cheerleader:

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×