Board index » delphi » TQuery Record read/write with one statement ??

TQuery Record read/write with one statement ??

Do any of  you Delphi Pros know of a way to perform a TQuery record read
and write in one one statement ??
I would like to perform the following type of opperation :
...
q1.active := True;
q2.active := True;
  q2.insert;
  q2.all_fields := q1.all_fields;   << This statement >>
  q2.key_field := some_other_value...;
  q2.post;
q2.active := False;
q1.active := False;
...

Thanks for any help.
***************************
Jim Carter *Email:j...@pcssys.com
***************************

 

Re:TQuery Record read/write with one statement ??


Hmm. I suppose that in theory you could something like this... but I haven't
tried it, so you're welcome to do so. :)

Juan

Procedure Moveit;
var x: integer;
begin
 q1.active := True;
 q2.active := True;
   q2.insert;
   for x := 1 to q2.fieldcount do
         q2.FieldValues[q2.Fields[x].FieldName] :=
q1.FieldValues[q1.Fields[x].FieldName];
   q2.post;
 q2.active := False;
 q1.active := False;
end;

Quote
Jim Carter wrote in message <35857D81.12DD3...@pcssys.com>...
>Do any of  you Delphi Pros know of a way to perform a TQuery record read
>and write in one one statement ??
>I would like to perform the following type of opperation :
>...
>q1.active := True;
>q2.active := True;
>  q2.insert;
>  q2.all_fields := q1.all_fields;   << This statement >>
>  q2.key_field := some_other_value...;
>  q2.post;
>q2.active := False;
>q1.active := False;
>...

>Thanks for any help.
>***************************
>Jim Carter *Email:j...@pcssys.com
>***************************

Re:TQuery Record read/write with one statement ??


Thanks, Your suggestion sure pointed me in the correct direction.   It seems
that the following code works ok, what do you think ?

      for x := 0 to q2.fieldcount - 1 do
         q2.Fields[x] := ql.Fields[x];

Have any other Ideas ??
-- Jim

Quote
Juan Jimenez (TeamB) wrote:
> Hmm. I suppose that in theory you could something like this... but I haven't
> tried it, so you're welcome to do so. :)

> Juan

> Procedure Moveit;
> var x: integer;
> begin
>  q1.active := True;
>  q2.active := True;
>    q2.insert;
>    for x := 1 to q2.fieldcount do
>          q2.FieldValues[q2.Fields[x].FieldName] :=
> q1.FieldValues[q1.Fields[x].FieldName];
>    q2.post;
>  q2.active := False;
>  q1.active := False;
> end;

> Jim Carter wrote in message <35857D81.12DD3...@pcssys.com>...
> >Do any of  you Delphi Pros know of a way to perform a TQuery record read
> >and write in one one statement ??
> >I would like to perform the following type of opperation :
> >...
> >q1.active := True;
> >q2.active := True;
> >  q2.insert;
> >  q2.all_fields := q1.all_fields;   << This statement >>
> >  q2.key_field := some_other_value...;
> >  q2.post;
> >q2.active := False;
> >q1.active := False;
> >...

> >Thanks for any help.
> >***************************
> >Jim Carter *Email:j...@pcssys.com
> >***************************

Other Threads