in reply to Re: DBI, add fields to existing table?
in thread DBI, add fields to existing table?

ALTER TABLE was correct which was suggested before but the syntax I ended up using was:
my $cmd = "ALTER TABLE $dbTable ADD (NAME text, ADDRESS text)"; my $cmd_prep = $db->prepare($cmd); unless($cmd_prep->execute()) { push(@error, "Database insertion error: ".DBI::errstr); } $cmd_prep->finish();
prepare() and execute() is preferred over do()

Replies are listed 'Best First'.
Re^3: DBI, add fields to existing table?
by jZed (Prior) on Aug 21, 2005 at 19:11 UTC
    The finish() in your snippet isn't needed. It is only for fetching data when the fetch is not completed. It's true that prepare() & execute() is preferable when you are executing the same statement many times (prepare once, execute many), but if you are only executing a single statement and especially a statement like ALTER (which can't have any placeholders in it), there is no reason at all to prefer prepare() and execute() over do().