Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   Impresión (https://www.clubdelphi.com/foros/forumdisplay.php?f=4)
-   -   Creacion de Indices en ejecucion (https://www.clubdelphi.com/foros/showthread.php?t=25600)

javicho_villa 27-09-2005 23:41:29

Creacion de Indices en ejecucion
 
Hola a Todos: gracias por la atencion prestada, tengo un problema cuando creo una tabla en tiempo de ejecucion, solo para crear el indice primario, el error que sale o es violacion de llaves o tabla no existe, si alguien me puede ayudar se lo voy a gradecer infinitamente.

Aqui el codigo usado:

//---- Creando una tabla temporal para el detalle de la boleta ----///
Código Delphi [-]
DM.TemporalTable.Close;
 Dm.TemporalTable.TableType := ttParadox;
 Numero := 1;
 MiTabla := '_TEMP_';
 lencontro := false;
 while lencontro=false do begin
 Dm.TemporalTable.TableName := MiTabla+Trim(IntToStr(Numero));
 if Dm.TemporalTable.Exists then Numero := Numero + 1
 else lencontro := true;
 end;
 with Dm.TemporalTable.FieldDefs do
 begin
 Clear;
 Add('Id_Boleta', ftInteger, 0, True);
 Add('Id_Temp', ftInteger, 0, FALSE);
 Add('Uno', ftString, 30, FALSE);
 Add('Dos' , ftFloat, 0, FALSE);
 Add('Tres', ftFloat, 0, FALSE);
 Add('Cuatro', ftString, 30, FALSE);
 Add('Cinco', ftFloat, 0, FALSE);
 Add('Seis', ftFloat, 0, FALSE);
 Add('Siete', ftString, 30, FALSE);
 Add('Ocho', ftFloat, 0, FALSE);
 Add('Nueve', ftFloat, 0, FALSE);
 end;
 Dm.TemporalTable.Exclusive := true;
 Dm.TemporalTable.IndexDefs.Clear;
 with Dm.TemporalTable.IndexDefs.AddIndexDef do begin
 Name := '';
 Fields := 'Id_Boleta';
 Options := [ixPrimary];
 end;
 Dm.TemporalTable.CreateTable;
 Dm.TemporalTable.Active := true;
 Dm.TemporalTable.FieldDefs.Update;
Donde Dm es el Data Module

javicho_villa 29-09-2005 06:27:21

Solucion
 
Bueno encontre la solucion en el mismo help, ahi explicanm que primero tienes que crear el indice primario para luego crera indices secundarios. el metodo es:

TTable.IndexDef.AddIndexDef.-> ahi le pones el name en una linea, y otros dos poarametros mas,

Gracias por atencion


La franja horaria es GMT +2. Ahora son las 03:45:28.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi