Hi Stuart, Probably too late now... but...
If you defined your SQL table with the DEFAULT "NEXT AVAILABLE" it will automatically increment the primary key value by 1 when you insert a new row... CREATE TABLE MYTABLE (CLIENT_NUMBER INT PRIMARY DEFAULT 'NEXT AVAILABLE', CLIENT_NAME VARCHAR FMT "30T" DEFAULT '', CREATE_ADDRESS VARCHAR FMT "30T" DEFAULT '' ... See "UniVerse SQL Reference Guide" sqlref.pdf page 113 (UV11.1 docset). Regards, David -----Original Message----- From: [email protected] [mailto:[email protected]] On Behalf Of Boydell, Stuart Sent: Friday, 27 May 2011 4: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 ************** IMPORTANT MESSAGE ***************************** This e-mail message is intended only for the addressee(s) and contains information which may be confidential. If you are not the intended recipient please advise the sender by return email, do not use or disclose the contents, and delete the message and any attachments from your system. Unless specifically indicated, this email does not constitute formal advice or commitment by the sender or the Commonwealth Bank of Australia (ABN 48 123 123 124) or its subsidiaries. We can be contacted through our web site: commbank.com.au. If you no longer wish to receive commercial electronic messages from us, please reply to this e-mail by typing Unsubscribe in the subject line. ************************************************************** _______________________________________________ U2-Users mailing list [email protected] http://listserver.u2ug.org/mailman/listinfo/u2-users
