Board index » delphi » Obviously overlooking something?

Obviously overlooking something?

Hello,

now I'm a bit confused. I have a Table1 needed to be restructured.

I use Database Desktop to make a new Table2 borrowing the structure of
Table1. Then I have an empty Table2 and restructure it as needed.
This I want to fill with the content of Table1, using a BatchMove1 with
batAppend mode.

Then it can't be done because the structure is not the same, is the error
message.

How can I then easy fill new structures with old structures data?

I mean, I can't use Database Desktop to directly restructure my customers
tables, it has to be an easier way to upgrade to a new version without loss
of data.

--
:)
Kai Inge

There's no such thing as an innocent user
-- Dark Avenger, in a Wired interview

 

Re:Obviously overlooking something?


...

Quote

> How can I then easy fill new structures with old structures data?

Writing a program that reads records from table1 and appends them to
table2 will probably take you around 5 minutes. I suspect its easier
and faster than mucking around with DBD or datapump...

Dima
--
"Whoops.  There goes another one.  Sorry.  But just wait
for Skys{*word*99}er 1.1; it'll be 100% collapse-free!"
        -- Bruce Schneier, in RISKS 20.90
---------------------------------------------------------
Sweetmorn, 30 Confusion 3166, 31:1:4 (1)

Re:Obviously overlooking something?


Ellinor Jensen <elli...@online.no> wrote

Quote
> Hello,

> now I'm a bit confused. I have a Table1 needed to be restructured.

> I use Database Desktop to make a new Table2 borrowing the structure of
> Table1. Then I have an empty Table2 and restructure it as needed.
> This I want to fill with the content of Table1, using a BatchMove1 with
> batAppend mode.

> Then it can't be done because the structure is not the same, is the error
> message.

> How can I then easy fill new structures with old structures data?

> I mean, I can't use Database Desktop to directly restructure my customers
> tables, it has to be an easier way to upgrade to a new version without loss
> of data.

Using Database desktop don't make a new table and borrow the structure,
just alter the structure of the existing table.
But the cleanest way is to include the restructuring in the new program
update. Check the local SQL help file how this can be done. Look for
ALTER TABLE etc.

Peter Reber

Re:Obviously overlooking something?


Quote
Ellinor Jensen wrote:
> Hello,

> now I'm a bit confused. I have a Table1 needed to be restructured.

> I use Database Desktop to make a new Table2 borrowing the structure of
> Table1. Then I have an empty Table2 and restructure it as needed.
> This I want to fill with the content of Table1, using a BatchMove1 with
> batAppend mode.

> Then it can't be done because the structure is not the same, is the error
> message.

If your new table has fewer columns than the old, you can use the mappings
property of TBatchMove. Granted that this is probably not the case (most tables
I work with have columns added to them). However, I suspect that MAPPINGS will
work if the destination table has more columns, so this could be a good chance.
Just enter the names of all the columns in the old table eg columnname, If the
name has changed, then supply the new name thus : oldname=newname. It should
work. Have a look in the Delphi help under the Mappings property or have a look
at the example on my Web Page www.pcug.org.au/~graydr to get a feel.

The other possiblility is to use SQL to populate the table .There is a special
form of SQL called a correlated insert. Basically:

INSERT INTO table
 VALUES ( SELECT column1, column2, 'constant' from table1 )  - I think?

Not sure whether this is actually possible with the BDE but it is a solution.

Quote
> How can I then easy fill new structures with old structures data?

> I mean, I can't use Database Desktop to directly restructure my customers
> tables, it has to be an easier way to upgrade to a new version without loss
> of data.

I suspect that you can write code to restructure the database using BDE calls
but have never done this myself.

Re:Obviously overlooking something?


Thank you for the answer.
It seems that it's no way around, but I hoped there was a way to avoid
'manually' coding the name of 110 fields/coloumns.
Thanks anyway.

:)
Kai Inge

Quote
"David Gray" <gra...@NOSPAM.pcug.org.au> wrote in message

news:395E070D.351A1EB5@NOSPAM.pcug.org.au...
Quote
> Ellinor Jensen wrote:

> > Hello,

