1 Reply Latest reply: Feb 27, 2012 12:46 PM by Mark McCoid RSS

    Passing Fields to Sub Issue (Like qvc project)

    Mark McCoid

      Hi,

       

      I recently downloaded Rob Wunderlich's QVC package and it inspired me to create a sub routine for a project I was working on.

       

      I created a routine that would accept a tablename, field names and a couple of other parameters so that I could automate the loading of external tables.

       

      All works great until if I pass fields (stored in a variable) like "@1 as Feed2_Name, @2 as Feed2_Zipcode", but when I try to pass a variable that has the following

       

       

      @1 as FEED2_NAME,
      IF(Index(@2,'-')>0,mid(@6,1,index(@2,'-')-1), @2) as FEED2_ZIPCODE, 
      IF(Index(@2,'-')>0,mid(@6,index(@2,'-')+1,4)) as FEED2_ZIP4
      

       

      I get problems because of the single quotes.  They come over as not double quotes, but two single quotes where there use to be one.

       

      IF(Index(@2,''-'')...

       

      Again, this is coming from a variable "vFeed2_Fields".

       

      Any ideas on how I need to structure the information in the variable so this doesn't happen?

       

      Thanks,


      Mark

        • Re: Passing Fields to Sub Issue (Like qvc project)
          Mark McCoid

          Here is what I ended up doing to get this to work.  It feels clunky, but it works:

           

          In the macro that is creating the field list, I use ! instead of single quotes, then AFTER I pass the fields over to routine that is building the table I do a replace:

           

           

          Let _fieldsFinal = Replace('$(_fields)', '!', chr(39)); 
          
          //Build table from passed values
                    [$(_tableName)]:
                    LOAD 
                              $(_fieldsFinal)
                    FROM $(_fileName)
                    (txt, codepage is 1252, no labels, delimiter is '$(_delimiter)', header is $(headerLines) lines, msq);
          
          

           

          If anyone has a better way, please let me know.

           

          Thanks,

           

          Mark