Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us in Toronto Sept 9th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Load Variable from Database and assign to Context variable

I tried to Load value from database and set in a context variable.

I have a table DatabaseConfig and two column (key,value).

Created two context in my job as key and value.

When i try to run the job, the output i am receiving is null

Labels (3)
1 Solution

Accepted Solutions
vboppudi
Partner - Creator III
Partner - Creator III

Hi Dinesh,

 

Are you looking read context values from DB and assign to context variables in job?

 

0683p000009LtIf.png

 

For this you need to define context variable name is same as key value in database.

Here key value is day, so you need to define context variable name as day. Then tContextLoad will assign value (monday) to context "day" 

 

0683p000009Lt3S.png

 

Hope this helps you.

 

Regards,

 

View solution in original post

9 Replies
TRF
Champion II
Champion II

Hi,

Can you share your job design?

At least, which components are you using?

Anonymous
Not applicable
Author

I attached my job design.


Capture.PNG
TRF
Champion II
Champion II

It should work.

Double check variables name in your tJava component.

Also verify columns name in SQL schema are aligned with context variables name defined for the job.

 

Anonymous
Not applicable
Author

I have attached 4 files.

-> Database table

-> Context variable for my Job

-> SQL Input connection page

-> Page where to load context detail from DB.

Could you check this and let me know for any further information


ContextVariable.PNG
databasepage.PNG
MSSQLDB.PNG
SQL.PNG
TRF
Champion II
Champion II

What's in your tJava component?

What's in your tMSSqlInput component? Should have 2 fields, not 3 as there in the table.

Anonymous
Not applicable
Author

I am getting output as :

 

Starting job DatabaseJob at 16:57 30/03/2018.

[statistics] connecting to socket on port 3429
[statistics] connected
Implicit_Context_Context set key "days" with value "monday"
Warning: Parameter "days" is a new parameter of Implicit_Context_Context
Warning: Parameter "Key" has not been set by Implicit_Context_Context
Warning: Parameter "Value" has not been set by Implicit_Context_Context
tContextLoad_4 set key "days" with value "monday"
hi


DatabaseJob

[statistics] disconnected
Job DatabaseJob ended at 16:57 30/03/2018. [exit code=0]

 

 

tJava i am printing :

 

System.out.println("hi");

System.out.println(context.Key);
System.out.println(context.Value);
System.out.println(jobName);

Anonymous
Not applicable
Author

databasepage -> this jpg which i attached is tMSSqlInput component.

Ok i changed my Database table to two columns. 


NewDB.PNG
vboppudi
Partner - Creator III
Partner - Creator III

Hi Dinesh,

 

Are you looking read context values from DB and assign to context variables in job?

 

0683p000009LtIf.png

 

For this you need to define context variable name is same as key value in database.

Here key value is day, so you need to define context variable name as day. Then tContextLoad will assign value (monday) to context "day" 

 

0683p000009Lt3S.png

 

Hope this helps you.

 

Regards,

 

Anonymous
Not applicable
Author

what if i want to read values from the queries and store them into globalmap variables??

ex: If i am using tmssqlinput and query is:

"select col1 from table1;

select col2 from table2;

"

Note: for the above query i am getting value for col1 only, col2 is NULL even after setting the additional jdbs parameters with "allowMultiQueries=true"

 

Please help