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

DavidZ <[email protected]>
Newsgroups gmane.comp.jakarta.turbine.torque.user
Message-ID <[email protected]>
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
<[email protected]>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 <[email protected]> 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
>
>
>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.