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



Folks

The SQL Reference even at V5R3 states that FETCH FIRST cannot be used in an UPDATE statement.

So I googled on 'sql fetch first' and came up with this something like this - it actually used foo and bar, but who's is quibbling? I adapted it to a single field from a file on everyone's system. This came from a TOP 10 answer - I modified it to a BOTTOM 10 = or first 10.

SELECT cusnum FROM qiws/qcustcdt X WHERE (select count(*) from qiws/qcustcdt where cusnum < X.cusnum ) < 10

This returns the first 10 - not in any order, and you can't probably use order by, anyhow, in a subquery.

No one promises that this is fast - YMMV. It also assumes, I think, uniqueness on CUSNUM. If not unique, I think you'd get more than 10 if there were duplicate values at positions 10 and up.

HTH
Vern

At 07:13 AM 12/6/2007, you wrote:

Hi Sue,

I tried what you suggested...

SELECT rrnb
FROM (SELECT RRN(b) AS rrnb
FROM filea b
WHERE FIELDA = 'X'
FETCH FIRST 1500 ROWS ONLY) A

And received the error
Keyword FETCH not expected. Valid tokens: ).

We are on V5R1. Do I have to be on a later version?

Rob


As an Amazon Associate we earn from qualifying purchases.

This thread ...

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.