Board index » delphi » Copying/Duplicating a record in a database

Copying/Duplicating a record in a database

I'm using Oracle 8.05 and a tquery and dbedits in delphi 3 client server

What is a simplistic way to make a copy or duplicate
the current selected record in a dbgrid. I can achieve this but is not a
very efficient
I had to write quite a bit of code. There must be a easier method for
doing this
Thanks for any help
Dean

 

Re:Copying/Duplicating a record in a database


Do you want to dup to the same dbgrid or to another one?

Juan

Quote
DHastas wrote:

> I'm using Oracle 8.05 and a tquery and dbedits in delphi 3 client server

> What is a simplistic way to make a copy or duplicate
> the current selected record in a dbgrid. I can achieve this but is not a
> very efficient
> I had to write quite a bit of code. There must be a easier method for
> doing this
> Thanks for any help
> Dean

Re:Copying/Duplicating a record in a database


I want to dup to the same dbgrid!
Quote
Juan Jimenez wrote:
> Do you want to dup to the same dbgrid or to another one?

> Juan

> DHastas wrote:

> > I'm using Oracle 8.05 and a tquery and dbedits in delphi 3 client server

> > What is a simplistic way to make a copy or duplicate
> > the current selected record in a dbgrid. I can achieve this but is not a
> > very efficient
> > I had to write quite a bit of code. There must be a easier method for
> > doing this
> > Thanks for any help
> > Dean

Re:Copying/Duplicating a record in a database


I've done it by: inserting a new record in a separate TQuery (same table)
and looping through the fields. Example:

  QueryTmp.Open;
  QueryTmp.Insert;
  for ii := 0 to Query1.FieldDefs.Count - 1 do
  begin
    QueryTmp.Fields[ii].Value := Query1.Fields[ii].Value;
  end;
  QueryTmp.Post;
  // you may want to refresh Query1 at this point;

Please excuse that this little code snippet was not ever tested.  It was
just off the top of my head.  I hope it helps.

eGreg

DHastas <d...@investrak.com> wrote in article
<39C3AB78.D879...@investrak.com>...

Quote
> I'm using Oracle 8.05 and a tquery and dbedits in delphi 3 client server

> What is a simplistic way to make a copy or duplicate
> the current selected record in a dbgrid. I can achieve this but is not a
> very efficient
> I had to write quite a bit of code. There must be a easier method for
> doing this
> Thanks for any help
> Dean

Re:Copying/Duplicating a record in a database


What's wrong with using the same record to create a new one, insert it,
then close an reopen the query?

Juan (TeamB)

Quote
Dean Hastas wrote:

> I want to dup to the same dbgrid!

> Juan Jimenez wrote:

> > Do you want to dup to the same dbgrid or to another one?

> > Juan

> > DHastas wrote:

> > > I'm using Oracle 8.05 and a tquery and dbedits in delphi 3 client server

> > > What is a simplistic way to make a copy or duplicate
> > > the current selected record in a dbgrid. I can achieve this but is not a
> > > very efficient
> > > I had to write quite a bit of code. There must be a easier method for
> > > doing this
> > > Thanks for any help
> > > Dean

Other Threads