5 Replies Latest reply: Dec 2, 2013 5:29 PM by Stephen Daspit RSS

    possible to reuse list of fields (and their renames) for repeated use in Load Script?

      Hello! I have a load script that consumes monthly files from an external source having hundreds of static field names and millions of records. To streamline, I only load the minimal set of fields I actually need. I loop through each of the monthly files and concatenate into my existing table of all months.

       

      Note that each monthly file is regenerated every month, so I can't just do an incremental load on the most recent month.

       

      I use a switch statement on a boolean variable to determine whether I'm loading the first month of data into a new combined months table or if I'm loading subsequent months into the exiting combined months table. The switch statement on the boolean variable determines how to set the concatenation.

       

      I mocked up the code below using two fields and their renamed field names to simplify. Right now, I have to maintain identical lists of fields and their renamed values in the TRUE and FALSE blocks within the switch.

       

      Is there any way to push this field list outside of the Switch and just refer to it? This would cut down on manual maintenance and resulting errors of trying to maintain the two lists of fields/aliases in parallel within the switch block.

       

      Let vHasRunFirst = FALSE();
      
      FOR EACH SourceFile IN FILELIST('$(cGenericFileString)')
           SWITCH vHasRunFirst
                CASE TRUE()
      
                     CONCATENATE ($(tCombinedMonths))
                     LOAD
                          ExternalField1 AS 'InternalField1',
                          ExternalField2 AS 'InternalField2'
                     FROM [$(SourceFile)] (QVD)
                     ;
      
                CASE FALSE()
      
                     $(tCombinedMonths):
                     NOCONCATENATE
                     LOAD
                          ExternalField1 AS 'InternalField1',
                          ExternalField2 AS 'InternalField2'
                     FROM [$(SourceFile)] (QVD)
                     ;
      
                     Let vHasRunFirst = TRUE();
           END SWITCH
      NEXT SourceFile
      

       

      I tried googling this and searching the existing QV community forum posts, but I don't see anyone else asking this.

       

      Thanks!