one database source insert to more than 1 table?

Post any questions you have about using the Verj.io Studio, including client and server-side programming with Javascript or FPL, and integration with databases, web services etc.

Moderators: Jon, Steve, Ian, Dave

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

one database source insert to more than 1 table?

#1

Postby t4nu » Tue Apr 26, 2016 11:12 am

Hi,
As far as I know, 1 database source can only insert or update or delete to 1 table. So if my transaction need to update to more than 1 table, what should I do so the data can be saved in all or none manners?
Call a stored procedure? execute query directly? or maybe there is other things that more simple?
Thanks in advance for the help.
0 x

Segi
Ebase User
Posts: 649
Joined: Mon Dec 09, 2013 6:37 pm

#2

Postby Segi » Tue Apr 26, 2016 4:10 pm

Technically speaking, there's nothing stopping you from putting more than 1 SQL command in the insert update or delete tabs as long at both tables that are being modified are accessible by the database connection that you specify for the database resource.

so you could have this in the insert tab

UPDATE Table1 SET column1='foo' where id=1234
UPDATE Table2 SET column2='bar' where id=1234
0 x

Jon
Moderator
Moderator
Posts: 1342
Joined: Wed Sep 12, 2007 12:49 pm

#3

Postby Jon » Tue Apr 26, 2016 4:28 pm

Or just add another database resource for the second insert, they will both be executed within the same transaction.
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#4

Postby t4nu » Wed Apr 27, 2016 4:01 am

Hi,
Unfortunately the code (following your example) gave me:
SQL command not properly ended error message.

The same message when I put the ; in the end of the command.
Segi wrote:Technically speaking, there's nothing stopping you from putting more than 1 SQL command in the insert update or delete tabs as long at both tables that are being modified are accessible by the database connection that you specify for the database resource.

so you could have this in the insert tab

UPDATE Table1 SET column1='foo' where id=1234
UPDATE Table2 SET column2='bar' where id=1234
0 x

t4nu
Ebase User
Posts: 305
Joined: Thu Jul 02, 2015 8:32 am
Location: Indonesia

#5

Postby t4nu » Wed Apr 27, 2016 4:05 am

Ah really?
If this is the case (execute 2 database resource but still in the same transaction) maybe this approach can become another alternative.
Thanks.
Jon wrote:Or just add another database resource for the second insert, they will both be executed within the same transaction.
0 x


Who is online

Users browsing this forum: No registered users and 10 guests