How to use UniQuery SqlInsert

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
zkrstin
Posts: 2
Joined: Tue 28 Sep 2010 19:34

How to use UniQuery SqlInsert

Post by zkrstin » Tue 28 Sep 2010 19:55

Hello, I try to use UniQuery SqlInsert, but somthing I get wrong.
My sql is:

Code: Select all

select  ppo.*, p.profesor , p.active,
op.id_1, op.id_2 , op.id_3

from skl_odeljenje_predmet op left join skl_profesor_predmet pp on op.id_predmeta = pp.id_predmeta
                              inner join skl_profesor p on pp.id_profesora = p.id
                              left join skl_prof_predmet_odeljenje ppo on op.id_odeljenja = ppo.id_odeljenje and op.id_predmeta = ppo.id_predmet and ppo.id_profesor = p.id
where op.id = :id
The result of this query for :id=2 is

Code: Select all

 
(ID, ID_PROFESOR, ID_PREDMET, ID_ODELJENJE, PROFESOR, AKTIVAN, ID_1, ID_2, ID_3) 
VALUES (NULL, NULL, NULL, NULL, 'Name1', 0, 2, 2, 14);
and SQL INSERT STATEMENT is

Code: Select all

INSERT INTO SKL_PROF_PREDMET_ODELJENJE
  (ID, ID_PROFESOR, ID_PREDMET, ID_ODELJENJE)
VALUES
  (NEXT VALUE FOR GEN_PROF_PRE_OD_ID, :Old_ID_1, :Old_ID_2A, :Old_ID_3)


When I call UniQuery->Insert() function, nothing happend?

What is wrong here?

:roll:

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Wed 29 Sep 2010 10:56

Hello,

The TUniQuery.SQLInsert property is used to specify the SQL statement that will be used when applying an insertion to a dataset.

Names of the parameters should be the same as field names.
Parameters prefixed with OLD_ allow using current values of fields prior to the actual operation, when you insert data the OLD_ parameters is null.

The TUniQuery.Insert method is used only to set the DataSet state to Insert mode, you should call the TUniQuery.Post method to insert data to database.

zkrstin
Posts: 2
Joined: Tue 28 Sep 2010 19:34

Example?

Post by zkrstin » Sat 02 Oct 2010 20:17

If I understand you, the Update SQL's insert statement type will be fired after insert.
Can you write some little example?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Mon 04 Oct 2010 09:34

Hello,

Please tell me more about what you are going to do, and I'll try to create an example.

Post Reply