question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Oracle] UPDATE FROM: implement correlated update support

See original GitHub issue

Hi!

I think Oracle has more good candidate for such thing:

UPDATE
  [UpdatedEntities]
SET
  ( [Value1], [Value2], [Value3] ) = 
  (
    SELECT
      ([UpdatedEntities].[Value1] * [t].[Value1]) * @int1,
      ([UpdatedEntities].[Value2] * [t].[Value2]) * @int2,
      ([UpdatedEntities].[Value3] * [t].[Value3]) * @int3
    FROM
      [NewEntities] [t] 
    WHERE
      [t].[id] <> @someId AND [UpdatedEntities].[id] = [t].[id]
  )
WHERE
  EXISTS(
    SELECT
      *
    FROM
       [NewEntities] [t6] 
    WHERE
      [t6].[id] <> @someId AND [UpdatedEntities].[id] = [t6].[id]
  )

_Originally posted by @AndrePScope in https://github.com/linq2db/linq2db/pull/1278#issuecomment-620851672_

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Reactions:1
  • Comments:5 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
sdanylivcommented, Feb 4, 2021

@viceroypenguin. Oracle is the rule-breaker, WITH statements in such case will not work. Oracle sticks WITH statement with SELECT, not whole query.

0reactions
jods4commented, Feb 16, 2021

@sdanyliv tangentially related: is there a syntax to write a “tuple” (not sure what’s the right word) update in Oracle manually?

I.e. can you write this with linq2db?

update X set (a, b) = (1, 2)
-- or with a subselect
update X set (a, b) = (select 1, 2 from dual)
Read more comments on GitHub >

github_iconTop Results From Across the Web

Oracle SQL correlated update
Now what I want is to update t1.c with t3.d. But I can't just update t1 from t3 using t1.c = t3.c I...
Read more >
Update statement with correlated subquery that intentionally...
I am trying to update one table using a subquery that totals several transactions from another table. I cannot figure how to link...
Read more >
5 Ways to Update Data with a Subquery in Oracle SQL
Another way to use a subquery in an UPDATE statement is to use a correlated subquery. It works in a similar way to...
Read more >
4 ways to do multiple table update in Oracle (what works ...
Cross table update (also known as correlated update, or multiple table update) in Oracle uses non-standard SQL syntax format (non ANSI standard) to...
Read more >
Updates Based on Queries
Updates Based on Queries. This article describes how a table can be updated using data from another table. Setup; Subquery Method; Inline View ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found