Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copying data from a field in an SQLTable to another. 1

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA
I am using Delphi 6 Enterprise and Interbase 6.

How does one copy data from a field (say P_NO) in a Table (say CHILD) of an SQLDataBase (say PCHILD.gdb) into a field (say P_NO) in a Table (say TRNSFR) of an SQLDataBase say PCHILD.gdb)?
 
hi,

update TRNSFR
set
P_NO = CHILDP_NO.VALUE
where
ID = ID

it will update in table TRNSFR the field P_NO with the value
from Child where ID = ID.
The best to perfom this is to fill the sql query at run time just before the execution of the query.

steph [bigglasses]
 
Can you please elaborate upon where I put this?

I am using an IBDataSet and to put .value in ModifySQL causes a melt-down. :)

Using your suggestion I would like to do the following but I get a Undeclared identifier 'SQL' exception at point A.

procedure TChildrenDM.IBDataSet1AfterScroll(DataSet: TDataSet);
begin
SQL.Clear; ...................................A
SQL.Add ('UPDATE TRNSFR');
SQL.Add ('SET C_NO = CHILDC_NO.VALUE ');
SQL.Add ('WHERE P_NO = P_NO');
Active := True;
end;

Any further suggestions?
 
hi,

i think it should read this:


procedure TChildrenDM.IBDataSet1AfterScroll(DataSet: TDataSet);
begin
with ibdataset1 do
begin
ModifySQL.Clear;
ModifySQL.Add ('UPDATE TRNSFR');
ModifySQL.Add ('SET C_NO = CHILDC_NO.VALUE ');
ModifySQL.Add ('WHERE P_NO = P_NO');
Active := True;
end;
end;


steph
 
Thanks. :) I'll go back and try that too.

But perhaps I should provide more details.

I have a TDataModule (dmData) (in a ThinClient) on which I have

TDCOMConnection1 hooded to a (running) ApplicationServer.
TClientDataSet which is hooked to above a via the Remote Server Property.

TDataSource (dsFather) which is hooked to the TIBdataSet below.
TIBTransaction (IBFatherTrans) " " TIBDataBase below
TIBDataBase (IBFatherDBase) " " C:\h\PChild\Tables\PCHILD.GDB
TIBdataSet (IBFatherDataSet) " " TIBTransaction above.
In the SelectSQL Editor of the TIBdataSet I have the following
SELECT *
FROM PARENT

In addition I have
TIBdataSet (IBTrnsfrDataSet) with the DataBase property set to IBFatherDbase above.
DataSource propery set to dsFather above.
In the SelectSQL Editor I have the following.
update TRNSFR
set
C_NO =:CHILDC_NO
where
P_NO =:p_NO

I have a TForm with a TDBGrid which is hooked to dsFather above via the DataSource Property.

The project compiles but the value of P_NO in TABLETrnsfr of the above DataBase
(PChild) remains unaffected by the following. What am I missing?

procedure TdmData.IBFatherDataSetAfterScroll(DataSet: TDataSet);
begin
with dmData do
begin
if dsFather.state in dsEditModes then
else
dsFather.Edit;
IBFatherDataSet.Post;
end;
end;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top