Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Oracle PL/SQL to T-SQL Conversion Question

User_8CP69Oct 6 2021

Hello Community,
My first post here, and I'm a newbie, so be easy on me with this question.
I have been tasked with converting some Oracle code to T-SQL, see below, but I'm getting the error in T-SQL
Incorrect syntax near the keyword 'WITH'.
And
Incorrect syntax near the keyword 'with'. If this statement is a common table expression, an xmlnamespaces clause or a change tracking context clause, the previous statement must be terminated with a semicolon.
The PL/SQL code is as follows:
MERGE INTO tbl_legal_probatewlgmt_case trg
USING
(
-- Derived attribute
WITH
earliest_wlgmt_events
AS
(
SELECT m.legal_case_id AS ce_case_data_id,
MIN(m.event_created_timestamp) AS case_created_datetime
FROM v_legal_probatewlgmt_case_evt m
WHERE m.legal_case_event_type_cid NOT IN (SELECT source_event_type_cid FROM v_prbtgrant_case_event_grps WHERE event_type_grp_key = gc_event_grp_draftcase_key)
GROUP BY m.legal_case_id
)

Any thoughts as to why I'm getting the error?

Comments
Post Details
Added on Oct 6 2021
1 comment
550 views