MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » October 2012

Re: SQL Update Multiple Fields from Different File



fixed

Thanks Rob...I get you. Now to do it...

On Mon, Oct 8, 2012 at 1:30 PM, <rob@xxxxxxxxx> wrote:
Michael,

If strmstpfd has these values

ststr stm#d stm#e
1 a b
2 c
3 d

SELECT * FROM michael/strmstpfd WHERE stm#d <> ' ' and stm#e <> ' '
would only return
ststr stm#d stm#e
1 a b

So if you had 1,2,3 in strmstp it would try to update 2 & 3 with null
values. Normally fixed by some usage of EXISTS to therefore only update 1
and ignore 2 & 3.



Rob Berendt
--
IBM Certified System Administrator - IBM i 6.1
Group Dekko
Dept 1600
Mail to: 2505 Dekko Drive
Garrett, IN 46738
Ship to: Dock 108
6928N 400E
Kendallville, IN 46755
http://www.dekko.com





From: Michael Ryan <michaelrtr@xxxxxxxxx>
To: Midrange Systems Technical Discussion <MIDRANGE-l@xxxxxxxxxxxx>,
Date: 10/08/2012 01:08 PM
Subject: SQL Update Multiple Fields from Different File
Sent by: midrange-l-bounces@xxxxxxxxxxxx



This stuff drives me crazy. With this SQL statement:

UPDATE michael/strmstp a SET (a.stm#d, a.stm#e) =
(select b.stm#d, b.stm#e
from michael/strmstpfd b WHERE a.ststr = b.ststr
and b.stm#d <> ' ' and b.stm#e <> ' ')

I'm getting a Null values not allowed in column or variable STM#D.

I know there is a one to one relationship between the two tables. I
also know that many records in both files

If I do this:

SELECT * FROM michael/strmstpfd WHERE stm#d <> ' ' and stm#e <> ' '

I get all the records I expect, and there are values for each stm#d
and and stm#e.

Any ideas what I'm doing wrong here?

Thanks!
--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing
list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.


--
This is the Midrange Systems Technical Discussion (MIDRANGE-L) mailing list
To post a message email: MIDRANGE-L@xxxxxxxxxxxx
To subscribe, unsubscribe, or change list options,
visit: http://lists.midrange.com/mailman/listinfo/midrange-l
or email: MIDRANGE-L-request@xxxxxxxxxxxx
Before posting, please take a moment to review the archives
at http://archive.midrange.com/midrange-l.






Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2014 by MIDRANGE dot COM and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available here. If you have questions about this, please contact