public inbox for [email protected]
help / color / mirror / Atom feedFrom: Sam Stearns <[email protected]>
To: [email protected]
Subject: Oracle ==> Postgres View
Date: Tue, 15 Oct 2024 14:30:55 -0700
Message-ID: <CAN6TVjmdUGuFrCn4HcUd4Q2uvNXZSEe_4TXG7neQip_m6dGiBQ@mail.gmail.com> (raw)
Howdy,
I have 2 views attached. An Oracle view written with NVL. The same view
was converted to Postgres using COALESCE. Postgres is throwing an error:
ERROR: syntax error at or near ","
LINE 12: ...esce(CASE WHEN impact_category='BULK_RATE_REQUEST', 1, -- To...
The problem block of code:
coalesce(CASE WHEN impact_category='BULK_RATE_REQUEST', 1, -- To handle
Portal's category for the old RIP
'CONTRACT_BULK_RATE', 1,
'SPOT_BULK_RATE', 2,
'CONTRACT_HISTORY', 3,
'SPOT_HISTORY', 4,
'RATE_SUBMISSION', 5,
'SPOT_BACKHAUL' THEN 6 END , 0),
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;
CREATE OR REPLACE FORCE VIEW CSBTFSPRD.BILLED_RATE_TRANSACTIONS
(
ACCOUNT_ID,
COMPANY_ID,
AUTHENTICATING_ORDER_ID,
AUTHENTICATING_PRODUCT_ID,
AUTHENTICATING_PRICE_CLASS,
AUTHORIZING_ORDER_ID,
AUTHORIZING_PRODUCT_ID,
AUTHORIZING_PRICE_CLASS,
START_DATE,
END_DATE,
TYPE_CODE,
PRICE,
EQUIPMENT,
LANE_COUNT,
LANE_ESTIMATE,
TRANSACTION_ID,
SUBMISSION_ID
)
BEQUEATH DEFINER
AS
SELECT account_id,
company_id,
order_id,
product_id,
price_class,
authorizing_order_id,
authorizing_subscription_type,
authorizing_price_class,
start_date,
end_date,
NVL (
DECODE (impact_category,
'BULK_RATE_REQUEST', 1, -- To handle Portal's category for the old RIP
'CONTRACT_BULK_RATE', 1,
'SPOT_BULK_RATE', 2,
'CONTRACT_HISTORY', 3,
'SPOT_HISTORY', 4,
'RATE_SUBMISSION', 5,
'SPOT_BACKHAUL', 6),
0),
price,
equipment,
lane_count,
lane_estimate,
TRANSACTION_ID,
-- convert 0 to NULL [TRI-5491]
DECODE (SUBMISSION_ID, 0, NULL, SUBMISSION_ID)
FROM rateindex.transcycle;
CREATE OR REPLACE VIEW billed_rate_transactions (account_id, company_id, authenticating_order_id, authenticating_product_id, authenticating_price_class, authorizing_order_id, authorizing_product_id, authorizing_price_class, start_date, end_date, type_code, price, equipment, lane_count, lane_estimate, transaction_id, submission_id) AS SELECT
account_id,
company_id,
order_id,
product_id,
price_class,
authorizing_order_id,
authorizing_subscription_type,
authorizing_price_class,
start_date,
end_date,
coalesce(CASE WHEN impact_category='BULK_RATE_REQUEST', 1, -- To handle Portal's category for the old RIP
'CONTRACT_BULK_RATE', 1,
'SPOT_BULK_RATE', 2,
'CONTRACT_HISTORY', 3,
'SPOT_HISTORY', 4,
'RATE_SUBMISSION', 5,
'SPOT_BACKHAUL' THEN 6 END , 0),
price,
equipment,
lane_count,
lane_estimate,
TRANSACTION_ID,
-- convert 0 to NULL [TRI-5491]
CASE WHEN SUBMISSION_ID=0 THEN NULL ELSE SUBMISSION_ID END
FROM
rateindex.transcycle;
Attachments:
[text/plain] oracle_view.txt (1.4K, 3-oracle_view.txt)
download | inline:
CREATE OR REPLACE FORCE VIEW CSBTFSPRD.BILLED_RATE_TRANSACTIONS
(
ACCOUNT_ID,
COMPANY_ID,
AUTHENTICATING_ORDER_ID,
AUTHENTICATING_PRODUCT_ID,
AUTHENTICATING_PRICE_CLASS,
AUTHORIZING_ORDER_ID,
AUTHORIZING_PRODUCT_ID,
AUTHORIZING_PRICE_CLASS,
START_DATE,
END_DATE,
TYPE_CODE,
PRICE,
EQUIPMENT,
LANE_COUNT,
LANE_ESTIMATE,
TRANSACTION_ID,
SUBMISSION_ID
)
BEQUEATH DEFINER
AS
SELECT account_id,
company_id,
order_id,
product_id,
price_class,
authorizing_order_id,
authorizing_subscription_type,
authorizing_price_class,
start_date,
end_date,
NVL (
DECODE (impact_category,
'BULK_RATE_REQUEST', 1, -- To handle Portal's category for the old RIP
'CONTRACT_BULK_RATE', 1,
'SPOT_BULK_RATE', 2,
'CONTRACT_HISTORY', 3,
'SPOT_HISTORY', 4,
'RATE_SUBMISSION', 5,
'SPOT_BACKHAUL', 6),
0),
price,
equipment,
lane_count,
lane_estimate,
TRANSACTION_ID,
-- convert 0 to NULL [TRI-5491]
DECODE (SUBMISSION_ID, 0, NULL, SUBMISSION_ID)
FROM rateindex.transcycle;
[text/plain] postgres_view.txt (1.1K, 4-postgres_view.txt)
download | inline:
CREATE OR REPLACE VIEW billed_rate_transactions (account_id, company_id, authenticating_order_id, authenticating_product_id, authenticating_price_class, authorizing_order_id, authorizing_product_id, authorizing_price_class, start_date, end_date, type_code, price, equipment, lane_count, lane_estimate, transaction_id, submission_id) AS SELECT
account_id,
company_id,
order_id,
product_id,
price_class,
authorizing_order_id,
authorizing_subscription_type,
authorizing_price_class,
start_date,
end_date,
coalesce(CASE WHEN impact_category='BULK_RATE_REQUEST', 1, -- To handle Portal's category for the old RIP
'CONTRACT_BULK_RATE', 1,
'SPOT_BULK_RATE', 2,
'CONTRACT_HISTORY', 3,
'SPOT_HISTORY', 4,
'RATE_SUBMISSION', 5,
'SPOT_BACKHAUL' THEN 6 END , 0),
price,
equipment,
lane_count,
lane_estimate,
TRANSACTION_ID,
-- convert 0 to NULL [TRI-5491]
CASE WHEN SUBMISSION_ID=0 THEN NULL ELSE SUBMISSION_ID END
FROM
rateindex.transcycle;
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: Oracle ==> Postgres View
In-Reply-To: <CAN6TVjmdUGuFrCn4HcUd4Q2uvNXZSEe_4TXG7neQip_m6dGiBQ@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