473,395 Members | 1,692 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

update subsquery with Not = condition

3
I am trying to create an update subsquery for the condition:
agent region region-ovrd-ind terminate-date
123 A Y 99999999 (active)
123 A Y 99999999 (active)
123 B N 20080101 (terminate)
123 B N 20080112 (terminate)

when the region-ovrd-id = Y & terminate-date is 9999999, then all the region should be same. In this case, update region to value of A & region-ovrd-id to Y

my update sql is:

Update ACR B
Set B.region_NUMBER = A.region_NUMBER, B.region_OVRD_IND = 'Y'
From ACR B
WHERE B.region_NUMBER NOT IN
(select A.region_NUMBER from ACR A
where B.AGENT_ID = A.AGENT_ID
AND A.REGION_OVRD_IND = 'Y' AND
A.TERMINATION_DTE = 99999999)

I am getting this error:


error
42601(-104)[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "CURRENT_TIMESTAMP" was found following "DATE, B.TIME_STAMP =". Expected tokens may include: "(". SQLSTATE=42601
(0.02 secs)


Appreciate any suggestions. Thanks.
Feb 9 '08 #1
3 1771
ck9663
2,878 Expert 2GB
I am trying to create an update subsquery for the condition:
agent region region-ovrd-ind terminate-date
123 A Y 99999999 (active)
123 A Y 99999999 (active)
123 B N 20080101 (terminate)
123 B N 20080112 (terminate)

when the region-ovrd-id = Y & terminate-date is 9999999, then all the region should be same. In this case, update region to value of A & region-ovrd-id to Y

my update sql is:

Update ACR B
Set B.region_NUMBER = A.region_NUMBER, B.region_OVRD_IND = 'Y'
From ACR B
WHERE B.region_NUMBER NOT IN
(select A.region_NUMBER from ACR A
where B.AGENT_ID = A.AGENT_ID
AND A.REGION_OVRD_IND = 'Y' AND
A.TERMINATION_DTE = 99999999)

I am getting this error:


error
42601(-104)[IBM][CLI Driver][DB2/NT] SQL0104N An unexpected token "CURRENT_TIMESTAMP" was found following "DATE, B.TIME_STAMP =". Expected tokens may include: "(". SQLSTATE=42601
(0.02 secs)


Appreciate any suggestions. Thanks.

try:

UPDATE ACR
set REGION = 'A'
where REGION_OVRD_IND = 'Y' AND TERMINATION_DTE = 99999999

remember, if this is done manually, you might not be able to roll this back. try doing a SELECT first and analyze the resultset first...

-- ck
Feb 9 '08 #2
Matila
3
Thanks for your suggestion.

However, I am doing this Update - subquery for unknown values off a table.
The above list of table values was an example of data.

Appreciate anymore suggestions!!!!!!!!!!!!????????????? Thanks!
Feb 9 '08 #3
code green
1,726 Expert 1GB
Well it looks like a DATE problem.
The only place I can see a date being used is here
Expand|Select|Wrap|Line Numbers
  1. A.TERMINATION_DTE = 99999999
But you are hiding what you are doing which makes it difficult.
Make sure you wrap the actual date in quotes
Expand|Select|Wrap|Line Numbers
  1. 'your dataestamp'
Feb 11 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Dave | last post by:
I have 2 tables, one with names, and another with addresses, joined by their CIVICID number (unique to the ADDRESSINFO table) in Oracle. I need to update a field in the NAMEINFO table for a...
13
by: J.P | last post by:
Hi! Anyone knows if it's possible to do an update if, and only if my condition is TRUE. Example: In MYTABLE I have three columns, like this: ID(INT), PUBLISH(ENUM(Y,N)),...
8
by: Lauren Quantrell | last post by:
In VBA, I constructed the following to update all records in tblmyTable with each records in tblmyTableTEMP having the same UniqueID: UPDATE tblMyTable RIGHT JOIN tblMyTableTEMP ON...
1
by: M Wells | last post by:
Hi All, I have a database that is serving a web site with reasonably high traffiic. We're getting errors at certain points where processes are being locked. In particular, one of our people...
3
by: Dan Berlin | last post by:
I have two tables: T1 : Key as bigint, Data as char(20) - size: 61M records T2 : Key as bigint, Data as char(20) - size: 5M records T2 is the smaller, with 5 million records. They both have...
14
by: John | last post by:
Hi all, I am doing the change from having worked in Oracle for a long time to MS SQL server and am frustrated with a couple of simple SQL stmt's. Or at least they have always been easy. The...
6
by: Vivek Sharma | last post by:
I have two tables that have a master detail relationship. i.e. Load has multiple partitions. I am using UDB v8. LOAD ------------- id status 1 0 2 0 3 0
5
by: Louis LeBlanc | last post by:
Hey folks. I'm new to the list, and not quite what you'd call a DB Guru, so please be patient with me. I'm afraid the lead up here is a bit verbose . . . I am working on an application that...
20
by: Mark Harrison | last post by:
So I have some data that I want to put into a table. If the row already exists (as defined by the primary key), I would like to update the row. Otherwise, I would like to insert the row. I've...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
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...
0
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.