On 30 Apr 2013 15:19, Mark S Waterbury wrote:

Let's suppose the name of the table (file) you want to update is
called "TEST" and the column (field) name to be updated is named
"LNUM"

#1. run a RGZPFM to ensure you compress out any deleted records.

NOTE: if you need the records to be kept in a certain order by key,
you can specify the KEYFILE parameter on the RGZPFM command.

#2. run the following SQL statement (e.g. using STRSQL):

update library/test set LNUM = RRN(test)

This will assign the "relative record number" for each row (record)
to the LNUM column (field) for each row (record).

<<SNIP>>

That update can easily fail, depending on the data in the column of the file with the unique key, *unless* the request can be performed with isolation other than *NONE; e.g.:

create table test (lnum int, c char)
;
create unique index testx on test (lnum)
;
insert into test values(5, 5), (4, 4), (3, 3), (2, 2), (1, 1)
; -- sequential insert assumed
delete from test where c in ('2', '4')
; -- delete even values to be reclaimed by reorganize
call cmdexec('rgzpfm test keyfile(*none) alwcancel(*no)')
; -- old-style reorg just compressing deleted rows
update test set lnum = rrn(test)
; -- *fails* with duplicate key [with no rows changed]!
update test set lnum = rrn(test) with ur
; -- 3 rows updated in TEST
commit
; -- data is now: (1 , 5), (2 , 3), (3 , 1)



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.