public inbox for [email protected]
help / color / mirror / Atom feedFrom: Sam Stearns <[email protected]>
To: pgsql-sql <[email protected]>
Subject: Re: Postgres View DDL
Date: Wed, 16 Oct 2024 14:42:28 -0700
Message-ID: <CAN6TVjkTRYMBEq97tbpLsho1dGxtbJX4T_Gvy_dsZx3U82MEmA@mail.gmail.com> (raw)
In-Reply-To: <CAN6TVj=gp68UdbiWT1n5csgC=KsZojuM6vnt3ZgmKNkmkVeCxQ@mail.gmail.com>
References: <CAN6TVj=gp68UdbiWT1n5csgC=KsZojuM6vnt3ZgmKNkmkVeCxQ@mail.gmail.com>
Tried changing to this:
(coalesce(REGEXP_REPLACE(broker_mc::numeric, '[^0-9]+', '', 'g'), 0)),
(coalesce(REGEXP_REPLACE(carrier_mc::numeric, '[^0-9]+', '', 'g'), 0)),
(coalesce(REGEXP_REPLACE(freight_forwarder_mc::numeric, '[^0-9]+', '',
'g'), 0)),
but that throws this error:
ERROR: function regexp_replace(numeric, unknown, unknown, unknown) does
not exist
LINE 46: (coalesce(REGEXP_REPLACE(broker_mc::numeric, '[^0-9]+', ...
^
HINT: No function matches the given name and argument types. You might
need to add explicit type casts.
Sam
On Wed, Oct 16, 2024 at 2:33 PM Sam Stearns <[email protected]> wrote:
> 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;
>
--
*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;
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected], [email protected]
Subject: Re: Postgres View DDL
In-Reply-To: <CAN6TVjkTRYMBEq97tbpLsho1dGxtbJX4T_Gvy_dsZx3U82MEmA@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox