MIDRANGE dot COM Mailing List Archive



Home » MIDRANGE-L » September 2012

RE: SQL error



fixed

You can also try an SQL Cook book for DB2, not exactly for this system, but
most times usefull, I hope.

http://www.database-books.us/db2_0003.php

Regards,
Carel Teijgeler

*********** REPLY SEPARATOR ***********

On 7-9-2012 at 17:50 Alan Shore wrote:

Hi Eric
I also have the same book, but I have found that the "real" way to
understand SQL is to look at the different tips and techniques that people
(especially on this list) suggest and try and use what they suggest.
There are MANY different ways to skin a cat, and that seems to be more
than apparent where SQL is concerned.
Go to this web page
http://www.as400pro.com/tipListInq.php?cat=SQL
Then choose iSeries (AS/400) SQL
You will see many different tips and techniques that people have suggested
for doing many different things

Alan Shore
Programmer/Analyst, Direct Response
E:AShore@xxxxxxxx
P:(631) 200-5019
C:(631) 880-8640
"If you're going through Hell, keep going" - Winston Churchill

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Friday, September 07, 2012 1:33 PM
To: 'Midrange Systems Technical Discussion'
Subject: RE: SQL error

This works great with one tiny change - needs two (( after Coalesce.


Is there a book or website that explains SQL on iseries? Especially
updates with joins?

I have two books - SQL400 by Paul Conte & Mike Cravitz and also SQL at
Work by Howard Arner.

The only joins I can find are SELECTs (read only, no updates).

How do you learn this stuff???

thanks!!

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Birgitta Hauser
Sent: Friday, September 07, 2012 11:56 AM
To: 'Midrange Systems Technical Discussion'
Subject: AW: SQL error

I'd use COALESCE in this way:
update bzcontract a set XDPCV =
Coalesce(select sum(CMPAMT) from pricecmp b, ctltable where a.ACNTNMB =
b.ACNTNMB and CTLTABLE = 'PRICE COMP' and cmptype = CTLELEMENT and
CTLFLAG1 = 'Y'
group by ACNTNMB), 0)

Mit freundlichen Grüßen / Best regards

Birgitta Hauser

"Shoot for the moon, even if you miss, you'll land among the stars." (Les
Brown)
"If you think education is expensive, try ignorance." (Derek Bok) "What is
worse than training your staff and losing them? Not training them and
keeping them!"


-----Ursprüngliche Nachricht-----
Von: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] Im Auftrag von DeLong, Eric
Gesendet: Friday, 07.9 2012 18:24
An: Midrange Systems Technical Discussion
Betreff: RE: SQL error

Use Coalesce to supply a "default value" instead of null...

update bzcontract a set XDPCV =
(select coalesce(sum(CMPAMT),0) from pricecmp b, ctltable where a.ACNTNMB
= b.ACNTNMB and CTLTABLE = 'PRICE COMP' and cmptype = CTLELEMENT and
CTLFLAG1 = 'Y'
group by ACNTNMB)

hth,
-Eric

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Stone, Joel
Sent: Friday, September 07, 2012 11:20 AM
To: 'Midrange Systems Technical Discussion'
Subject: SQL error

How can I get around error (without changing file to allow nulls)?



update bzcontract a set XDPCV =
(select sum(CMPAMT) from pricecmp b, ctltable where a.ACNTNMB =
b.ACNTNMB
and CTLTABLE = 'PRICE COMP' and cmptype = CTLELEMENT and CTLFLAG1 =
'Y'
group by ACNTNMB)

error:

Null values not allowed in column or variable XDPCV.

______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs
Skyscan service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--
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.


--
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 inbound email has been scanned for all viruses by the MessageLabs
SkyScan
service.
________________________________________________________________________

______________________________________________________________________
This outbound email has been scanned for all viruses by the MessageLabs
Skyscan service.
For more information please visit http://www.symanteccloud.com
______________________________________________________________________
--
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.


Disclaimer: This message contains confidential information and is intended
only for the individual named. If you are not the named addressee you
should not disseminate, distribute or copy this e-mail. Please notify the
sender immediately by e-mail if you have received this e-mail by mistake
and delete this e-mail from your system. E-mail transmission cannot be
guaranteed to be secure or error-free as information could be intercepted,
corrupted, lost, destroyed, arrive late or incomplete, or contain viruses.
The sender therefore does not accept liability for any errors or omissions
in the contents of this message, which arise as a result of e-mail
transmission. If verification is required please request a hard-copy
version. Any views or opinions presented are solely those of the author
and do not necessarily represent those of the company.
--
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.



-----
Geen virus gevonden in dit bericht.
Gecontroleerd door AVG - www.avg.com
Versie: 10.0.1382 / Virusdatabase: 2437/5246 - datum van uitgifte:
09/03/12








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