DBMS: Sybase Central
Funzione attuale per proporre in automatico il key value:
codice:
function GetAutoIncVal(aDbName,aTabName: string): integer;
begin
result:=-1;
try
with TQuery.Create(nil) do
begin
DatabaseName:=ADbName;
SQL.Text:='select Get_Identity('+QuotedStr(aTabName)+') as id';
Active:=true;
if not(IsEmpty) then
result:=FieldByName('id').AsInteger;
Free;
end;
except
result:=-1;
end;
end;
Problema:
Supponiamo che sulla tabella dispongo di un solo campo con il precedente key value = 1, l'autoincrement mi da 47 - e cosi via.
ossia parte da 47.
Potete darmi una funzione collaudate e ottimale per ottenere l'autoincrement valido.