Subject | Re: [firebird-support] Increase the max context number |
---|---|
Author | Magno Machado |
Post date | 2007-04-16T11:48:47Z |
>Ok...
> Provide examples of the structures of perhaps two related source
> tables, along with their corresponding tables in the destination
> database
In both source and destination databases, I have a table called
CIDADES('cidades' means cities in portuguese) with the following fields:
Cidade(Integer, primary key), CidNome(String), CidUf(String),
CidOutPais(Char), CidPais(String), CidKm(Integer), CidEdi(String),
CodPais(Integer)
The field CosPais is a foreign key to a table called PAIS(Country in
portuguese), with these fields:
CodPais(Integer, primary key), NomePais(String), LExterior(Char).
In the dest database, those tables have the following ddl:
CREATE TABLE PAIS (
CODPAIS INTEGER NOT NULL,
NOMPAIS VARCHAR(30) NOT NULL,
LEXTERIOR CHAR(1) NOT NULL,
PRIMARY KEY (CODPAIS)
);
CREATE TABLE CIDADE (
CIDADE INTEGER NOT NULL,
CIDNOME VARCHAR(30) NOT NULL,
CIDUF CHAR(2) NOT NULL,
CIDKM INTEGER,
CIDEDI VARCHAR(18)
CIDOUTPAIS CHAR(1) NOT NULL,
CIDPAIS VARCHAR(30) NOT NULL,
CODPAIS INTEGER NOT NULL,
PRIMARY KEY(CIDADE),
FOREIGN KEY(CODPAIS) REFERENCES PAIS(CODPAIS) ON UPDATE CASCADE
);
(Note that in many cases, both source and dest tables are identical)
To translate the data from the source structure to the dest structure I have
a view for each dest table. When dest table and their correspondent on the
source database are identical, that view is auto-generated by a software
i've wrote. So, for the tables CIDADE and PAIS, the views are:
CREATE VIEW VW_PAIS(
CODPAIS,
NOMPAIS,
LEXTERIOR
)
AS
SELECT
CODPAIS,
NOMPAIS,
LEXTERIOR
FROM
PAIS
;
CREATE VIEW_VW_CIDADE(
CIDADE,
CIDNOME,
CIDUF,
CIDKM,
CIDEDI,
CIDOUTPAIS,
CIDPAIS,
CODPAIS
)
AS
SELECT
CID.CIDADE,
CID.CIDNOME,
CID.CIDUF,
CID.CIDKM,
CID.CIDEDI,
CID.CIDOUTPAIS,
CID.CIDPAIS,
PAIS.CODPAIS
FROM
CIDADE CID
LEFT JOIN VW_PAIS PAIS ON CID.CODPAIS=PAIS.CODPAIS
;
(The tables referenced in the views are copies of the source tables. The
data returned by the views are copied into the destination tables)
13 Apr 2007 20:01:19 -0700, Helen Borrie <helebor@...>:
>[Non-text portions of this message have been removed]
> At 11:57 AM 14/04/2007, you wrote:
> >I'm developing a software to transfer data from a set of dbf tables to a
> >firebird database.
> >I can't change the structure of the source or destination databases.
> >And in the strategy that I'm using to convert the data from those two
> >different data-structure I need to have a view for each table of de
> >destination database, with the same structure. And those views must
> >implements the same relationships of the respective destination tables.
>
> This still sounds weird, to put it politely.
>
> Provide examples of the structures of perhaps two related source
> tables, along with their corresponding tables in the destination
> database. I have been following your threads and it's my observation
> that it would take a very bold person to try to guess what you are
> doing, never mind attempt to guide you out of this bird's nest...
>
> ./heLen
>
>
>