Customer Portal

variable merged into data?

Comments 8

  • Avatar
    avackova
    0
    Comment actions Permalink
    Hello Des,
    I'm not sure if I've understood the task properly, but the following graph should process required transformation:
    <?xml version="1.0" encoding="UTF-8"?>
    <Graph name="xlsDb" >
    <Global>
    <Metadata id="Metadata0">
    <Record fieldDelimiter="|" name="dbMeta" recordDelimiter="\n" type="delimited">
    <Field name="XLSURL" type="string"/>
    <Field name="CustomerID" type="long"/>
    </Record>
    </Metadata>
    <Metadata id="Metadata2">
    <Record fieldDelimiter="|" name="result" recordDelimiter="\n" type="delimited">
    <Field name="First" type="string"/>
    <Field name="Last" type="string"/>
    <Field name="CustomerId" type="string"/>
    </Record>
    </Metadata>
    <Metadata id="Metadata1">
    <Record fieldDelimiter="|" name="xlsMeta" recordDelimiter="\n" type="delimited">
    <Field name="First" type="string"/>
    <Field name="Last" type="string"/>
    <Field auto_filling="source_name" name="fileURL" type="string"/>
    </Record>
    </Metadata>
    <Connection dbConfig="conn/conn.cfg" id="Connection0" type="JDBC"/>
    <Property fileURL="workspace.prm" id="GraphParameter0"/>
    </Global>
    <Phase number="0">
    <Node dbConnection="Connection0" id="DB_INPUT_TABLE0" sqlQuery="select XLSURL, CustomerID from dbdata" type="DB_INPUT_TABLE"/>
    <Node id="EXT_HASH_JOIN0" joinKey="$fileURL=$XLSURL;#" type="EXT_HASH_JOIN">
    <attr name="transform"><![CDATA[//#TL

    // Transforms input record into output record.
    function transform() {
    $0.First := $0.First;
    $0.Last := $0.Last;
    $0.CustomerId := $1.CustomerID;
    }

    ]]></attr>
    </Node>
    <Node id="SIMPLE_COPY0" type="SIMPLE_COPY"/>
    <Node id="TRASH0" type="TRASH"/>
    <Node fileURL="port:$0.XLSURL:source" id="XLS_READER0" type="XLS_READER"/>
    <Edge fromNode="DB_INPUT_TABLE0:0" id="Edge0" inPort="Port 0 (in)" metadata="Metadata0" outPort="Port 0 (out)" toNode="SIMPLE_COPY0:0"/>
    <Edge fromNode="EXT_HASH_JOIN0:0" id="Edge5" inPort="Port 0 (in)" metadata="Metadata2" outPort="Port 0 (out)" toNode="TRASH0:0"/>
    <Edge fromNode="SIMPLE_COPY0:0" id="Edge1" inPort="Port 0 (input)" metadata="Metadata0" outPort="Port 0 (out)" toNode="XLS_READER0:0"/>
    <Edge fromNode="SIMPLE_COPY0:1" id="Edge4" inPort="Port 1 (slave)" metadata="Metadata0" outPort="Port 1 (out)" toNode="EXT_HASH_JOIN0:1"/>
    <Edge fromNode="XLS_READER0:0" id="Edge3" inPort="Port 0 (driver)" metadata="Metadata1" outPort="Port 0 (out)" toNode="EXT_HASH_JOIN0:0"/>
    </Phase>
    </Graph>
  • Avatar
    deshartman
    0
    Comment actions Permalink
    Agata,

    I'll try it today and see if it does the trick.

    Basically I need to insert a "constant" in an extra column off the XLS data. I'll try it and let you know.

    As always thanks for the help

    Des
  • Avatar
    deshartman
    0
    Comment actions Permalink
    Nope, did not do the job. Problem is I do not have a common key to merge with.

    Let me ask the question differently. Is there a way to assign a parameter value to the data? Something like this

    // Transforms input record into output record.
    function transform() {
    $0.supplier_file_id := ${SUPPLIER_ID};

    In this way I can read the dB and get the value I want and then using a Reformat transform, I can assign the parameter to the value in the transform.

    I tried this, but get a syntax error.

    Thanks
    Des
  • Avatar
    avackova
    0
    Comment actions Permalink
    Hi Des,
    if supplier_file_id field is numeric your transformation should work (what message do you get?), if it is string data field, all you need is to quote it:
    $0.supplier_file_id := '${SUPPLIER_ID}';
    while parameters are substituted by theirs values during graph instantiation.
  • Avatar
    deshartman
    0
    Comment actions Permalink
    Agata

    Yep, that did the trick. If I do not have the ' 's I get a syntax error complaining about the "$" value.

    I am unable to set the type of the parameter, so I presume all parameters are String? Here is an extract from the Source

    <Property id="GraphParameter1" name="SUPPLIER_FILE_ID" value="0"/>


    Thanks for the help again.

    Des
  • Avatar
    avackova
    0
    Comment actions Permalink
    If you know this is the number it is better to use a numeric type, while most of the operations is faster on numbers than on strings.
  • Avatar
    deshartman
    0
    Comment actions Permalink
    It is a number, so how would I set up a parameter as numeric type?

    Thanks
    Des
  • Avatar
    avackova
    0
    Comment actions Permalink
    Nothing ;-). If data field is numeric, just write in your transformation:
    $0.supplier_file_id := ${SUPPLIER_ID};

    And the graph "see" it as:
    $0.supplier_file_id := 0;

Please sign in to leave a comment.