[Gambas-user] gb.db autoincrement ?

Jacky jscops at ...11...
Fri Oct 17 08:02:24 CEST 2008


Le Thursday 16 October 2008 22:08:22 Kari Laine, vous avez écrit :
> Hi,
>
> i cannot figure out how the get inserted autoincrement column right after
> addition to table.
>
> I have
> ------------------------
>   rResult3 = $hConn.Create("files")
>
>   rResult3!filename = sFile
>   rResult3!md5sum = MUtils.md5sum(sDir, sFile)
>   rResult3!lastaccess = Stat(sdir &/ sFile, TRUE).LastAccess
>   rResult3!lastchange = Stat(sdir &/ sFile, TRUE).LastChange
>   rResult3!lastmodified = Stat(sdir &/ sFile, TRUE).LastModified
>   rResult3!size = Stat(sdir &/ sFile, TRUE).Size
>
> rResult3.Update
> ----------------------
>
> after this I would have to add record to related table which among others
> need the autoincrement column of the first insert..
>
>
> Hopefully someone understands what I am trying to ask here...

Perhaps, i don't know :)

If your key name is "lind" or other name if you want

db AS NEW Connection
Tab = "files"
TRY db.Exec("ALTER TABLE " & Tab & " DROP PRIMARY KEY ")
TRY db.Exec("ALTER TABLE " & Tab & " ADD (lind INT unique)")
TRY db.Exec("ALTER TABLE " & Tab & " change lind lind INT unique NOT NULL 
AUTO_INCREMENT")

is it it that you wanted to know?

Jacky 






More information about the User mailing list