6 Replies Latest reply: May 31, 2016 4:53 PM by Marco Wedel RSS

    How can I insert random values into pre-loaded fields in a table? [Initial script provided]

    John Blomqvist

      Hi all,

       

      I have the following script:

       

      ColumnTable:

       

      LOAD * INLINE [

       

      FieldName, DataFormat, Dependency

       

      OrderID, Numeric, None

       

      OrderDate, Datetime, None

       

      CustomerID, String, None

       

      CustomerName, String, None

       

      DispatchDate, Date, OrderDate

       

      ];

       

      FieldList:

      LOAD Concat(

       

        Pick(Match(DataFormat,'Numeric','Datetime','String','Date'),

       

        'Round(100*Rand())',

       

        'Timestamp(Makedate(2016)+Rand()*366)',

       

        'CHR(ORD(''A'')+floor(Rand()*26))',

       

        'Date(Makedate(2016)+floor(Rand()*366))'

       

        ) & ' AS [' & FieldName & ']', ', ') AS ColumnList RESIDENT ColumnTable;

       

       

       

      LET vColumnList = peek('ColumnList');

       

      DataTable:

       

      LOAD $(vColumnList)

       

      AUTOGENERATE 1000;

       

      -------------------------

       

      What I would like to do is populate the DataTable fields, OrderID, OrderDate, CustomerID, CustomerName, DispatchDate with values.

       

      Take the example of CustomerID and CustomerName. The values for the fields should be populated from the table below:

       

      CustomerIDCustomerName
      1Coca Cola
      2Nike
      3Apple
      4Microsoft
      5Dell

       

      I would like to populate CustomerID in the DataTable with random CustomerID's from 1 to 5 in the table above, and CustomerName in the DataTable with CustomerName values in the table above.

       

      How can I achieve this in the existing script please?