Forum Stats

  • 3,770,167 Users
  • 2,253,079 Discussions
  • 7,875,357 Comments

Discussions

Oracle PL/SQL to T-SQL Conversion Question

User_8CP69
User_8CP69 Member Posts: 1 Green Ribbon

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?

Tagged:

Answers