Page 1 of 1
Update more than one table
Posted: Thu 08 May 2014 08:58
by krshin
Hello,
Does UniDAC or any xxxDAC product of DevArt for Delphi can update more than one table in sama time. For example I have join query with 3 tables and I need to update all tables by some criteria (key value)?
Thanks in advance...
Re: Update more than one table
Posted: Thu 08 May 2014 14:02
by azyk
Hello,
Please specify the database you are working with, as this functionality can be implemented in different databases in different ways.
Re: Update more than one table
Posted: Thu 08 May 2014 17:57
by krshin
Hello,
I'm primary using SQL Server than Oracle and Firebird, because little users need small database and I use Firebird and standard users use SQL Server, and larger users with more request use Oracle as backend database.
Thanks for help...
Re: Update more than one table
Posted: Mon 19 May 2014 11:17
by AlexP
MS SQL Server
To update more than one table at a time, you should write a SQL query to TUniQuery.SQLUpdate for update of each table. The SQL query must be delimited by ";", for example:
Code: Select all
UPDATE EMP SET ENAME = :ENAME ,JOB = :JOB WHERE EMPNO = :EMPNO;
UPDATE DEPT SET DNAME = :DNAME WHERE DEPTNO = :DEPTNO;
For Oracle, you can run similar commands in an anonymous block:
Code: Select all
BEGIN
UPDATE EMP SET ENAME = :ENAME ,JOB = :JOB WHERE EMPNO = :EMPNO;
UPDATE DEPT SET DNAME = :DNAME WHERE DEPTNO = :DEPTNO;
END;