Six Stars

Problem with Result of sql query and how to add him to an other sql query

Hello again, I have now a sql query , but it return 7 or 8 query instead of 5

And and my query is not returning a result, he return me only the full query

SELECT   * FROM table  where   C_USER_A=(SELECT max(C_USER) as c_user FROM user WHERE  name= 'this.name')

I want to execute the query , how should i do ?

 

toos.PNG

String name;
String resultat= ((String)globalMap.get("tOracleRow_2_QUERY"))+'(' + ((String)globalMap.get("tOracleRow_1_QUERY"))+')';
System.out.print(resultat);

 

this is my java code 

Tags (3)
1 ACCEPTED SOLUTION

Accepted Solutions
Thirteen Stars TRF
Thirteen Stars

Re: Problem with Result of sql query and how to add him to an other sql query

Hi,
Compare the datatype for the columns returned by the "select *" with the datatype defined for the schema.
Also, the columns order in the schema must be aligned with the order columns for the select.

TRF
4 REPLIES
Thirteen Stars TRF
Thirteen Stars

Re: Problem with Result of sql query and how to add him to an other sql query

Hi again,

What do you expect from the tJava component.

Remember this rule from the documentation:

"You can use a tJava component to integrate your custom Java code into a Talend program. It applies exclusively to the start of the generated code of the subjob: it will be executed first, but only once in the subjob. Normally, tJava has no input or output data flow and is used as a separate subjob."

What is the result from the "print" operation? 


TRF
Six Stars

Re: Problem with Result of sql query and how to add him to an other sql query

 

SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name1')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name2')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name3')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name4')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name5')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name6')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name7')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name8')
SELECT   * FROM MY_TABLE  where   MY_TABLE.my_row  =(SELECT max(USER.rows) as rows FROM USER WHERE  USER.name = 'name9')

The java print return this

 

In my Job, I want to get the user.rows and adding this to an other sql query to insert an element to my DB

 

I don't know how can I see the result of my query, I tried with tOracleInput but he say me Error "ORA-01722"

Thirteen Stars TRF
Thirteen Stars

Re: Problem with Result of sql query and how to add him to an other sql query

Hi,
Compare the datatype for the columns returned by the "select *" with the datatype defined for the schema.
Also, the columns order in the schema must be aligned with the order columns for the select.

TRF
Thirteen Stars TRF
Thirteen Stars

Re: Problem with Result of sql query and how to add him to an other sql query

Hi,

Does this help?

If so, thank's to mark your case as solved (Kudos also accepted).


TRF