Is there a tag that will help?

Ask a Question related to Coldfusion - Advanced Techniques, Design and Development.

  1. #1

    Default 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

  2. #2

    Default 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

  3. #3

    Default 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

  4. #4

    Default 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

  5. #5

    Default 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

  6. #6

    Default 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]#&nbsp;&nbsp;&nbsp;
    Type (roughly) = #QryMetaData.getColumnTypeName (JavaCast("int",
    iColNum))#<br>
    </cfloop>
    </cfoutput>

    MikerRoo Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139