Page 1 of 1

How to use UniQuery SqlInsert

Posted: Tue 28 Sep 2010 19:55
by zkrstin
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:

Posted: Wed 29 Sep 2010 10:56
by AlexP
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.

Example?

Posted: Sat 02 Oct 2010 20:17
by zkrstin
If I understand you, the Update SQL's insert statement type will be fired after insert.
Can you write some little example?

Posted: Mon 04 Oct 2010 09:34
by AlexP
Hello,

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