Update more than one table

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
krshin
Posts: 14
Joined: Wed 21 Mar 2007 11:29

Update more than one table

Post by krshin » Thu 08 May 2014 08:58

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...

azyk
Devart Team
Posts: 1119
Joined: Fri 11 Apr 2014 11:47
Location: Alpha Centauri A

Re: Update more than one table

Post by azyk » Thu 08 May 2014 14:02

Hello,

Please specify the database you are working with, as this functionality can be implemented in different databases in different ways.

krshin
Posts: 14
Joined: Wed 21 Mar 2007 11:29

Re: Update more than one table

Post by krshin » Thu 08 May 2014 17:57

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...

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

Re: Update more than one table

Post by AlexP » Mon 19 May 2014 11:17

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;

Post Reply