jara_vla
asked on
save querie??
As I can keep the result from a querie? my Base of data I need the registries with date for example of 1998 and the result I need to keep it like DB1998.DB
Consult:='Select * from correspondence where date like upper('+chr(39)+'%1998'%'+ chr(39)+ ') ';
Query.Close;
Query.SQL.text:=consult;
Query.Open;
as I can keep the result?
Help me!!!
Consult:='Select * from correspondence where date like upper('+chr(39)+'%1998'%'+
Query.Close;
Query.SQL.text:=consult;
Query.Open;
as I can keep the result?
Help me!!!
ASKER
I need to keep multiple registries reason why I need to keep the result from all the querie like a new table DB1998.DB
Consult:='INSERT INTO Table_Name
Select * from correspondence where date like
upper('+chr(39)+'%1998'%'+ chr(39)+ ') ';
Query.SQL.text:=consult;
Query.ExceSQL;
Select * from correspondence where date like
upper('+chr(39)+'%1998'%'+
Query.SQL.text:=consult;
Query.ExceSQL;
ASKER
but I want to create the table with the result of the querie reason why I cannot insert in Table_name since it does not even exist :(
Consult:='CREATE TABLE Table_Name
Select * from correspondence where date like
upper('+chr(39)+'%1998'%'+ chr(39)+ ') ';
Query.SQL.text:=consult;
Query.ExceSQL;
Select * from correspondence where date like
upper('+chr(39)+'%1998'%'+
Query.SQL.text:=consult;
Query.ExceSQL;
ASKER
in
Consult:='CREATE TABLE respald.db Select * from correspondencia'+
' where fecharec like upper('+chr(39)+'%1998%'+c hr(39)+ ')';
Query.SQL.text:=consult;
Query.ExecSQL;
message
'invalid use of keyword.
Token: select
Line number:1'
??? what is wrong??
Consult:='CREATE TABLE respald.db Select * from correspondencia'+
' where fecharec like upper('+chr(39)+'%1998%'+c
Query.SQL.text:=consult;
Query.ExecSQL;
message
'invalid use of keyword.
Token: select
Line number:1'
??? what is wrong??
hi jara_vla,
Consult:='CREATE TABLE Table_Name As '+ //look at the As here
'Select * from correspondence where date '+
'like '+
'upper('+chr(39)+'%1998'%' +chr(39)+ ') '; Query.SQL.text:=consult;
Query.ExceSQL;
if this not work, then tell me what database you use.
(paradox i guess)
if you use paradox then take a look to the batchmove-method
Consult:='Select * from correspondence where date '+
'like '+
'upper('+chr(39)+'%1998'%' +chr(39)+ ') '; Query.SQL.text:=consult;
Query.ExceSQL;
//you need a table component
Table1.DatabaseName := query1.Databasename;
Table1.Tablename := 'Tmp.DB'; //or whatever name
try
I := Table1.BatchMove(query1,Ba tCopy);
Showmessage(IntStr(I)+' Query Records Saved');
except
//an error
end;
meikl ;-)
Consult:='CREATE TABLE Table_Name As '+ //look at the As here
'Select * from correspondence where date '+
'like '+
'upper('+chr(39)+'%1998'%'
Query.ExceSQL;
if this not work, then tell me what database you use.
(paradox i guess)
if you use paradox then take a look to the batchmove-method
Consult:='Select * from correspondence where date '+
'like '+
'upper('+chr(39)+'%1998'%'
Query.ExceSQL;
//you need a table component
Table1.DatabaseName := query1.Databasename;
Table1.Tablename := 'Tmp.DB'; //or whatever name
try
I := Table1.BatchMove(query1,Ba
Showmessage(IntStr(I)+' Query Records Saved');
except
//an error
end;
meikl ;-)
oops, sorry some typos
in the second sample use
Query.Open;
instead of
Query.ExceSQL;
and instead of
query1
use
query
meikl ;-)
in the second sample use
Query.Open;
instead of
Query.ExceSQL;
and instead of
query1
use
query
meikl ;-)
ASKER
thank you very much to kretzschmar! batchmove-method works perfectly with a small problem! it does not index the result :( I need that the result of the querie keeps in another table and that is indexed with the same field that the original one! it is possible to be done?
ASKER
Adjusted points to 30
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
hello ?
jara_vla are you still alive ?
ASKER
Very very thanks! kretzschmar :)
ASKER
mmm,when I erase of a table registries with
delete from correspondencia.db where numfolio like '%-003%'
these registries disappears of the table but the size of the file is not reduced! that this badly?
delete from correspondencia.db where numfolio like '%-003%'
these registries disappears of the table but the size of the file is not reduced! that this badly?
hi jara_vla,
after deleeing you must pack the table
here a sample from borland
you must placed the bde-unit in the uses clause
/ Pack a Paradox or dBASE table
// The table must be opened execlusively before calling this function...
procedure PackTable(Table: TTable);
var
Props: CURProps;
hDb: hDBIDb;
TableDesc: CRTblDesc;
begin
// Make sure the table is open exclusively so we can get the db handle...
if Table.Active = False then
raise EDatabaseError.Create('Tab le must be opened to pack');
if Table.Exclusive = False then
raise EDatabaseError.Create('Tab le must be opened exclusively to pack');
// Get the table properties to determine table type...
Check(DbiGetCursorProps(Ta ble.Handle , Props));
// If the table is a Paradox table, you must call DbiDoRestructure...
if Props.szTableType = szPARADOX then
begin
// Blank out the structure...
FillChar(TableDesc, sizeof(TableDesc), 0);
// Get the database handle from the table's cursor handle...
Check(DbiGetObjFromObj(hDB IObj(Table .Handle), objDATABASE, hDBIObj(hDb)));
// Put the table name in the table descriptor...
StrPCopy(TableDesc.szTblNa me, Table.TableName);
// Put the table type in the table descriptor...
StrPCopy(TableDesc.szTblTy pe, Props.szTableType);
// Set the Pack option in the table descriptor to TRUE...
TableDesc.bPack := True;
// Close the table so the restructure can complete...
Table.Close;
// Call DbiDoRestructure...
Check(DbiDoRestructure(hDb , 1, @TableDesc, nil, nil, nil, FALSE));
end
else
// If the table is a dBASE table, simply call DbiPackTable...
if Props.szTableType = szDBASE then
Check(DbiPackTable(Table.D BHandle, Table.Handle, nil, szDBASE, TRUE))
else
// Pack only works on PAradox or dBASE; nothing else...
raise EDatabaseError.Create('Tab le must be either of Paradox or dBASE ' +
'type to pack');
Table.Open;
end;
meikl
after deleeing you must pack the table
here a sample from borland
you must placed the bde-unit in the uses clause
/ Pack a Paradox or dBASE table
// The table must be opened execlusively before calling this function...
procedure PackTable(Table: TTable);
var
Props: CURProps;
hDb: hDBIDb;
TableDesc: CRTblDesc;
begin
// Make sure the table is open exclusively so we can get the db handle...
if Table.Active = False then
raise EDatabaseError.Create('Tab
if Table.Exclusive = False then
raise EDatabaseError.Create('Tab
// Get the table properties to determine table type...
Check(DbiGetCursorProps(Ta
// If the table is a Paradox table, you must call DbiDoRestructure...
if Props.szTableType = szPARADOX then
begin
// Blank out the structure...
FillChar(TableDesc, sizeof(TableDesc), 0);
// Get the database handle from the table's cursor handle...
Check(DbiGetObjFromObj(hDB
// Put the table name in the table descriptor...
StrPCopy(TableDesc.szTblNa
// Put the table type in the table descriptor...
StrPCopy(TableDesc.szTblTy
// Set the Pack option in the table descriptor to TRUE...
TableDesc.bPack := True;
// Close the table so the restructure can complete...
Table.Close;
// Call DbiDoRestructure...
Check(DbiDoRestructure(hDb
end
else
// If the table is a dBASE table, simply call DbiPackTable...
if Props.szTableType = szDBASE then
Check(DbiPackTable(Table.D
else
// Pack only works on PAradox or dBASE; nothing else...
raise EDatabaseError.Create('Tab
'type to pack');
Table.Open;
end;
meikl
ASKER
it is necessary to pack the table so that the space occupied by the erased registries is released? or entendi badly? there is no another form?
result := Query.Fields[0].AsString;
or use the name of de column:
result := Query.FieldByName('Column_