What comes to mind are these:

1. Have a the system write the Max key somewhere.
2. Create a Trigger that keeps a max key updated.
3. Create an Index then use a SUBR to access the Max Key.
4. If this statement is used a lot then every time you run it update your
own Max Key and start looking from that point.

David A. Green
(480) 813-1725
DAG Consulting

-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Boydell, Stuart
Sent: Thursday, May 26, 2011 11:04 PM
To: U2 Users List
Subject: [U2] [UV] Emulate SQL MAX() function at TCL

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?

Cheers,
Stuart




_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

_______________________________________________
U2-Users mailing list
[email protected]
http://listserver.u2ug.org/mailman/listinfo/u2-users

Reply via email to