Board index » delphi » Copy record inside one table

Copy record inside one table

Hi

How can I copy records inside my table.

Let say I have one table called CommonReportInfo

ReportID int
DatabaseID int
Info char255

ReportID and DatabaseID is the combined key "unique" (cannot remember the
correct english word for it)

Now I need to copy all records from one report to another report.

I need to be able to set the destination ReportID and the Source ReportID in
that query.

Is that possible or do I have to use two queries and manually copy the data
in  a loop?

regards
Henrik

 

Re:Copy record inside one table


insert into CommonReportInfo
select
  50 as ReportID,
  51 as DatabaseID,
  Info
from
  CommonReportInfo
where
  ReportID=20 and
  DatabaseID=21

Eric

Re:Copy record inside one table


Quote
> insert into CommonReportInfo
> select
>   50 as ReportID,
>   51 as DatabaseID,
>   Info
> from
>   CommonReportInfo
> where
>   ReportID=20 and
>   DatabaseID=21

Hi Eric

Thanks, that's real good!

However is it supposed to work with blob fields too? I made a mistake the
info is a blob.

regards
Henrik

Re:Copy record inside one table


Some databases let you select blob fields in the select statement.  Others
do not.  Oracle for instance will let you use a blob field in a select
statement, but you cannot do a "create table bob as select * from fred" when
fred has a blob column.  There are ways around this, but I need some more
specifics.

What database are you using and how do you connect to it?

Eric

Quote
> However is it supposed to work with blob fields too? I made a mistake the
> info is a blob.

Re:Copy record inside one table


Quote
> Some databases let you select blob fields in the select statement.  Others
> do not.  Oracle for instance will let you use a blob field in a select
> statement, but you cannot do a "create table bob as select * from fred"
when
> fred has a blob column.  There are ways around this, but I need some more
> specifics.

> What database are you using and how do you connect to it?

I was trying to avoid that question, it's embarrassing to tell taht I'm
still using BDE, it's simply paradox table I'm using SQL on.

I have made a workaround solution, I wont get a prize for that but it works
I'm doing it manually. I have serious problems wrinting the the blob fields
in an insert statement, but it works like a charm in the update statement
wierd. I simply doing an insert and then an update.

I would like to do it the right way, this feels a bit clumsy.

regards
Henrik

Other Threads