Bonjour,
J'ai deux tables qui ont chacunes leur propre générateur de clé primaire mais ils ne s'incrémentent pas de un en un comme je le voudrais.
On dirait qu'ils croissent selon une suite géométrique. Ex:
Voici un extrait du code qui gère ceci :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17 PED_ID ------- 26 29 33 38 44 51 59 68 26+3=29 29+4=33 33+5=38 38+6=44 etc.
Si quelqu'un a une idée?
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26 IBSQL_Venda.SQL.Clear; IBSQL_Venda.SQL.Append('SELECT GEN_ID(PEDIDOS_GEN_ID, 1) AS ID FROM PEDIDOS;'); IBSQL_Venda.ExecQuery; PedId := IBSQL_Venda.FieldByName('ID').AsString; IBSQL_Venda.Close; IBSQL_Venda.SQL.Clear; IBSQL_Venda.SQL.Append('INSERT INTO PEDIDOS (PED_ID, ...) '); IBSQL_Venda.SQL.Append('VALUES (:pedID, ...);'); IBSQL_Venda.ParamByName('pedID').AsString := PedId; IBSQL_Venda.ExecQuery; IBSQL_Venda.Close; for Index := 1 to StrGrid_Venda.RowCount-1 do begin IBSQL_Venda.SQL.Clear; IBSQL_Venda.SQL.Append('SELECT GEN_ID(ITENS_PEDIDOS_GEN_ID, 1) AS ID FROM ITENS_PEDIDOS;'); IBSQL_Venda.ExecQuery; IpeId := IBSQL_Venda.FieldByName('ID').AsString; IBSQL_Venda.Close; IBSQL_Venda.SQL.Clear; IBSQL_Venda.SQL.Append('INSERT INTO ITENS_PEDIDOS (IPE_ID, ...) '); IBSQL_Venda.SQL.Append('VALUES (:ipeID, ...);'); IBSQL_Venda.ParamByName('ipeID').AsString := IpeId; IBSQL_Venda.ExecQuery; IBSQL_Venda.Close; end;
Cyril
Partager