Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert statement for multiple tables 1

Status
Not open for further replies.

zl

Programmer
Apr 20, 2001
3
US
How do you insert records into multiple tables.
 
With multiple insert statements. ANSI SQL syntax is
INSERT INTO table_name VALUES ......
Consequently, there is only accomodation for one table per statement.
If you have a complex view, it may be possible to insert into the view and let the system figure out which columns go where, but this depends on (a) your RDBMS and (b) how your view/tables are structured.
 
Hiya,

As mentioned by carp, you can insert into multiple tables using a view. HOWEVER, you need to make sure that all the fields that are not nulls in any of the tables used in the view are mentioned in the select statement, otherwise the insert will fail. Also, you must make sure that you have write privilages into the relevant databases that the select refers to, or it will fail.

Finally, you need to check if there are any triggers attached to any of the tables, and if so, that you have specified all the information that these may require...to top all that off, check for potential deadlock conflicts, to the trigger using a table you have also used in the view.....

Good luck,

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top