Bonjour à tous,
Je ne suis pas débutant en delphi, mais je suis complètement débutant en base de données.
Je me suis lancé dans un premier projet base de données avec Interbase.
Je suis arrivé à créer ma base de données et j'ai créé ma table avec ce code :
MyIBQuery.SQL.Add('CREATE TABLE DONNE '
+ '(NUM int not null,'
+ 'DATA VarChar(13))'
+ ';');
MyIBQuery.ExecSQL;
Ma question est la suivante, je voudrais transformer mon champ "NUM" en champ auto incrémenté ou bien en créer un nouveau.
Interbase ne dispose pas de champ auto incrémenté.
Après des recherches sur internet, j'ai vu qu'il fallait passer par des Trigger et des générateurs;
InterBase doesn't have a convenient AutoInc datatype like Paradox, so we have to do a little bit of work to get this functionality. Start out by creating an Integer field that is appropriate for the size of the values you want in your AutoInc field. From there, we need a trigger to calculate the value for the field:

CREATE TRIGGER autoinc FOR tablename
BEFORE INSERT AS
BEGIN
NEW.autoinc_field_nane = GEN_ID(generator_name, 1);
END

We aren't done yet. We need a persistent location to store the current AutoInc value. InterBases way to deal with this is called a generator:

CREATE GENERATOR generator_name;
SET GENERATOR generator_name TO x;
J'ai essayé de l'incorporer dans l'instruction SQL qui me sert à créer ma table mais j'ai plein d'erreurs.
Un coup de main serait le bienvenu.
Merci

Jean-Louis