On Jun 30, 2004, at 12:17 PM, Kristin Green wrote:
Arrggh! Then why is the option there! :-(
As far as I know, it's a holdover from the old database engine they
used. They redesigned it for 5.5.
Why would they do that to me? Why?
I don't think it's personal. ;)
While we're on the topic, how would one implement 'auto-increment' and
ensure that the field is unique?
I use a method like this. Note that myDatabase is a global reference to
the database I'm using. This particular function is used with a SQLite
database, but it should work with the REAL Database with minimal
conversion. This code selects the integer column you want from the
table you want and returns the maximum value plus one.
Function getNextID(table as string, keyfield as string) as Integer
dim rs as recordSet
dim sql as string
dim i as integer
if myDatabase<>nil then
sql="select max("+keyfield
sql=sql+") from "+table
rs=myDatabase.SQLSelect(sql)
if rs<>nil then
i=rs.idxField(1).integerValue
return i+1
rs.close
else
return 1
end if
end if
End Function
To get the next id for some given field, call it like this:
dim newID as integer
newID=getNextID("people","id")
Hope this helps!
--
brad at truetech dot org
http://truetech.org
<><
_______________________________________________
Unsubscribe or switch delivery mode:
<http://support.realsoftware.com/listmanager/>
Search the archives of this list here:
<http://support.realsoftware.com/listarchives/lists.html>
|