I am trying to loop over the tables of a database using the following code getting an error java.lang.UnsupportedOperationException
. i have even tried with cfloop query and other attributes
got errors complex value can't convert to simple value. can anyone tell me how shall i have to loop over this query ? Thanks.
<cfquery name="q" datasource="datasource">
SHOW TABLES FROM datasource
</cfquery>
<cfloop collection ="#q#" item="i">
#q[i]#
</cfloop>
have you tried CFDBINFO? It supports a type of 'tabes' and ought to return you a query of table name, type and remarks for each table.
You are getting that error because cfloop
collection
expects a structure, not a query object. Hence the "UnsupportedOperation..." error.Instead you should use a query loop. The generated column name is dynamic, based on the database name you supply. You can either hard code it or access it dynamically:
That said, I find it easier to use the metadata
INFORMATION_SCHEMA
views. You can query them just like any table. Then output the static column names as usual.How about