Tabela Temporária

11/02/2003

0

Como criar uma tabela temporária com o resultado de uma consulta
SQL.

Alguém pode ajudar-me ?

Obrigado desde já

Marcos. :(


M_gab

M_gab

Responder

Posts

11/02/2003

Falcao

unit UCriaTabela;

interface

uses DBTables, DB, SysUtils, Forms;

{ Criar tabela temporária no HD do cliente }
Procedure CriaTabela;

implementation

{ =========================== INICIO DA COPIA =========================== }
{ COPIE ESTA PROCEDURE PARA O SEU FORM E FAÇA A DEVIDA ADEQUAÇÕES,
QUE SÃO O NOME DA TABELA A SER CRIADA, OS NOMES DOS CAMPOS E DOS INDICES.
}

{ Criar tabela temporária no HD do cliente }
Procedure CriaTabela;
var Table1 : TTable;
Indices: TIndexOptions;
NomeTabela, FileName: String;
begin
{?}NomeTabela:= ´TABELA´; { coloque o nome da tabela a criar }

{ file name é uma variavel global ou uma property no form }
FileName:= ExtractFilePath (ParamStr (0)) + NomeTabela;

{ Don´t overwrite an existing table } {verificar se tabela já existe}
if FileExists (FileName + ´.db´) then
Begin
DeleteFile (FileName + ´.db´);
DeleteFile (FileName + ´.px´);
DeleteFile (FileName + ´.val´);
End;

Indices:= [ixPrimary, ixUnique];

with TTable.Create (Application) do
begin
{ The Table component must not be active }
Active := False;
{ First, describe the type of table and give }
{ it a name }
DatabaseName := ExtractFilePath (ParamStr (0));
TableName := FileName;
TableType := ttParadox;

{ Next, describe the fields in the table }
with FieldDefs do
begin
Clear; {colocar os nomes dos campos a criar}
{?} Add (´codigo´, ftString, 7, false);
{?} // ....
end;

{ Next, describe any indexes }
with IndexDefs do
begin
Clear;

{ The 1st index has no name because it is
{ a Paradox primary key }
{ Name , Fields , Options }
{?} Add (´Codigo_Chave´, ´codigo´, Indices);
{?} // ....
end;

{ Call the CreateTable method to create the table }
CreateTable;

{ Libera o componente TTable da memória }
Free;
end;
end;

{ =========================== INICIO DA COPIA =========================== }

end.
:?: :!:


Responder

11/02/2003

Anonymous

ja ouviu falar no componente ClientDataSet

utilize ele que é show de bola pra isso


Responder

Que tal ter acesso a um e-book gratuito que vai te ajudar muito nesse momento decisivo?

Ver ebook

Recomendado pra quem ainda não iniciou o estudos.

Eu quero
Ver ebook

Recomendado para quem está passando por dificuldades nessa etapa inicial

Eu quero

Utilizamos cookies para fornecer uma melhor experiência para nossos usuários, consulte nossa política de privacidade.

Aceitar