cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X

Dynamic SQL query with PostgreSQL and Thingworx

Sathishkumar_C
17-Peridot

Dynamic SQL query with PostgreSQL and Thingworx

I'm trying to fetch data from PostgreSQL database.

Query,

select 
 entry_timestamp + interval '30 minutes' as offset_timestamp,
 entry_timestamp
from 
 sensor_data

I'm trying to pass 30 minutes from Thingworx input.

select 
 entry_timestamp + interval '<dynamic>' as offset_timestamp,
 entry_timestamp
from 
 sensor_data

How to do that?

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @Sathishkumar_C 

 

You can try something like this. Just pass the whole '30 minutes' (with a single quote) as input to the service

 

c4.PNG

View solution in original post

2 REPLIES 2

Hi @Sathishkumar_C 

 

You can try something like this. Just pass the whole '30 minutes' (with a single quote) as input to the service

 

c4.PNG

Thanks @Velkumar 

 

select 
 entry_timestamp + make_interval(mins => <<offset_interval>>) as offset_timestamp,
 entry_timestamp
from 
 sensor_data

 

Got a expected output with above code. offset_interval (Ex. 30is passing from ThingWorx service.

Below one also working as expected,

select 
 entry_timestamp + <<offset_interval>> as offset_timestamp,
 entry_timestamp
from sensor_data

offset_interval (Ex. interval '30 minutes'is passing from ThingWorx service.

Top Tags