5 Replies Latest reply: Sep 3, 2018 1:51 PM by Rob Wunderlich RSS

    Having trouble with variable & if..then in Data Load Editor

    Elizabeth Oram

      Hello,

       

      I'm trying to create a script that first loops through & loads the FileBaseName() of all files ending with .qvd in a folder, then, if a certain filename doesn't exist, create that file by loading another file and saving it to that filename.

       

      The first part looks like this, and works like it's supposed to, i.e. it loads a table with each filename.

       

      Directory [$(vSource)/QVDs & CSVs/Archive QVDs];

      For Each File in FileList('*.qvd')

      ArchiveFiles:
          Load Distinct
           FileBaseName() as Archive
          From [$(File)](qvd);
         
      Next File;

       

      Then, I want to check if a certain filename exists in the field Archive. If it doesn't, I want to create the file and then drop the table ArchiveFiles, and if it does, I just want to drop the table ArchiveFiles. I've tried creating a variable that will be True or 1 or Y if the filename exists in the Archive field, and False or 0 or N if it doesn't, and then using the value of that variable in an If..then..else..end if statement. I haven't been able to get it to work. I've also tried directly using the Match() function in the if statement, and that hasn't worked either. Can anyone give some advice on this?

        • Re: Having trouble with variable & if..then in Data Load Editor
          Elizabeth Oram

          To clarify, I have been able to get a variable that returns the correct answer to whether the filename exists in the Archive field or not. The problem occurs with the following If..then..else..end if part. So far I've been using this structure:

           

          If vArchive='False' then

           

          Tablename:

          Load *

          From [file location](qvd);

           

          Store Tablename into [archive file location](qvd)

          Drop tables ArchiveFiles, Tablename;

           

          Else

           

          Drop table ArchiveFiles;

           

          End if;

           

          What's happening is that the value of vArchive is equal to True, but the if statement is acting as if it's False.