One Star

Reading queries from .sql file and parsing query

Hi everyone,
My query is that I need to pass the output of an certain SQL query to target destination. let me elaborate the scenario.
I have an .sql file with an query.
Query: select empno, empname, sal, designation, company from EMP
This query will generate an output,
103 advani 100 gm infy
104 amit 100 developer TCS
Now my requirement is that this output is not seen in Talend Data Integration anywhere. I want to pass this query such that the respective output will be either transferred to similar database or be stored in an txt file in deliminated form.
I tried tSQLRow & tFileInputFullRow but couldn't figure out any way....
Let me explain again, I want to pass an SQL query in Talend Data Integration and output of respective query to be transferred in target database or deliminated file.
I tried running insert and update queries using tSQLRow, they work fine. Even the select queries work, but the obtained outpt needs to be used somewhere else.
3 REPLIES
Moderator

Re: Reading queries from .sql file and parsing query

Hi,
Now my requirement is that this output is not seen in Talend Data Integration anywhere. I want to pass this query such that the respective output will be either transferred to similar database or be stored in an txt file in deliminated form.
I tried tSQLRow & tFileInputFullRow but couldn't figure out any way....

Did you use tXXXinput component to execute sql query? Actually, I have made a demo job: tMySqlInput-->tlogrow to see the output. see my pics
Or you want to pass query into output file?( select empno, empname, sal, designation, company from EMP)
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.
One Star

Re: Reading queries from .sql file and parsing query

Thanks xdshi,
I tried your method in Oracle instead of SQL, thanks it worked. But I have doubt. The values of table is seen in the query editor of tOracleRow as seen in screenshots. Also in tLogRow, I got output, but the data in table is shown as null. Why is it so?
Also I want to load the displayed data in tLogRow in deliminated file or similar structured database...... please help....
Moderator

Re: Reading queries from .sql file and parsing query

Hi,
The values of table is seen in the query editor of tOracleRow as seen in screenshots. Also in tLogRow, I got output, but the data in table is shown as null. Why is it so?

As a matter of fact, we usually use t<DB>Input to execute a select query, you have to use a tParseRecordSet after t<DB>Row to parse the record set if you use t<DB>Row to execute a select query.
Please see the component reference tMysqlRow with related scenarios.
Best regards
Sabrina
--
Don't forget to give kudos when a reply is helpful and click Accept the solution when you think you're good with it.