database - oracle grammar to h2 grammar (+) join table -
i have following query oracle
select distinct count(pa.payment_id) location c, inventory e, inventory_stock es, payment_client ep, payment pa, currency cur, location s, exchange_country exc, exchange_rate sso, exchange_hike so, exchange_margin sov cur.outstate = 'n' , c.location_id = e.location_id , e.inventory_id = ep.inventory_id , e.inventory_stock_id = es.inventory_stock_id , ep.client_id = pa.end_client , pa.cur_id = cur.cur_id , cur.location_id = s.location_id , c.client_id not null , cur.cur_id = exc.cur_id(+) , exc.exchange_id = sso.exchange_id(+) , sso.account_id = so.account_id(+) , so.option_name(+) = 'premium' , exc.exchange_id = sov.exchange_id(+) , sov.name(+) = 'value';
right using h2 database , syntax error got so.option_name(+)
, sov.name(+);
know (+) oracle's way of right join , left join there possible way convert h2 error , grammar equivalent?
it's time move on. oracle's legacy outer join syntax no longer recommended oracle. from docs:
oracle recommends use clause outer join syntax rather oracle join operator. outer join queries use oracle join operator (+) subject following rules , restrictions, not apply clause outer join syntax [...]
if replace (+)
usage outer join
, not query work on both oracle , h2, important step forward application whole.
select distinct count(pa.payment_id) location c join inventory e on c.location_id = e.location_id join payment_client ep on e.inventory_id = ep.inventory_id join inventory_stock es on e.inventory_stock_id = es.inventory_stock_id join payment pa on ep.client_id = pa.end_client join currency cur on pa.cur_id = cur.cur_id join location s on cur.location_id = s.location_id left join exchange_country exc on cur.cur_id = exc.cur_id left join exchange_rate sso on exc.exchange_id = sso.exchange_id left join exchange_hike on sso.account_id = so.account_id , so.option_name = 'premium' left join exchange_margin sov on exc.exchange_id = sov.exchange_id , sov.name = 'value' c.client_id not null , cur.outstate = 'n'
the importance when converting (+)
left join
pay close attention predicates must go on
clause, , predicates fine in where
clause. in particular, following 2 predicates must go in relevant left joined table's on
clause:
so.option_name(+) = 'premium'
sov.name(+) = 'value'
Comments
Post a Comment