× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



Subqueries are where I really struggle. I have taken your query and
converted to proper field names as such.
UPDATE contmast00 a SET a.cmsuffix =
CASE CMMASTF WHEN 'Y' THEN '00'
ELSE
(SELECT b.cmsuffix
FROM (SELECT cmmastr, cmcontract,
RIGHT(DIGITS(ROW_NUMBER()
OVER(PARTITION BY cmmastr
ORDER BY cmcontract)),2)
AS suffix
FROM contmast00 b
WHERE cmmastf = 'N') b
WHERE a.cmmastr = b.cmmastr AND a.cmcontract = b.cmcontract)
END

When I run this it tells me Column CMSUFFIX not in table B in *N. this
points to the (SELECT b.cmsuffix

-----Original Message-----
From: midrange-l-bounces@xxxxxxxxxxxx
[mailto:midrange-l-bounces@xxxxxxxxxxxx] On Behalf Of Elvis Budimlic
Sent: Wednesday, April 23, 2008 2:56 PM
To: 'Midrange Systems Technical Discussion'
Subject: RE: Sql - updating multiple records with a sequential value


I goofed on qtemp/t1, it should have said myFile (or whatever your real
file name is). PARTITION is an SQL keyword. In the context of
ROW_NUMBER function (available with V5R4) you can think of it as a GROUP
BY equivalent.

Elvis

Celebrating 11-Years of SQL Performance Excellence on IBM i5/OS and
OS/400 www.centerfieldtechnology.com


-----Original Message-----
Subject: RE: Sql - updating multiple records with a sequential value

Thanks Elvis,
2 questions.
Does qtemp/t1 have to exist? I get a T1 in qtemp not found.

Also, what is PARTITION? Is this a keyword? I couldn't find it in my
sql book. If not what is PARTITION



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:
Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.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 on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.