Club Delphi  
    Paypal   FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Bases de datos > Tablas planas
Registrarse FAQ Miembros Calendario Guía de estilo Temas de Hoy

 
 
Herramientas Buscar en Tema Desplegado
  #8  
Antiguo 24-03-2020
Avatar de kuan-yiu
[kuan-yiu] kuan-yiu is offline
Miembro Premium
 
Registrado: jun 2006
Ubicación: Galicia. España.
Posts: 1.017
Poder: 22
kuan-yiu Va camino a la fama
Código Delphi [-]
   qInsertar:= TQuery.create(Application);
   with qInsertar do
   begin
      try
         close;
         SQL.Clear;
         DatabaseName := miBase;
         SQL.Add('Insert into '+tabla1+' (Id)');
         SQL.Add('Values (:id)');
         Prepare;
         tabla2.first;
         tabla3.first;
         //Si no están ordenadas tienes que tener dos bucles anidados. Si lo están vale algo así.
         while (not tabla2.eof)and(not tabla3.eof) do
         begin
            if (tabla2.FieldByName('CODIGO').AsInteger=tabla3.FieldByName('CODIGO').AsInteger) and
               (tabla2.FieldByName('NOMBRE').AsString=tabla3.FieldByName('NOMBRE').AsString) then
            begin
               Parambyname('id').AsInteger  := tabla2.FieldByName('CODIGO').AsInteger;
               ExecSQL;
               tabla2.next;
               tabla3.next;
            end
            else
            begin
            //Siguiente registro. Depende de la ordenación. Avanzando una u otra según cual sea menor o mayor.
            end;
        end;
      finally
         Free;
      end;
   end;
Responder Con Cita
 



Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Insertar filas de una tabla a otra en distinta BD Gregorio Cíber Firebird e Interbase 2 23-12-2016 22:19:26
actualizar tabla al insertar en otra tabla hybrid Conexión con bases de datos 14 02-12-2009 15:09:13
Dbgrid para insertar en una tabla pero cogiendo datos de otra tabla taru MySQL 1 27-07-2006 15:36:12
insertar datos en una tabla desde otra Giniromero SQL 5 17-06-2004 19:37:16
Como insertar datos de una tabla en otra tabla? Salomon Firebird e Interbase 1 28-08-2003 11:29:40


La franja horaria es GMT +2. Ahora son las 01:36:20.


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