public inbox for [email protected]
help / color / mirror / Atom feedOracle ==> Postgres View
4+ messages / 3 participants
[nested] [flat]
* Oracle ==> Postgres View
@ 2024-10-15 21:30 Sam Stearns <[email protected]>
2024-10-15 21:46 ` Re: Oracle ==> Postgres View David Rowley <[email protected]>
2024-10-15 21:49 ` Re: Oracle ==> Postgres View William Alves Da Silva <[email protected]>
0 siblings, 2 replies; 4+ messages in thread
From: Sam Stearns @ 2024-10-15 21:30 UTC (permalink / raw)
To: [email protected]
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;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Oracle ==> Postgres View
2024-10-15 21:30 Oracle ==> Postgres View Sam Stearns <[email protected]>
@ 2024-10-15 21:46 ` David Rowley <[email protected]>
1 sibling, 0 replies; 4+ messages in thread
From: David Rowley @ 2024-10-15 21:46 UTC (permalink / raw)
To: Sam Stearns <[email protected]>; +Cc: [email protected]
On Wed, 16 Oct 2024 at 10:31, Sam Stearns <[email protected]> wrote:
> 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?
Have a look at the syntax of your case statement and check it against [1].
David
[1] https://www.postgresql.org/docs/current/functions-conditional.html
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Oracle ==> Postgres View
2024-10-15 21:30 Oracle ==> Postgres View Sam Stearns <[email protected]>
@ 2024-10-15 21:49 ` William Alves Da Silva <[email protected]>
2024-10-16 16:15 ` Re: Oracle ==> Postgres View Sam Stearns <[email protected]>
1 sibling, 1 reply; 4+ messages in thread
From: William Alves Da Silva @ 2024-10-15 21:49 UTC (permalink / raw)
To: Sam Stearns <[email protected]>; +Cc: pgsql-sql <[email protected]>
Hello.
I think you want this.
coalesce(CASE impact_category
WHEN 'BULK_RATE_REQUEST' THEN 1 -- To handle Portal's category for the old RIP
WHEN 'CONTRACT_BULK_RATE' THEN 1
WHEN 'SPOT_BULK_RATE' THEN 2
WHEN 'CONTRACT_HISTORY' THEN 3
WHEN 'SPOT_HISTORY' THEN 4
WHEN 'RATE_SUBMISSION' THEN 5
WHEN 'SPOT_BACKHAUL' THEN 6 END , 0)
Regards,
William Alves
> On 15 Oct 2024, at 18:30, Sam Stearns <[email protected]> wrote:
>
> 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
>
> <https://www.dat.com/?utm_medium=email&utm_source=DAT_email_signature_link><oracle_view.txt...;
^ permalink raw reply [nested|flat] 4+ messages in thread
* Re: Oracle ==> Postgres View
2024-10-15 21:30 Oracle ==> Postgres View Sam Stearns <[email protected]>
2024-10-15 21:49 ` Re: Oracle ==> Postgres View William Alves Da Silva <[email protected]>
@ 2024-10-16 16:15 ` Sam Stearns <[email protected]>
0 siblings, 0 replies; 4+ messages in thread
From: Sam Stearns @ 2024-10-16 16:15 UTC (permalink / raw)
To: William Alves Da Silva <[email protected]>; +Cc: pgsql-sql <[email protected]>
Thank you all for the help! William's advice did the trick.
Sam
On Tue, Oct 15, 2024 at 2:49 PM William Alves Da Silva <
[email protected]> wrote:
> Hello.
>
> I think you want this.
>
> coalesce(CASE impact_category
> WHEN 'BULK_RATE_REQUEST' THEN 1 -- To handle Portal's category for the
> old RIP
> WHEN 'CONTRACT_BULK_RATE' THEN 1
> WHEN 'SPOT_BULK_RATE' THEN 2
> WHEN 'CONTRACT_HISTORY' THEN 3
> WHEN 'SPOT_HISTORY' THEN 4
> WHEN 'RATE_SUBMISSION' THEN 5
> WHEN 'SPOT_BACKHAUL' THEN 6 END , 0)
>
> Regards,
> William Alves
>
> On 15 Oct 2024, at 18:30, Sam Stearns <[email protected]> wrote:
>
> 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;
> <oracle_view.txt><postgres_view.txt>
>
>
>
--
*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;
^ permalink raw reply [nested|flat] 4+ messages in thread
end of thread, other threads:[~2024-10-16 16:15 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2024-10-15 21:30 Oracle ==> Postgres View Sam Stearns <[email protected]>
2024-10-15 21:46 ` David Rowley <[email protected]>
2024-10-15 21:49 ` William Alves Da Silva <[email protected]>
2024-10-16 16:15 ` Sam Stearns <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox