4 Replies Latest reply: Dec 8, 2017 7:25 PM by Shamit Shah RSS

    Create a key

    Shamit Shah

      Hi,

       

      I have the following in the script and need to create a key

      fldPeronID & PayrollCode  as key1

      in TABLEA

       

      TABLEA:

      LOAD

       

      fldPersonID,

      TravelTime,

      Service

       

      From

      [lib://QVD/Time.qvd]

      (qvd)

       

      LEFT JOIN

      fldPersonID,

      PayrollCode

       

      From

      [lib://QVD/Payroll.qvd]

      (qvd);

       

      Any ideas on how/where I can create the key in TABLEA?

       

      Thanks

        • Re: Create a key
          An Pham

          Hi

          you can using Autonumber function to create a number Key, or concatenate two column fldPeronID & PayrollCode  as key after load TABLEA with Join


          TABLEA_WITH_NEW_KEY:
          Load
          Autonumber (fldPeronID & PayrollCode ) as Key,  // or fldPeronID & PayrollCode  as key
          *
          resident TABLEA ;
          
          
          Drop table TABLEA ;
          
          
          

           

          Regards

          • Re: Create a key
            Luis Madriz

            Hi, I think you need to create a new table and drop TABLEA

             

            NewTableA:

            NoConcatenate

            Load *,

                 fldPeronID & PayrollCode as key1

            Resident TABLEA;

            Drop Table TABLEA;

              • Re: Create a key
                omar bensalem

                I'd suggest :

                NewTableA:

                NoConcatenate

                Load *,

                    autonumber( fldPeronID & '|' & PayrollCode )as key1

                Resident TABLEA;

                Drop Table TABLEA;

                 

                the reason to seperate between the 2 fields by a | for example; is to make sur the key is unique.

                example to illustrate my point :

                fldPeronID=100

                PayrollCode =10

                fldPeronID & PayrollCode =10010

                but

                fldPeronID=10

                PayrollCode =010

                fldPeronID & PayrollCode =10010

                with that, we create the same for 2 differents set of values !

                but if we seperate them by sthing '|', we make sure to have a unique key for each combination.

                then we surround the new key by autonumber to make it as a num