Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3404220
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T05:21:20+00:00 2026-05-18T05:21:20+00:00

Does anyone have a sample of how to use WITH and UPDATE in a

  • 0

Does anyone have a sample of how to use WITH and UPDATE in a query in PLSQL?

I binged and googled without success.

Here is what I am trying to do

WITH
OldRecords AS
(
  SELECT 'New Records' as RecordLabel, rowid, OrDev.* 
  FROM CDR.MSRS_OR_ORDEV OrDev
  WHERE 1=1
    AND OrDev.ASOFENDDATETIME IS NULL
    AND OrDev.REPORTSTARTDATE = to_date ('7/1/2010', 'mm/dd/yyyy')
    AND OrDev.REPORTENDDATE = to_date ('7/31/2010', 'mm/dd/yyyy')
    AND OrDev.downloadrequestid <> 3
), 
NewRecords AS
(
  SELECT 'Old Records' as RecordLabelrowid, OrDev.* 
  FROM CDR.MSRS_OR_ORDEV OrDev
  WHERE 1=1
    AND OrDev.ASOFENDDATETIME IS NULL
    AND OrDev.REPORTSTARTDATE = to_date ('7/1/2010', 'mm/dd/yyyy')
    AND OrDev.REPORTENDDATE = to_date ('7/31/2010', 'mm/dd/yyyy')
    AND OrDev.downloadrequestid = 3
)
UPDATE CDR.MSRS_OR_ORDEV SET ASOFENDDATETIME = GETDATE()
WHERE RowID IN
(
  SELECT OldRecords.RowId
  FROM OldRecords
    INNER JOIN NewRecords
      ON  OldRecords.Customer_Id = NewRecords.Customer_Id
      AND OldRecords.BusinesKey1 = NewRecords.BusinesKey1
      AND OldRecords.BusinesKey2 = NewRecords.BusinesKey2
)

Basically this is a Type-II dimension update.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T05:21:21+00:00Added an answer on May 18, 2026 at 5:21 am

    This is how to use WITH in an UPDATE in PLSQL. Note that this only works for a single column update.

    UPDATE CDR.MSRS_OR_ORDEV 
    SET ASOFENDDATETIME = sysdate
    WHERE RowID IN
    (
      WITH
      OldRecords AS
      (
        SELECT rowid, OldRecords.* 
        FROM CDR.MSRS_OR_ORDEV OldRecords
        WHERE 1=1
          AND OldRecords.ASOFENDDATETIME IS NULL
          AND OldRecords.REPORTSTARTDATE = to_date ('7/1/2010', 'mm/dd/yyyy')
          AND OldRecords.REPORTENDDATE = to_date ('7/31/2010', 'mm/dd/yyyy')
          AND OldRecords.downloadrequestid <> 3
      ), 
      NewRecords AS
      (
        SELECT rowid, NewRecords.* 
        FROM CDR.MSRS_OR_ORDEV NewRecords
        WHERE 1=1
          AND NewRecords.ASOFENDDATETIME IS NULL
          AND NewRecords.REPORTSTARTDATE = to_date ('7/1/2010', 'mm/dd/yyyy')
          AND NewRecords.REPORTENDDATE = to_date ('7/31/2010', 'mm/dd/yyyy')
          AND NewRecords.downloadrequestid = 3
      )
      SELECT OldRecords.RowId
      FROM OldRecords
        INNER JOIN NewRecords
          ON  OldRecords.BusinesKey1 = NewRecords.BusinesKey1
          AND OldRecords.BusinesKey2 = NewRecords.BusinesKey2
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Does anyone have sample code, or a tutorial which demonstrates how to use Grappa
Does anyone have a sample application which makes use of mapping models in particular
Does anyone have sample code to copy open (in-use and locked by another program)
Have a rather simple question. Does anyone knows if i can use jparallax both
Does anyone have a hello world sample or tutorial for creating an Eclipse plugin
Does anyone have a simple example of implementing an async validation rule in csla?
Does anyone have any good samples, resources, pointers etc. for C# Silverlight with RIA
I'm looking to write a simple proxy server in .NET. Does anyone have any
Does anyone have a nice solution for GalleryView when I want to display photos
Does anyone have any idea how to change the thickness of the text pointer

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.