listfields

Lists all the fields in the specified database, SQLResult record set, or SQL table
[listfields Params] Database Tags [/listfields]
To display a list of all the fields in a particular database, put a [listfields] context into a template. You may put a [listfields] context inside the [listdatabases] context to automatically list all the fields in all the databases.

The following tags are available inside a [listfields] context:


TagDescription
[FieldName]the name of the field.
[index]A number from 1 to the total number of fields, indicating this field's index placement in the list.
The following tags are available when using [listfields] to list SQL fields
[ordinal]Will retrieve the literal position of the current iterated field.
[datatype]Will retrieve the named SQL datatype of the current iterated field.
[allownull]Returns whether or not (T or F) the current iterated field will accept a null value as a possible entry/value.
[width]Will retrieve the maximum length of data the current iterated field will allow.
Example WebDNA code:
[listdatabases]
  Fields in database [name]:<br>
  [listfields db=[name]]
   Fieldname: [fieldname]<br>
  [/listfields]
<hr>
[/listdatabases]

To display a list of all fields in an SQL table (after a [SQLConnect] context), specify the SQL connection and database table.

Example WebDNA code:
[listfields conn_ref=conn1&table=inventory]
  <b>[fieldname]</b><br>
  ordinal: [ordinal]<br>
  datatype: [datatype]<br>
  allownull: [allownull]<br>
  width: [width]<br>
<hr>
[/listfields]

To display a list of all fields in a [SQLresult] record set, include the [listfields] inside of a [SQLresult] context.

Example WebDNA code:
[SQLresult result_ref=rs1]
The result set from query "select * from employees;" has [numfields] fields:<br>
  [listfields]
    <b>[fieldname]</b><br>
    ordinal: [ordinal]<br>
    datatype: [datatype]<br>
    allownull: [allownull]<br>
    width: [width]
    <hr>
  [/listfields]
[/SQLresult]