× 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.



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

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


Mike, based on further fleshing out of your requirements, I believe this
ought to work:

UPDATE myFile a SET a.suffix =
CASE flag WHEN 'Y' THEN '00'
ELSE
(SELECT b.suffix
FROM (SELECT master, contract,
RIGHT(DIGITS(ROW_NUMBER()
OVER(PARTITION BY master
ORDER BY contract)),2)
AS suffix
FROM qtemp/t1
WHERE flag = 'N') b
WHERE a.master = b.master AND a.contract = b.contract)
END

Elvis

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


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

I am adding some new fields to a file. The file containts a master
contract#, contract# and (new) contract suffix

MASTER CONTRACT MASTER Flag SUFFIX
200300022 Y 00
200300022 200500120 N
200300022 200500121 N
200300022 200600124 N

I want to be able to update the suffix with 01, 02, 03, etc for each
master contract that matches a contract

So if mastflg = 'y', update suffix(incrementing value) where contract =
master

Can I do this with SQL? I'm not sure how to make the suffix field
increment.

Thanks

Mike


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.