Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.
-
BobNims #1
Is there a tag that will help?
I have a giant access table that needs analyzing. I want to be able to print
out every fieldname in the table and the appropriate first row of data for each
field. Is there a method or tag that will allow me to do this without having
to individually type out the fields... Ultimately I would like it to output
like the following...
FieldName: FieldData:
DataType FieldSize
WorkOrderID 1
AutoNumber Long Integer
Recipient Bob Nims
Text 50
RequestedBy Joe Smith
Text 50
Etc....
BobNims Guest
-
Kronin555 #2
Re: Is there a tag that will help?
As far as I know, coldfusion query objects don't contain the DataType and FieldSize information you're looking for. They do contain a list of the columns, accessible through queryname.columnlist.
Kronin555 Guest
-
BobNims #3
Re: Is there a tag that will help?
I've tried the queryname.columnlist but it end up returning the list
alphabetically and all uppercase. I am trying to come up with a quicker way to
analyze this database so I can incorporate it into another app and need to be
able to show where it does not follow our naming conventions, etc...
Appreciate the response though
BobNims Guest
-
MikerRoo #4
Re: Is there a tag that will help?
First the easy part:
If this is a recent version of Access, you can use the "top" statement to get
the first row.
For example: "SELECT TOP 1 dog FROM pack".
As for finding and using the field names -- you can run queries against
Access' system tables.
In Access, Select Tools->Options->View and check hidden and system objects.
The info you want is in there but you are on your own for getting it (make
lots of backups!).
-- MikeR
MikerRoo Guest
-
PaulH #5
Re: Is there a tag that will help?
been a long time since i used access but you might try cfx_tables,
cfx_tableFields, etc. in the
[url]http://www.activsoftware.com/mx/undocumentation/query.cfm[/url].
<cfset columns=yourQuery.columnList>
<cfset metaData=yourQuery.getMetaData()>
<cfoutput>
<cfloop index="column" list="#columns#">
#metadata.getColumnTypeName(yourQuery.findColumn(c olumn))#<br>
</cfloop>
</cfoutput>
PaulH Guest
-
MikerRoo #6
Re: Is there a tag that will help?
That's a neat trick. It gets only vague type info but it sure beats the VB
approach for ease.
Something closer to what was asked for is attached...
<cfquery name="qGetTableVitals" datasource="YOUR_DATA_SOURCE">
SELECT TOP 1 * FROM YOUR_TABLE_HERE
</cfquery>
<cfset QryMetaData = qGetTableVitals.getMetaData ()>
<cfset colNameArray = QryMetaData.getColumnLabels ()>
<cfset QryColCount = QryMetaData.getColumnCount ()>
<cfoutput>
<cfloop index="iColNum" from="1" to="#QryColCount#">
Column = #colNameArray [iColNum]#
Type (roughly) = #QryMetaData.getColumnTypeName (JavaCast("int",
iColNum))#<br>
</cfloop>
</cfoutput>
MikerRoo Guest



Reply With Quote

