Bill,

Nice, Thank you and Happy New Year to you as well.

I have an end of day routine that makes a copy of the DB, cleans up and left 
over data in holding tables, and autochks the DB, I may add this code there as 
an additional check to the DB health.


n  Frank

Frank Taylor - Director of Information Technology
F.J. O'Hara & Sons,  Inc - Araho Transfer Inc.
Boston, MA - Rockland, ME - Miami, FL
Direct Dial - 617-790-3093
email: 
[email protected]<http://mail.whitewolftechnologies.com/cgi-bin/compose.exe?id=01ef7f9322f8a76400dacb6a1fe342bb5a7&new=&xsl=compose.xsl&[email protected]>

From: [email protected] [mailto:[email protected]] On Behalf Of Bill Downall
Sent: Monday, December 30, 2013 10:46 AM
To: RBASE-L Mailing List
Subject: [RBASE-L] - Re: COMPILED APP PROBLEM


On Mon, Dec 30, 2013 at 10:33 AM, Frank Taylor 
<[email protected]<mailto:[email protected]>> wrote:
Which brings forth this question, where can I see or select from a system table 
that will show what the last Autonumber was for the table, thus allow me to 
check to see if the max(autonumbered col) in a table is greater then what the 
system shows for that table and would generate at insert

Frank,

Happy New Year!

SET VAR vTableName TEXT = 'YourTableName'
SET VAR vColumnName TEXT = 'YourAutonumColName'

SELECT d1.SYS_NEXT FROM Sys_Defaults d1, Sys_Columns c2, Sys_Tables t3 +
  WHERE d1.sys_column_id = c2.sys_column_id +
    AND c2.sys_table_id = t3.sys_table_id +
    AND t3.sys_table_name = .vTableName +
    AND c2.sys_column_Name = .vColumnName

SELECT MAX ( &vColumnName ) FROM &vTableName

These two queries give you the "next" number to be autoassigned, and the 
current highest value.

You could create a cursor to find all the sys_column_ids  where 
SYS_DEFAULT.Column _ID is not null, and look up the current maxes for those 
columns.

Bill

Bill

Reply via email to