update prescriber_cros s_ref
set preferred_in = 'Y' where prescriber_id =
(with temp1 as
(select A.prescriber_id ,A.prescriber_d ea_nb,A.prescri ber_ama_nb,A.pr escriber_aoa_nb
from claimsa.tprscbr _prescribe1 A, prescriber_cros s_ref B where
A.prescriber_id = B.prescriber_id ),
with temp2 as
(select case when prescriber_dea_ nb <>'' and prescriber_ama_ nb <>''
and prescriber_aoa_ nb <>'' then prescriber_id
when prescriber_dea_ nb <>'' and prescriber_ama_ nb
<>'' then prescriber_id
when prescriber_ama_ nb <>'' and prescriber_aoa_ nb <>''
then prescriber_id
when prescriber_ama_ nb <>'' then prescriber_id
when prescriber_aoa_ nb <>'' then prescriber_id
else
null
end as prescriber_id
from temp1))
select temp2.prescribe r_id from temp2 where temp2.prescribe r_id is not
null) 4 6295
DB2 does not support "Common Table Expression" (aka WITH) in a subquery.
What you can do is create an SQL Function with the WITH inside of it.
Cheers
Serge
You can use nested table expression instead of common table
expression.
(not always, but it seems true in your case)
Like this:
update prescriber_cros s_ref
set preferred_in = 'Y'
where prescriber_id =
(select temp2.prescribe r_id
from (select case
when prescriber_dea_ nb <>''
and prescriber_ama_ nb <>''
and prescriber_aoa_ nb <>'' then
prescriber_id
when prescriber_dea_ nb <>''
and prescriber_ama_ nb <>'' then
prescriber_id
when prescriber_ama_ nb <>''
and prescriber_aoa_ nb <>'' then
prescriber_id
when prescriber_ama_ nb <>'' then
prescriber_id
when prescriber_aoa_ nb <>'' then
prescriber_id
else null
end as prescriber_id
from (select A.prescriber_id
, A.prescriber_de a_nb
, A.prescriber_am a_nb
, A.prescriber_ao a_nb
from claimsa.tprscbr _prescribe1 A
, prescriber_cros s_ref B
where A.prescriber_id = B.prescriber_id
) temp1
) AS temp2
where temp2.prescribe r_id is not null)
But, I am suspicious this will work. Because subselect may return
multiple rows.
I guess your intension is to correlate updating table
prescriber_cros s_ref with claimsa.tprscbr _prescribe1.
Another point is that first three when conditions of a case expression
are included in last two when conditions.
THird point is you joined with prescriber_id. So, I thought you can
use EXISTS.
As a result, my idea is as follows:
update prescriber_cros s_ref B
set preferred_in = 'Y'
where EXISTS
(select *
from (select case
when prescriber_ama_ nb <>'' then
prescriber_id
when prescriber_aoa_ nb <>'' then
prescriber_id
else null
end as prescriber_id
from claimsa.tprscbr _prescribe1 A
where A.prescriber_id = B.prescriber_id
) AS temp2
where temp2.prescribe r_id is not null
)
Furthermore, this could produce same results.
update prescriber_cros s_ref B
set preferred_in = 'Y'
where EXISTS
(select *
from claimsa.tprscbr _prescribe1 A
where A.prescriber_id = B.prescriber_id
AND (prescriber_ama _nb <>''
OR
prescriber_aoa_ nb <>''
)
)
You can use IN predicate too.
update prescriber_cros s_ref
set preferred_in = 'Y'
where prescriber_id IN
(select temp2.prescribe r_id
from (select case
when prescriber_dea_ nb <>''
and prescriber_ama_ nb <>''
and prescriber_aoa_ nb <>'' then
prescriber_id
when prescriber_dea_ nb <>''
and prescriber_ama_ nb <>'' then
prescriber_id
when prescriber_ama_ nb <>''
and prescriber_aoa_ nb <>'' then
prescriber_id
when prescriber_ama_ nb <>'' then
prescriber_id
when prescriber_aoa_ nb <>'' then
prescriber_id
else null
end as prescriber_id
from (select A.prescriber_id
, A.prescriber_de a_nb
, A.prescriber_am a_nb
, A.prescriber_ao a_nb
from claimsa.tprscbr _prescribe1 A
, prescriber_cros s_ref B
where A.prescriber_id = B.prescriber_id
) temp1
) AS temp2
where temp2.prescribe r_id is not null
)
You might realize that you do not need to specify "where
temp2.prescribe r_id is not null".
Because NULL is not equal to any value(even with NULL).
But, it may be usefull to filter out unnecessary rows from subselect
and to make better performance.
OR
update prescriber_cros s_ref
set preferred_in = 'Y'
where prescriber_id IN
(select A.prescriber_id
from claimsa.tprscbr _prescribe1 A
, prescriber_cros s_ref B
where A.prescriber_id = B.prescriber_id
AND (A.prescriber_a ma_nb <>''
OR
A.prescriber_ao a_nb <>''
)
)
> As a result, my idea is as follows: update prescriber_cros s_ref B set preferred_in = 'Y' where EXISTS (select * from (select case when prescriber_ama_ nb <>'' then prescriber_id when prescriber_aoa_ nb <>'' then prescriber_id else null end as prescriber_id from claimsa.tprscbr _prescribe1 A where A.prescriber_id = B.prescriber_id ) AS temp2 where temp2.prescribe r_id is not null )
This seems to be sql error. TABLE keyword is necessary.
update prescriber_cros s_ref B
set preferred_in = 'Y'
where EXISTS
(select *
from TABLE
(select case
when prescriber_ama_ nb <>'' then
prescriber_id
when prescriber_aoa_ nb <>'' then
prescriber_id
else null
end as prescriber_id
from claimsa.tprscbr _prescribe1 A
where A.prescriber_id = B.prescriber_id
) AS temp2
where temp2.prescribe r_id is not null
) This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: andrew |
last post by:
Ok, pretty new to this php stuff, but good with perl/python etc.
What is wrong with this php document ???
I get this error:
Parse error: syntax error, unexpected $end in
E:\xampp\workspace\test1\fragments.php on line 7
from this doc ...
|
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have any preconceived ideas about it. I have
noticed, however, that every programmer I talk to who's aware of Python is
also talking about Ruby. So it seems that Ruby has the potential to compete
with and displace Python. I'm curious on what basis it...
|
by: Omar |
last post by:
Hi,
In the next sentence, what's wrong?
<select name='id' onChange="window.location='dePaso.jsp?vuelta=a&nombre=id&anterior=ejecutivo
= 'Daniel Perez'&valor='+this.options.value">
IE complains about missing ";"
TIA
|
by: Daniel Rudy |
last post by:
What is wrong with this program? When I try to compile it, I get the
following error. Compiler is gcc on FreeBSD.
strata:/home/dcrudy/c 1055 $$$ ->cc -g -oe6-3 e6-3.c
e6-3.c: In function `main':
e6-3.c:32: syntax error before `||'
e6-3.c:33: syntax error before `printf'
e6-3.c:36: syntax error before `||'
e6-3.c:40: syntax error before `('
e6-3.c:40: syntax error before `strcpy'
|
by: Nitin Bhardwaj |
last post by:
Hello all,
I am puzzled by the term 'semantics' !
Well I know about 'syntax of a language' - as defined by its
associated grammar
Then what is this semantics?
What does the C Compiler checks during semantic analysis?
And does it produce error OR warnings when it encounters a semantic
mistake?
| |
by: Xiangliang Meng |
last post by:
Hi, all.
I see a very strange fragment code today.
Uint32 enum
{
a = 100;
b = 200;
};
NOTE: Uint32 is defined to be 'unsigned' in other source files.
|
by: Keith K |
last post by:
Having developed with VB since 1992, I am now VERY
interested in C#. I've written several applications with
C# and I do enjoy the language.
What C# Needs:
There are a few things that I do believe MSFT should do to
improve C#, however.
I know that in the "Whidbey" release of VS.NET currently
|
by: Protoman |
last post by:
Could you tell me what's wrong with this program, it doesn't compile:
#include <iostream>
#include <cstdlib>
using namespace std;
class Everything
{
public:
static Everything* Instance()
|
by: brianbasquille |
last post by:
Hello all,
Strange little problem here... am just trying to insert some basic
information into an Access Database using OleDB.
I'm getting a "Syntax error in Insert Into statement" when it tries to
execute the SQL. The strange thing is if i take the exact SQL being
executed from the debugger and insert and execute it using the MS
Access query engine, it works fine!
|
by: Ryan |
last post by:
{"POINTID":77902,"MAPID":762,"LONG":-122.21654892,"LAT":"37.1834331019","CITY":"Boulder
Creek","STATE":"CA","DIST":5745.4}
I get an "invalid label" error...
I'm kinda new to this. Thanks!
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |