On 27/05/11 07:03, Boydell, Stuart wrote:
> Just wondering if anyone has a neat trick for picking up the highest ID from 
> a file. Where the file ID is an integer.
> 
> With UVSQL I would SELECT MAX(@ID) FROM TABLE; - however, the program I need 
> to do this within has the file (table) open and if I try to execute it 
> returns the error 'Non-SQL re-entrant query calls are not allowed.'
> 
> The best I have so far is:
>    st = 'SELECT FILE @ID BY.DSND @ID'
>    st<-1> = 'LIST ONLY FILE SAMPLE 1'
>    exec st capturing cap
>    maxId = trim(cap<4>)
> 
> Any other ideas?
> 
Extending your idea ...

SELECT FILE @ID BY.DSND @ID SAMPLE 1
READLIST

Not quite sure whether SAMPLE is the correct keyword, because I think
one keyword samples then sorts (that might be SAMPLING), but I'm sure
there is one that sorts then samples.

If you can't find the keyword, the other trick could be

SELECT FILE @ID BY.DSND @ID
READNEXT
CLEARLIST

Cheers,
Wol
_______________________________________________
U2-Users mailing list
U2-Users@listserver.u2ug.org
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to