1 Reply Latest reply: Jun 19, 2013 10:23 AM by Dave Riley RSS

    FieldName not working as expected?

    Damian Rowe - Do not contact for downloads

      Hi All,

       

      I'm trying to create a table that holds the names and position numbers of fields in a QVD. 

       

      For example if I have a QVD with the following fields:

      FIELDA, FIELDB, FIELDC

      The table would be:

      FIELDNAME FIELDPOSITION

      FIELDA          1

      FIELDB          2

      FIELDC          3

       

      The script I've written for this is:

       

      EMPTYTABLE:
      LOAD *
      FROM QVDNAME (qvd)
      where 1 = 0;

       

      TABLE_FIELDS:
      load IterNo() as FIELD_NUMBER,
      FieldName(IterNo(), 'EMPTYTABLE') as FIELD_NAME
      autogenerate 1
      while IterNo() < NoOfFields('EMPTYTABLE');

       

      This produces a table with the correct number of rows.  FIELD_NUMBER is populated correctly but FIELD_NAME is null. 

       

      Have I missed something obvious?  I'd be greatful for any help/explanations!

        • Re: FieldName not working as expected?
          Dave Riley

          I wouldn't do it that way. Access the XML structure as this ...

           

          TABLE_FIELDS:

          LOAD

              Rowno() as FIELD_NUMBER,

              FieldName as FIELD_NAME

          FROM [{name}.qvd] (XmlSimple, Table is [QvdTableHeader/Fields/QvdFieldHeader]);

           

          .. really simple and quick.

           

          flipside

           

           

          EDIT: If querying multiple qvds, then the Rowno() will continue incrementing from last stored value, so RecNo() might be neaded to give you the Field_Number within the QVD.