Coast Line
asked on
Dynamically listing table in MYSQL
Hi well i am running this query in <cfquert tag as:
SHOW FULL tables
the above is run in <cfquery> to get all the tables from mysql. database
ok when i use CFDUMP it comes as:
TABLES_IN_MYDATABASENAME
tabl1
table2
table3
etc
Now when i use another database i have to hard code the databaseName to get all tables like:
TABLES_IN_MYDATABASENAME2
Mytabl1
Mytable2
Mytable3
etc
I tried something like this:
<cfset dbName = listGetAt(list.columnList, 3,"_")>
<cfoutput>#evaluate("table s_in_"&dbN ame)#</cfo utput>
to get the databaseName dynamically and get the tablesName exactly but it is not working as though.
Please help
SHOW FULL tables
the above is run in <cfquery> to get all the tables from mysql. database
ok when i use CFDUMP it comes as:
TABLES_IN_MYDATABASENAME
tabl1
table2
table3
etc
Now when i use another database i have to hard code the databaseName to get all tables like:
TABLES_IN_MYDATABASENAME2
Mytabl1
Mytable2
Mytable3
etc
I tried something like this:
<cfset dbName = listGetAt(list.columnList,
<cfoutput>#evaluate("table
to get the databaseName dynamically and get the tablesName exactly but it is not working as though.
Please help
<cfoutput query="list">
<tr>
<td><cfset dbName = listGetAt(list.columnList,3,"_")>
<!---<cfoutput>#evaluate("tables_in_"&dbName)#</cfoutput>--->
#TABLES_IN_TESTTABLE#
</cfoutput>
ASKER
the datasource is dyanmic as datasource is stored in session and based on that session. if datasource is mysql
then the query will run based on the datasource selected.
Here is what i tried and get this result:
<cfoutput query="list">
<tr>
<td><cfif session.dsntype eq 'mysql'>
<cfset dbname = ucase(listlast(listfirst(l ist.column list), "_"))>
#list['TABLES_IN_' & dbname]#<br />
<cfelse>
Blah Blah Blah
</cfif>
</cfoutput>
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Complex object types cannot be converted to simple values.
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
then the query will run based on the datasource selected.
Here is what i tried and get this result:
<cfoutput query="list">
<tr>
<td><cfif session.dsntype eq 'mysql'>
<cfset dbname = ucase(listlast(listfirst(l
#list['TABLES_IN_' & dbname]#<br />
<cfelse>
Blah Blah Blah
</cfif>
</cfoutput>
The web site you are accessing has experienced an unexpected error.
Please contact the website administrator.
The following information is meant for the website developer for debugging purposes.
Error Occurred While Processing Request
Complex object types cannot be converted to simple values.
The expression has requested a variable or an intermediate expression result as a simple value, however, the result cannot be converted to a simple value. Simple values are strings, numbers, boolean values, and date/time values. Queries, arrays, and COM objects are examples of complex values.
another ooops on my part! (too much beer i guess...)
change this:
#list['TABLES_IN_' & dbname]#
to this:
#list['TABLES_IN_' & dbname][currentrow]#
change this:
#list['TABLES_IN_' & dbname]#
to this:
#list['TABLES_IN_' & dbname][currentrow]#
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Azadi
Open in new window