in reply to nested dbi queries question
This really has nothing to do with Perl or DBI. You can do it with a single SQL, barring minor SQL dialect variations (you don't mention what database you're using).
If you have to execute that from Perl, just put the whole thing in a $dbh->do(...).SELECT * INTO sp_err FROM sp WHERE NOT EXISTS ( SELECT 1 FROM supplier WHERE sp.num = supplier.num )
Update
The SELECT * INTO form is non-standard SQL that's supported only a few places (Sybase comes to mind). The equivalent in standard SQL, presuming sp and sp_err have the same columns, would be:
As to "moving" rows: your original post didn't do that: it only inserted rows into sp_err. As to why it didn't work, see my reply elsewhere in this thread.INSERT INTO sp_err SELECT * FROM sp WHERE NOT EXISTS ( SELECT 1 FROM supplier WHERE sp.num = supplier.num )
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: nested dbi queries question
by philosophia (Sexton) on Feb 01, 2005 at 23:23 UTC | |
by runrig (Abbot) on Feb 02, 2005 at 00:11 UTC | |
|
Re^2: nested dbi queries question
by philosophia (Sexton) on Feb 03, 2005 at 20:02 UTC |