We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

example for calculation of value

Hi,

what is the preferred way to make calculations on exsisting values?
I get the values from a SQL Server and want to make calculations on them.
I tried this using UpdateAttribute Processor but the calculated value didn´t show up
in the file.
Is there some kind of option to get them to show up in the file?

I also tried using a script(Javascript) using OutputStreamCallback to do this. But this didn´t work either.
Can you provide me with an example on how to do this?
Thanks.

Regards,
Patrick

4 Replies

KS Karthikeyan SankaraVadivel Syncfusion Team March 27, 2017 07:21 AM UTC

Hi Patrick,  

Thank you for contacting Syncfusion support.  

what is the preferred way to make calculations on exsisting values?

 
The Data Integration Expression Language provides the ability compare them to other values, and make some calculations on the existing values. 

Please refer the Expression language guide for more details - https://help.syncfusion.com/data-integration/expression-language-guide  
I get the values from a SQL Server and want to make calculations on them.
I tried this using UpdateAttribute Processor but the calculated value didn´t show up 
in the file.  
In Data Integration Platform, we have provided the preloaded sample Data flow(templates) that deals with data transformation.  
Some of them are ,  
·         Boolean Operations 
·         Column Operations 
·         Conditional Operations 
·         Mathematical Operations 
·         Searching Operations 
·         String Manipulation 
·         Substring Operations 
·         JsonToSQL 

In order to utilize this sample you need to initiate the preloaded samples in to the Data Integration Platform.  
I also tried using a script(Javascript) using OutputStreamCallback to do this. But this didn´t work either.

 
In order to execute your scripts you can use “ExecuteScript” processor to achieve your use case.  

Can you provide me with an example on how to do this? 
Please refer our above mentioned example templates for data transformation.  
  


Regards, 
Karthikeyan S  



GK Gregory Kohle March 28, 2017 06:24 AM UTC

Hi Karthikeya,thanks for your response.I got a simple script working, where the values from the sql server are overwritten with Hello World.How do I get the script to append the value to the exsisting values?How do I read a specific value from the content of the flowfile? Is this possible via a script or is a custom processor the better solution?I tried to use session.append instead of session.write, but this resulted in a MethodMissingException.My script is attached.The use case would be the following: Execute SQL -> ExecuteScript-> SplitAvro-> ConvertAvroToJSON->ConvertJSONToSQL->PutSQLScript: import org.apache.commons.io.IOUtils    import java.nio.charset.StandardCharsets         flowFile = session.get()    if(!flowFile) return    def txt = 'Hello world!'    // Cast a closure with an inputStream and outputStream parameter to StreamCallback    flowFile = session.write(flowFile, {inputStream, outputStream ->      text = IOUtils.toString(inputStream, StandardCharsets.UTF_8)        outputStream.write(txt.getBytes(StandardCharsets.UTF_8))    } as StreamCallback)    session.transfer(flowFile, REL_SUCCESS)What would be the correct input for the module directory for a javascript script?Thanks. Regards,Patrick


GK Gregory Kohle March 28, 2017 07:22 AM UTC

Hi Karthikeya,

got it working now.

Regards,
Patrick


KS Karthikeyan SankaraVadivel Syncfusion Team March 28, 2017 12:56 PM UTC

Hi Patrick,  

Thank you for contacting Syncfusion Support.   

Please get back to us if you need further assistance. We will happy to assist you.  

Regards,  
Karthikeyan S   


Loader.
Up arrow icon