A
A
AltLumad2016-03-12 20:14:20
PostgreSQL
AltLumad, 2016-03-12 20:14:20

UniDac + PostgreSQL How to execute several Inserts within one ExecSQL()?

There is TUniConnection, TPostgreSQLUniProvider, TUniQuery
The code is something like this:

Q->SQL->Text = " insert into tbl_A (colum1,column2) values(1,1); \r\n"
                             " insert into tbl_A (colum1,column2) values(2,2); \r\n"
                             " insert into tbl_A (colum1,column2) values(3,3); ";
  Q->ExecSQL();

Error: "Multiple commands cannot be inserted into a prepared statement" when executing the script.
If you execute each of these inserts separately, then there is no problem. But that option doesn't work for me.
Tell me how to execute this script within a single command for execution.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
AltLumad, 2016-03-12
@AltLumad

There is a TUniScript component, it perfectly copes with this task.
You need to work with it in the same way as with TUniQuery.
The code is the following:

UniScript->SQL->Text = " insert into tbl_A (colum1,column2) values(1,1); \r\n"
                             " insert into tbl_A (colum1,column2) values(2,2); \r\n"
                             " insert into tbl_A (colum1,column2) values(3,3); ";
UniScript->Execute();

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question