> > now I'm a bit confused. I have a Table1 needed to be restructured.

> > I use Database Desktop to make a new Table2 borrowing the structure of
> > Table1. Then I have an empty Table2 and restructure it as needed.
> > This I want to fill with the content of Table1, using a BatchMove1 with
> > batAppend mode.

> > Then it can't be done because the structure is not the same, is the
error
> > message.

> If your new table has fewer columns than the old, you can use the mappings
> property of TBatchMove. Granted that this is probably not the case (most
tables
> I work with have columns added to them). However, I suspect that MAPPINGS
will
> work if the destination table has more columns, so this could be a good
chance.
> Just enter the names of all the columns in the old table eg columnname, If
the
> name has changed, then supply the new name thus : oldname=newname. It
should
> work. Have a look in the Delphi help under the Mappings property or have a
look
> at the example on my Web Page www.pcug.org.au/~graydr to get a feel.

> The other possiblility is to use SQL to populate the table .There is a
special
> form of SQL called a correlated insert. Basically:

> INSERT INTO table
>  VALUES ( SELECT column1, column2, 'constant' from table1 )  - I think?

> Not sure whether this is actually possible with the BDE but it is a
solution.

> > How can I then easy fill new structures with old structures data?

> > I mean, I can't use Database Desktop to directly restructure my
customers
> > tables, it has to be an easier way to upgrade to a new version without
loss
> > of data.

> I suspect that you can write code to restructure the database using BDE
calls
> but have never done this myself.

Re:Obviously overlooking something?


Ouch! How painful and a horror to maintain. I NEVER restructure
manually or even use batchmove to restructure but I do it directly
on the table. There are various methods depending on what you need
to do. (Almost) anything can be done using SQL (ALTER TABLE) and
fields can also be added using a table and AddFields.
What is more difficult is to change the field type of to change
the size of a string field, there you need to make BDE calls
directly or find a work-around. Using batchmove just do the trick
here without objecting.
It is well worthwhile to dig into this restructure thing deeper.

Peter Reber

Quote
Ellinor Jensen <elli...@online.no> wrote in message news:94A75.5227$MS3.108831@news1.online.no...
> Thank you for the answer.
> It seems that it's no way around, but I hoped there was a way to avoid
> 'manually' coding the name of 110 fields/coloumns.
> Thanks anyway.

> :)
> Kai Inge

> "David Gray" <gra...@NOSPAM.pcug.org.au> wrote in message
> news:395E070D.351A1EB5@NOSPAM.pcug.org.au...
> > Ellinor Jensen wrote:

> > > Hello,

> > > now I'm a bit confused. I have a Table1 needed to be restructured.

> > > I use Database Desktop to make a new Table2 borrowing the structure of
> > > Table1. Then I have an empty Table2 and restructure it as needed.
> > > This I want to fill with the content of Table1, using a BatchMove1 with
> > > batAppend mode.

> > > Then it can't be done because the structure is not the same, is the
> error
> > > message.

> > If your new table has fewer columns than the old, you can use the mappings
> > property of TBatchMove. Granted that this is probably not the case (most
> tables
> > I work with have columns added to them). However, I suspect that MAPPINGS
> will
> > work if the destination table has more columns, so this could be a good
> chance.
> > Just enter the names of all the columns in the old table eg columnname, If
> the
> > name has changed, then supply the new name thus : oldname=newname. It
> should
> > work. Have a look in the Delphi help under the Mappings property or have a
> look
> > at the example on my Web Page www.pcug.org.au/~graydr to get a feel.

> > The other possiblility is to use SQL to populate the table .There is a
> special
> > form of SQL called a correlated insert. Basically:

> > INSERT INTO table
> >  VALUES ( SELECT column1, column2, 'constant' from table1 )  - I think?

> > Not sure whether this is actually possible with the BDE but it is a
> solution.

> > > How can I then easy fill new structures with old structures data?

> > > I mean, I can't use Database Desktop to directly restructure my
> customers
> > > tables, it has to be an easier way to upgrade to a new version without
> loss
> > > of data.

> > I suspect that you can write code to restructure the database using BDE
> calls
> > but have never done this myself.

Other Threads