[fpc-pascal] SQL show tables

David B Copeland david.copeland at jsidata.ca
Tue Jan 13 15:33:23 CET 2009


On Tue, 2009-01-13 at 10:37 +0000, Martin Friebe wrote: 
> Joost van der Sluis wrote:
> > Op maandag 12-01-2009 om 13:30 uur [tijdzone -0500], schreef David B
> > Copeland:
> >
> >   
> >> "Query: Cannot open a non-select statement"
> >>     
> >
> > 'show tables' is not a valid sql-statement. It is a MySQL-hack. The
> > TODBCConnection can not see that it is connected to a MySQL server and
> > thus doesn't recognise this statement as a select-statement. If you use
> > a TMySQLConnection it will work. You can fill in a bug report to ask if
> > TODBCConnection can recognise 'show' as 'select'. We'll have to look
> > what kind of effect that has on other (really sql-based)
> > database-servers.
> >   
> If you (the original poster) uses Mysql 5 or up, then "Show tables" is 
> not needed. Use the information-schema instead
> 
> SELECT table_name FROM INFORMATION_SCHEMA.TABLES  WHERE table_schema = 
> '/|db_name|/'
> 

Thanks for all the info. I did try 'show tables' with a TMySQLConnection
and found that it worked. But I like the others suggestions. I've found
that TMySQLConnection.GetTableNames works like a charm, but that
TMySQLConnection.GetTableNames fails with "The metadata is not available
for this type of  database." I would think the GetTableNames is more
portable. So I will file a bug report against GetTableNames.

Dave.





More information about the fpc-pascal mailing list