Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
cancel
Showing results for 
Search instead for 
Did you mean: 
Prakhar1
Creator III
Creator III

Assign value to context variable from database table

Hi,

I have a table name as "record" having one column as "column_val" and their are 3 rows and  the data is like

column_val

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

a

b

c

 

I have 3 context variables names as "varA","varB" and "varC".

Now, i want to load the first row value to varA, second row value to varB and 3rd row value to varC.

Can someone Help on this?

Labels (2)
1 Reply
iamabhishek
Creator III
Creator III

One way of doing it would be to use tDenormalize on your input data. This would transform your input data from row to columns. In tDenormalize you could specify anything as your delimiter. Once that is done take the output from tDenormalize and use it inside tJavaRow and use a bit of String functions to split the string into multiple parts - in your three parts and assign them to three different context variables.
0683p000009M75Y.jpg0683p000009M75d.jpg0683p000009M75n.jpg

//Code generated according to input schema and output schema
System.out.println("After denormalize: "+input_row.column_val);
String[] parts = (input_row.column_val).split(",");
context.new1 = parts[0];
context.new2 = parts[1];
context.new3 = parts[2];
System.out.println("After split-context1: "+context.new1);
System.out.println("After split-context2: "+context.new2);
System.out.println("After split-context3: "+context.new3);