Subject | INSERT INTO Multiple Tables |
---|---|
Author | Robert DiFalco |
Post date | 2003-03-24T20:32:07Z |
Sorry for the naïve question, but is it possible to insert into multiple tables using a single statement?
Say I want to do the following:
PreparedStatement ps = con.prepareStatement(
"INSERT INTO Persistent(id,classtype) VALUES (?,?); " +
"INSERT INTO Named(persistentId,name) VALUES (?,?)" );
ps.setInt( 1, id );
ps.setString( 2, classtype );
ps.setInt( 3, id );
ps.setString( 4, name );
Note that I want the parameters to be positioned 1,2,3, and 4.
R.
Say I want to do the following:
PreparedStatement ps = con.prepareStatement(
"INSERT INTO Persistent(id,classtype) VALUES (?,?); " +
"INSERT INTO Named(persistentId,name) VALUES (?,?)" );
ps.setInt( 1, id );
ps.setString( 2, classtype );
ps.setInt( 3, id );
ps.setString( 4, name );
Note that I want the parameters to be positioned 1,2,3, and 4.
R.