From: | Sam Stearns <sam(dot)stearns(at)dat(dot)com> |
---|---|
To: | pgsql-sql <pgsql-sql(at)lists(dot)postgresql(dot)org> |
Subject: | Postgres View DDL |
Date: | 2024-10-16 21:33:37 |
Message-ID: | CAN6TVj=gp68UdbiWT1n5csgC=KsZojuM6vnt3ZgmKNkmkVeCxQ@mail.gmail.com |
Views: | Whole Thread | Raw Message | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
Howdy,
I have an Oracle view that's been converted for Postgres. This block of
code in the Oracle view DDL:
TO_NUMBER (NVL (REGEXP_REPLACE (broker_mc, '[^0-9]+', ''), 0)),
TO_NUMBER (NVL (REGEXP_REPLACE (carrier_mc, '[^0-9]+', ''), 0)),
TO_NUMBER (NVL (REGEXP_REPLACE (freight_forwarder_mc, '[^0-9]+', ''), 0)),
has been converted for Postgres as:
(coalesce(REGEXP_REPLACE(broker_mc, '[^0-9]+', '', 'g'), 0))::numeric ,
(coalesce(REGEXP_REPLACE(carrier_mc, '[^0-9]+', '', 'g'), 0))::numeric ,
(coalesce(REGEXP_REPLACE(freight_forwarder_mc, '[^0-9]+', '', 'g'),
0))::numeric ,
which is throwing the following error:
ERROR: COALESCE types text and integer cannot be matched
LINE 43: ...ce(REGEXP_REPLACE(broker_mc, '[^0-9]+', '', 'g'), 0))::numer...
^
I have been looking through:
https://www.postgresql.org/docs/current/functions-conditional.html#FUNCTIONS-COALESCE-NVL-IFNULL
https://www.postgresql.org/docs/current/typeconv-union-case.html
but I'm not seeing a way to resolve it. Would anyone be able to advise how
to correct this for Postgres, please?
Thanks,
Sam
--
*Samuel Stearns*
Lead Database Administrator
*c:* 971 762 6879 | *o:* 503 672 5115 | DAT.com
[image: DAT]
<https://www.dat.com/?utm_medium=email&utm_source=DAT_email_signature_link>
From | Date | Subject | |
---|---|---|---|
Next Message | Sam Stearns | 2024-10-16 21:42:28 | Re: Postgres View DDL |
Previous Message | Sam Stearns | 2024-10-16 16:15:11 | Re: Oracle ==> Postgres View |