More: Getting table and field names

Jan Schenkel janschenkel at yahoo.com
Mon Aug 6 14:12:36 EDT 2007


--- Mikey <mikeythek at gmail.com> wrote:
> I'm looking all over but I can't find SQL commands
> to use with ODBC to
> extract the table names for a database, and once I
> have those to
> extract the column names for a table.  My SQL is
> pretty darn rusty, in
> case you couldn't figure that out already.
> 
> TIA.
> 

Oops, I forgot to explain how you can fetch the column
information; the following code is rather crude, but
it does the trick until we get full schema
information:
##
function qrtdb_TableColumnNames pConnectionID,
pTableName
  local tQuery, tCursor, tColumnNames
  put "SELECT * FROM" && pTableName into tQuery
  put revdb_query(pConnectionID, tQuery) into tCursor
  if tCursor is a number then
    put revdb_columnnames(tCursor) into tColumnNames
    get revdb_closecursor
  end if
  return tColumnNames
end qrtdb_TableColumnNames
##

Put the above somewhere in a library stack script, and
then call it like this to extract the information from
a single table:
##
put qrtdb_TableColumnNames(gConnectionID, "images")
into tColumnNames
##

Like I said, it's a crude approach, and some databases
will be rather unhappy if you ask them to prepare an
entire table for a cursor, only to use the cursor
information.
But it has always worked for me - of course, depending
on the database, you can wirte specific queries to
extract column information. But those queries are
again database-dependent.

Hope this helped,

Jan Schenkel.

Quartam Reports & PDF Library for Revolution
<http://www.quartam.com>

=====
"As we grow older, we grow both wiser and more foolish at the same time."  (La Rochefoucauld)


       
____________________________________________________________________________________
Building a website is a piece of cake. Yahoo! Small Business gives you all the tools to get online.
http://smallbusiness.yahoo.com/webhosting 



More information about the use-livecode mailing list