Help running interactive SQL statement

435 pts.
Tags:
IBM DB2
This user recently upgraded from V4R5 to V5R2, and now they're having difficulty running an interactive SQL statement that worked fine at R4R5. The statement is as follows: update grmlib/mspmp100 as t1 set pmfp2=(select pmfp2 from grmlib/sin gupl2 as t2 where t1.prdno=t2.prdno and t2.pmfp2<>0) Previously this returned the following result: 674 rows updated in MSPMP100 in GRMLIB. But now the same command returns this: Null values not allowed in column or variable PMFP2. Do you know what's going on? Any help will much appreciated. -- Michelle Davidson, editor, Search400.com

Answer Wiki

Thanks. We'll let you know when a new response is added.

os version is not the reason.
data is the reason

the reason is that one of the answer of the select is nothing

try this (not checked)

update grmlib/mspmp100 as t1 set pmfp2=(select
coalesce(pmfp2, ‘defaultvalue’)
from grmlib/sin
gupl2 as t2 where t1.prdno=t2.prdno and t2.pmfp2<>0)

now when t2 returns null (ie nothing), then select returns ‘defaultvalue’

nota : this sample assumes pmfp2 is char. If not, set the default value to an acceptable value

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy

Thanks! We'll email you when relevant content is added and updated.

Following