>>>>> "Jani" == Jani Tolonen <janikt@stripped> writes:
Jani> Pete Lancashire writes:
>> Hi ..
>>
>> What are the errno's returned from mysqlshow and
>> what will cause an error.
Jani> Hello Pete,
Jani> Can you be more specific about the error that occurred?
Jani> What was the output from mysqlshow _exactly_?
Jani> See 'perror --help'.
>> Or is there a better way to test if a particular
>> table exists, other then grepping through the
>> text that mysqlshow sends to stdout.
Jani> Doesn't sound too bad idea to me to do it that way.
>> Or .. is there a DBI call, that I don't have to
>> scan through the results (DBI->data_sources,
sth-> {table}).
Jani> Sorry, but the above is deprecated.
Jani> Best way to do the above is perhaps to do a small
Jani> perl function, which tests if a table exists.
Jani> I'm sure you can do one yourself, but here is an
Jani> example how to do it:
Jani> -----------------------------------------------------
Jani> ####
Jani> #### Test if a specific table exists
Jani> #### Return values: 1 if table exists, else 0
Jani> #### Args: database handler, table name
Jani> ####
Jani> sub if_exists_tbl
Jani> {
Jani> my ($dbhandler, $tbl_name) = @_;
Jani> $sth = $dbhandler->prepare("show tables");
Jani> die "Error: $DBI::errstr" if (!$sth->execute);
Jani> while (($row = $sth->fetchrow_arrayref))
Jani> {
Jani> return 1 if ($row->[0] eq $tbl_name);
Jani> }
Jani> return 0;
Jani> }
Jani> -----------------------------------------------------
<cut>
You can of fourse also do "show tables like '$tbl_name'".
Regards,
Monty