You are viewing a plain text version of this content. The canonical link for it is here.
Posted to torque-user@db.apache.org by Sasikumar Natarajan <ns...@yahoo.com> on 2008/08/20 07:13:41 UTC

how can i Insert data into multiple table at a time

Hi All,
       i am new to apache torque. How can i insert data in to multiple table at one time hit. Actually i have a form to get the user's input and need to insert data in multiple table . Please help me..
Thanks in Advance
Sasi


      

RE: how can i Insert data into multiple table at a time

Posted by Thomas Fischer <fi...@seitenbau.net>.
>        i am new to apache torque. How can i insert data in to 
> multiple table at one time hit.

Hm, I do not know what you mean by that. Please make yourself familiar 
with the appropriate Database concepts (update/insert and transaction). 
These are supported by Torque.

> Actually i have a form to get the 
> user's input and need to insert data in multiple table 

I'd open a transaction, save the data, and commit the transaction.

http://db.apache.org/torque/releases/torque-3.3/runtime/reference/write-to-db.html

http://db.apache.org/torque/releases/torque-3.3/runtime/reference/connections-transactions.html


    Thomas

Re: how can i Insert data into multiple table at a time

Posted by DavidZ <we...@gmail.com>.
and you may want to use transaction here when inserting records to multiple
tables:

        Connection connection = null;
        try {
            connection = Transaction.begin(YouOMPeer.DATABASE_NAME);
            r1.save();
            r2.setRefIndexId(r1.getIndex());
            ....
             r2.save();            }
            Transaction.commit(connection);
        }
        catch(TorqueException e) {
          Transaction.safeRollback(connection);
            throw e;
        }
Hope this will help.

On Fri, Aug 22, 2008 at 11:26 AM, Frank Nguyen
<fr...@sbcglobal.net>wrote:

> There is no difference b/w inserting into 1 table or multiple tables from a
> single form transaction. Read the tutorial at:
>
> http://db.apache.org/torque/releases/torque-3.1.1/user-guide.html
>
> If the second adding/inserting needs a ref index from previous inserted
> row, do something like:
>
> r1.save();
> r2.setRefIndexId(r1.getIndex());
> ....
> r2.save();
>
> Hope this helps,
>
>
>
>
>
> Sasikumar Natarajan <ns...@yahoo.com> wrote: Hi All,
>        i am new to apache torque. How can i insert data in to multiple
> table at one time hit. Actually i have a form to get the user's input and
> need to insert data in multiple table . Please help me..
> Thanks in Advance
> Sasi
>
>
>
>

Re: how can i Insert data into multiple table at a time

Posted by Frank Nguyen <fr...@sbcglobal.net>.
There is no difference b/w inserting into 1 table or multiple tables from a single form transaction. Read the tutorial at:

http://db.apache.org/torque/releases/torque-3.1.1/user-guide.html

If the second adding/inserting needs a ref index from previous inserted row, do something like:

r1.save();
r2.setRefIndexId(r1.getIndex());
....
r2.save();

Hope this helps,





Sasikumar Natarajan <ns...@yahoo.com> wrote: Hi All,
       i am new to apache torque. How can i insert data in to multiple table at one time hit. Actually i have a form to get the user's input and need to insert data in multiple table . Please help me..
Thanks in Advance
Sasi