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: 
manuk1
Contributor
Contributor

'null' value with a tDBRow to count a number of lines

Hi everyone,

 

I try to execute a SQL query with a tDBRow component to count the number of rows of a table and send it by mail, as a statistic.

 

Example of the Query :

  select count(*) AS NbUpdateMerge1

  from myTable

  where ...

 

So I use an alias and try to identify the wanted data.

 

0695b00000HAG1nAAH.png 

I use a field in my tDBRow schema to store the field identified by the alias :

0695b00000HAGNOAA5.png 

After, I use a tJava (or tJavaRow) component to store the value in a context variable :

  context.Stats1 = row5.NbUpdateMerge1;

 

When I execute, the result is a null value, instead of the real value. Why ?

 

For information, if I use a tDBInput instead of the tDBRow, it works !

6 Replies
gjeremy1617088143

Hi, you can use a tjavarow,

context.Stats1= input_row.NbUpgradeMerge1;

send me love and kudos

manuk1
Contributor
Contributor
Author

Thanks for replying, gjeremy1617088143.

Will test.

 

EDIT : Unfortunately, I receive a NULL value.

tcabre
Contributor
Contributor

Hi you must use tdbinput with ​tjavarow to get the value of count.

jlolling
Creator III
Creator III

The component tDBRow does not provide out-of -the-box the resultset. You have to activate that in the advanced settings.

Once you have activate this option you need to assign the resultset to an output column of the flow.

Next you have to use tParseRecordSet to get the values and tParseRecordSet will also open the actual loop over the result set in case there are more than one row in the result set.

You can also use the incoming flow columns together with the outgoing columns.

But take care, if your resultset does not provide records you will get no output row by the tParseRecordSet.

Conclusion: in your case it should be easier to use a normal tDBInput.

jlolling
Creator III
Creator III

You probably ask your self, what is the purpose of the tDBRow component?

  1. Running any statement even it is not an select
  2. this component can be used within a flow and can take over values from an incoming flow to tweak the select
  3. this component is unfortunately the only one can handle prepared statement parameters (see also in the advanced settings)
manuk1
Contributor
Contributor
Author

Thank you, for the answer.

Will try, if I need this again.