ClickHouse / clickhouse-jdbc-bridge

A JDBC proxy from ClickHouse to external databases
Apache License 2.0
167 stars 60 forks source link

Need help with using query variables #171

Closed mehanizm closed 1 year ago

mehanizm commented 1 year ago

I'd like to use variable from another query inside jdbc bridge query but do not understand how to do this.

I want to do smth like this:

with max_id as (select max(ID) from table_2)
select
 *

from jdbc('oracle', 'schema', 
   'select
 * from schema.table where id > {{max_id}}');

If it is possible, please, point me to the correct way.

mehanizm commented 1 year ago

I've solved this

select
 *

from jdbc(
    (select concat('oracle?max_id=', toString(max(ID)) from table_2),
    'schema', 
    'select
 * from schema.table where id > {{max_id}}');