Howdy!
The problem is one of reading the file *one command* at a time. If your file
is "well formed" (for any useful definition) such that you could slurp the file
and split it on a simple regex, this trick can work fine.
I had a case where I had the schema in the DATA handle of a module. It went
like this:
foreach (creates())
{
$dbh->do($_) or die...
}
sub creates
{
return split(/^EOC$/m, <<EOS);
CREATE TABLE name
(
id INTEGER PRIMARY KEY,...
)
EOC
CREATE TABLE...
EOC
more create, alter, etc
EOS
}
The trick is being able to split the SQL file into discrete commands.
|