Thanks Francois, your explanation was realy helpful.
-suresh
Francois Orsini wrote:
The quotes are there for the parser to treat the table object
(ansi-92) identifier as case sensitive and for the reason you
mentioned when dealing with objects that have reserved words as
identifiers...
The metadata DatabaseMetaData.getColumns() method does not really take
a table name per-se (to be picky), but more like a table name
"pattern" following the JDBC pattern-matching format convention ('%'
and '_' characters can be used).
I believe the way it is expressed currently in the getColumns() or
getTables() metadata calls is correct as underneath, system catalogs
get queried via an (internal) SQL statement which takes a
case-sensitive string as search predicate to select the matching
tuples - in your case matching the table name expressed in uppercase
will match the table you created (obviously).
One thing you could also do is new'ing a DbTable object for the
qualifying resultset row that matches the table you are looking for
with a getTables() call (using a qualifying/restrictive pattern) and
then specificy the table name to use in the getColumns() call via a
DbTable.getTableName() call...you might want to do this if you want to
ensure you are dealing with a valid table satisfying your search
before returning the columns...
Just some thoughts...
--francois
On 6/22/05, Suresh Thalamati <[EMAIL PROTECTED]> wrote:
I have a table that uses reserved word as name , so it is quoted like :
create table "ORDER"(a int ) ;
All SQL queries seems to expect it as quoted name , except Database
Metadata getColumns(..).
DatabaseMetaData dmd = conn.getMetaData();
ResultSet rs = dmd.getColumns(null, null , "\"ORDER\"" , null) ;
does not return any column information , where as
ResultSet rs = dmd.getColumns(null, null , "ORDER"" , null) ;
retunns the "ORDER" table columns Information.
I am wondering what is the correct usage here , i.e does metadata
calls suppose to
expect quoted tables names like SQL or the one without quotes ?
Thanks
-suresht