The problem
You need to collate and rearrange the contents of several databases into one table whenever a given indicator is achieved (the indicator may be, among other things, a stock price, a value in one of the databases, or the flight pattern of African swallows). The format and length of the tables are predictable. There are 5,000 records in each table so manually running a separate INSERT
statement for each record is not a viable option even with the programs used in earlier chapters. The problem calls for a means of iterating through a series and changing the INSERT
statement automatically. Using what we have covered in previous chapters, we could pursue one of the following two ways to do this:
Write a MySQL script to insert the data in batch mode
Iterate over the data to form and execute a MySQL
INSERT
statement accordingly
None of these are a very good solution to the present problem.
Why not a MySQL script?
As we have seen when we created the world
and Sakila
databases, a MySQL script...