Hitachi Vantara Pentaho Community Forums
Results 1 to 2 of 2

Thread: Dynamic Column Names with Numbers On the End

  1. #1

    Default Dynamic Column Names with Numbers On the End

    I can't figure out how to do the following in spoon:

    Code:
    int index = 1;
    while (index <= 16) {
    double amountVal = //value from column named "Amount'+index (ex: Amount1); date dateVal = //value from column named "Date'+index (ex: Date1); insertToDatabase(amountVal, dateVal); index++;
    }
    I'm attempting to do this in a transaction. I can pull out the values from the database, but I can't figure out how iterate over each column. This code isn't in javascript. It's just prototyped out.
    Last edited by Slutibartfast; 11-28-2017 at 07:56 PM.

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You can use Row-Normaliser for this.
    If you don't know the number of fields involved at design-time, you'll have to use ETL-Metadata-Injection.
    You can determine the column names by querying the information schema of your source database.
    Alternatively, you can use Table-Input (SELECT * FROM ... LIMIT 0) followed by Metadata-Structure-Of-Stream to learn the column names.
    So long, and thanks for all the fish.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.