Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread Souvik Bhattacherjee
Or just add pid to table3... > That's an application requirement. So pid cannot be added at will to table3. How much development and maintenance effort are you willing to spend here to gain what is likely to amount to only a bit of efficiency? Many things are possible if you are going to modify

Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread David G. Johnston
On Thu, Apr 18, 2019 at 9:03 AM Souvik Bhattacherjee wrote: > Thanks Michel. > > However this only works if a is an unique attribute in the table that > would help us to identify tuples that participated in the join. Consider > the following join: > > insert into table3 (id, level, empname, salar

Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread Michel Pelletier
On Thu, Apr 18, 2019 at 9:06 AM Michael Lewis wrote: > Thus, what I'm looking for here is way to store the information and then >> pass that information to the next query efficiently. >> For example, is it possible to define a struct of my choice, private to >> the current transaction, that would

Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread Michael Lewis
> > Thus, what I'm looking for here is way to store the information and then > pass that information to the next query efficiently. > For example, is it possible to define a struct of my choice, private to > the current transaction, that would store the data and then pass it around > to the next qu

Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread Souvik Bhattacherjee
Well the DELETE is not going to work as c.cid will error as undefined. > Yes, that's a typo. I haven't tested it out before typing; just wanted to convey the general idea. -SB On Thu, Apr 18, 2019 at 10:50 AM Adrian Klaver wrote: > On 4/17/19 5:30 PM, Souvik Bhattacherjee wrote: > > There are

Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread Souvik Bhattacherjee
Thanks Michel. However this only works if a is an unique attribute in the table that would help us to identify tuples that participated in the join. Consider the following join: insert into table3 (id, level, empname, salary) (select t0.cid, t0.level, t1.empname, t2.salary from table0 t0, table1

Re: Method to pass data between queries in a multi-statement transaction

2019-04-18 Thread Adrian Klaver
On 4/17/19 5:30 PM, Souvik Bhattacherjee wrote: There are few if any situations where you need to immediately and completely pass all values from one query to another in the same transaction where the queries cannot just be combined into a single statement.  Your representative example is one t

Re: Method to pass data between queries in a multi-statement transaction

2019-04-17 Thread Michel Pelletier
On Wed, Apr 17, 2019 at 5:30 PM Souvik Bhattacherjee wrote: > > What if I need the result of the join to be stored into table3 as well > as the tuples that participated in the query to be deleted from table1. The > following can be done without the need to transfer values from the previous > quer

Re: Method to pass data between queries in a multi-statement transaction

2019-04-17 Thread Souvik Bhattacherjee
One can argue here that we can use the results from table3 to perform the delete operation instead of joining again. But table3 may be subject to updates which makes the situation tricky. On Wed, Apr 17, 2019 at 8:30 PM Souvik Bhattacherjee wrote: > There are few if any situations where you need

Re: Method to pass data between queries in a multi-statement transaction

2019-04-17 Thread Souvik Bhattacherjee
There are few if any situations where you need to immediately and completely pass all values from one query to another in the same transaction where the queries cannot just be combined into a single statement. Your representative example is one that is easily combined into a single statement. > W

Re: Method to pass data between queries in a multi-statement transaction

2019-04-17 Thread Adrian Klaver
On 4/17/19 3:04 PM, Souvik Bhattacherjee wrote: Hello, I'm trying to pass some values between queries in a multi-statement transaction. For example, consider the following representative multi-statement transaction: begin; select * from table1 t1, table2 t2 where t1.cid = t2.cid; delete from

Re: Method to pass data between queries in a multi-statement transaction

2019-04-17 Thread David G. Johnston
On Wed, Apr 17, 2019 at 3:04 PM Souvik Bhattacherjee wrote: > Hello, > > I'm trying to pass some values between queries in a multi-statement > transaction. For example, consider the following representative > multi-statement transaction: > > begin; > select * from table1 t1, table2 t2 where t1.ci

Method to pass data between queries in a multi-statement transaction

2019-04-17 Thread Souvik Bhattacherjee
Hello, I'm trying to pass some values between queries in a multi-statement transaction. For example, consider the following representative multi-statement transaction: begin; select * from table1 t1, table2 t2 where t1.cid = t2.cid; delete from table1 where cid in (values-to-be-populated-from-the