简体   繁体   中英

Trying to migrate from Oracle to PostgreSQL

SELECT b.SERVICENAME,
       a.PARAMETERNAME,
       a.PARAMETERVALUE
FROM serviceParameter a,
     subscriberService b,
     serviceName c
WHERE a.SUBSCRIBERKEY (+) = 15677889
  AND b.SUBSCRIBERKEY = 15677889
  AND b.SERVICENAME = a.SERVICENAME(+)
  AND c.SERVICENAME = b.SERVICENAME
  AND c.MULTIINSTANCE = '0'
ORDER BY a.SERVICENAME;

How can I migrate the above code to PostgresSQL?

You have to translate it along these lines:

SELECT ...
FROM a, b
WHERE a.x = b.y(+)
  AND a.p = 42
  AND b.q(+) = 'foo';

will become:

SELECT ...
FROM a LEFT OUTER JOIN b
        ON a.x = b.y
           AND b.q = 'foo'
WHERE a.p = 42;

That is:

  • The side with the (+) becomes the right side of a LEFT OUTER JOIN (or, equivalently, the left side of a RIGHT OUTER JOIN ).

  • All the WHERE conditions that contain a (+) lose that adornment and go into the join condition .

It is easy to translate Oracle's join syntax to standard conforming syntax because the latter is more powerful (and easier to read to boot).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM