473,405 Members | 2,300 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,405 software developers and data experts.

Update difficulty

Hi all,

I am wondering, when I issue this sql:

SELECT
CASE
WHEN LOCATE('*',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'*','%')
WHEN LOCATE('%',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'%','_')
ELSE STRIP(SURRUSR)
END AS NS
FROM D1.TCEOSURROGAT

I get exactly what I want in a NS Column:
NS
------------
WEB
%
_0ARS1
GCMS001
but when I try to updtae this result into the same table in a column
UPDSURRUSR:

UPDATE D1.TCEOSURROGAT TCEOSURROGAT
SET UPDSURRUSR = (
SELECT
CASE
WHEN LOCATE('*',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'*','%')
WHEN LOCATE('%',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'%','_')
ELSE STRIP(SURRUSR)
END AS NS
FROM D1.TCEOSURROGAT)

DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0811N The result of a scalar fullselect, SELECT INTO statement, or
VALUES
INTO statement is more than one row. SQLSTATE=21000
I just don't know what is wrong... but like I wrote a lot of time I am
not a specialist.... but I am learning every day some more...

Thaks for your help

Jul 18 '07 #1
2 2486
cb*****@gmail.com wrote:
Hi all,

I am wondering, when I issue this sql:

SELECT
CASE
WHEN LOCATE('*',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'*','%')
WHEN LOCATE('%',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'%','_')
ELSE STRIP(SURRUSR)
END AS NS
FROM D1.TCEOSURROGAT

I get exactly what I want in a NS Column:
NS
------------
WEB
%
_0ARS1
GCMS001
but when I try to updtae this result into the same table in a column
UPDSURRUSR:

UPDATE D1.TCEOSURROGAT TCEOSURROGAT
SET UPDSURRUSR = (
SELECT
CASE
WHEN LOCATE('*',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'*','%')
WHEN LOCATE('%',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'%','_')
ELSE STRIP(SURRUSR)
END AS NS
FROM D1.TCEOSURROGAT)

DB21034E The command was processed as an SQL statement because it was
not a
valid Command Line Processor command. During SQL processing it
returned:
SQL0811N The result of a scalar fullselect, SELECT INTO statement, or
VALUES
INTO statement is more than one row. SQLSTATE=21000
I just don't know what is wrong... but like I wrote a lot of time I am
not a specialist.... but I am learning every day some more...

Thaks for your help
The error means that you are trying to assign a set of values to the column:
I get exactly what I want in a NS Column:
NS
------------
WEB
%
_0ARS1
GCMS001
but you need a scalar value ( a single value, not a set of values ). You
can solve this by adding a where clause in the subselect as:

UPDATE D1.TCEOSURROGAT TCEOSURROGAT_1
SET UPDSURRUSR = (
SELECT
CASE
WHEN LOCATE('*',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'*','%')
WHEN LOCATE('%',STRIP(SURRUSR)) <0 THEN REPLACE(SURRUSR,'%','_')
ELSE STRIP(SURRUSR)
END AS NS
FROM D1.TCEOSURROGAT TCEOSURROGAT_2
WHERE TCEOSURROGAT_1.<p.k= TCEOSURROGAT_2.<p.k>
)

Since I dont know what column(s) that is the key in D1.TCEOSURROGAT I
used <p.kas a marker

HTH
/Lennart
Jul 18 '07 #2
Maybe this is what you are trying to do?
UPDATE D1.TCEOSURROGAT
SET UPDSURRUSR
= CASE
WHEN LOCATE('*',STRIP(SURRUSR)) <0
THEN REPLACE(SURRUSR,'*','%')
WHEN LOCATE('%',STRIP(SURRUSR)) <0
THEN REPLACE(SURRUSR,'%','_')
ELSE STRIP(SURRUSR) END


--
Serge Rielau
DB2 Solutions Development
IBM Toronto Lab
Jul 19 '07 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

198
by: Michael N. Christoff | last post by:
Java, the software developed by Sun Microsystems in the mid-1990s as a universal operating system for Internet applications, gave NASA a low-cost and easy-to-use option for running Spirit, the...
1
by: Keith | last post by:
Hi I'm having a great deal of difficulty doing a very simple thing. This is what I want to do. On a Windows Form - NO DATAGRID.... I have various text boxes, into which I want to show fields and...
2
by: Paul | last post by:
wondered if anyone might lend a hand? I'm having a little difficulty updating the backend SQL Server tables. Normally I just use Access' update but I'd really like to try something new. I'd like...
2
by: Dejan Pujic | last post by:
Hello, I'm having difficulty figuring out how to update values in a certain column, where the new information depends on the previous. Here's a further description: The whole database is for...
0
by: mr_wizard | last post by:
I posted a message yesterday on my difficulty in updating an Access table. Yesterday the error response was permission related. I've gotten past that, but still cannot update the table. XP Pro...
0
by: Doug | last post by:
I've got a strongly-typed dataset with 2 related tables in it ("Staff" and "Roles"). I want to make a change to the parent Staff row and also to its child Role row. I'm having difficulty figuring...
6
by: Matt | last post by:
I'm having difficulty with trying to update a Access memo field through an SQL statement where the value I'm trying to pass is longer than 255 characters. The field is being truncated. I'm using...
2
by: Eli Silverman | last post by:
I am attempting to develop a form that lists available speakers for a meeting. One of my clients can have as many as about 800 contracted speakers and a variety of 100 topics that they can speak...
2
by: topthebookie | last post by:
I have a dilemma. I created a query named QP Test, the second query I created is named QP Test Update. My table I am trying to flag with 1 is all_hx4.qp Flag. I am not sure what I have done wrong,...
2
by: jjb1214 | last post by:
Hi all, I've been unable to find the answer I'm looking for on the forums, so I'm asking my first-ever question. I'm building a windows forms application in Visual Basic using Visual Studio 2008....
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: 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
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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...
0
tracyyun
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...

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.