Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Sameer_Keluskar
Contributor
Contributor

How to query a PostgreSQL DB in talend

Hello,

I am trying to query my PostgreSQL DB using the tDBinput component, but I am getting errors.

Following is my query in the query builder:

"select max(created_date) as max_date from \""+context.orders_table+"\";"

When I try to replace the context variable with the actual table name using the following query, it gives me appropriate results, the following is the query:

select max(created_date) as max_date from "Orders_Table";

 

Could you please help me write a query having a context variable so it runs fine?

Labels (2)
6 Replies
manodwhb
Champion II
Champion II

@Sameer_Keluskar , you need to call the below query in tDBinput and ";" not required.

 

select max(created_date) as max_date from "Orders_Table"

"select max(created_date) as max_date from "\"+context.orders_table+"\""

manodwhb
Champion II
Champion II

@Sameer_Keluskar , you need to call the below query in tDBinput and ";" not required.

 

select max(created_date) as max_date from "Orders_Table"

"select max(created_date) as max_date from "\"+context.orders_table+"\""

Anonymous
Not applicable

Hi Sameer,

 

Try the following: 

"select max(created_date) as max_date from " + context.orders_table

You don't need the semicolon at the end. 

 

Roland

Anonymous
Not applicable

Hi Sameer,

 

Try the following: 

"select max(created_date) as max_date from " + context.orders_table

You don't need the semicolon at the end. 

 

Roland

Anonymous
Not applicable

First of all, what kind of errors you get?

I guess you get the error about missing table?

In this case please change your query this way:

"select max(created_date) as max_date from "+context.orders_table

If you put tables in double quotas this means the table name must exists exactly this way (case sensitive!!) in the database. Mostly this is not the case. I bet your table is shown as order_table in your database browser.

The other problem is the ; at the end of your query. This ; is NOT part of a statement, many tools use this to separate between statements or it is used within code blocks of functions. Oracle e.g. do not accept statements ending with ;

 

Anonymous
Not applicable

First of all, what kind of errors you get?

I guess you get the error about missing table?

In this case please change your query this way:

"select max(created_date) as max_date from "+context.orders_table

If you put tables in double quotas this means the table name must exists exactly this way (case sensitive!!) in the database. Mostly this is not the case. I bet your table is shown as order_table in your database browser.

The other problem is the ; at the end of your query. This ; is NOT part of a statement, many tools use this to separate between statements or it is used within code blocks of functions. Oracle e.g. do not accept statements ending with ;