Subject Re: [firebird-support] Copying records from a table to other table
Author Martijn Tonies
Hi,

> I know that is a simple mistake mine.
>
> My script is:
> INSERT INTO cpforneced ( CODEMP, CODFILIAL, CODFOR,
> RAZFOR, CODEMPTF, CODFILIALTF, CODTIPOFOR, CODEMPBO,
> CODFILIALBO, CODBANCO, NOMEFOR, DATAFOR, ATIVOFOR, PESSOAFOR,
> CNPJFOR, CPFFOR, INCFOR, RGFOR, ENDFOR, NUMFOR,
> COMPLFOR, BAIRFOR, CEPFOR, CIDFOR, UFFOR, CONTFOR,
> FONEFOR, FAXFOR, AGENCIAFOR, CONTAFOR, EMAILFOR )
> values

you're trying to get data from "co1for", but there's no SELECT statement.

> ( 99, 1, c01for.cod_for, c01for.raz_soc, 99, 1, 1,
> NULL, NULL,NULL, c01for.nom_fan, NULL, 'N', c01for.tip_pes,
> c01for.nro_cgc,c01for.nro_cpf,null,c01for.des_end, null,
> null, c01for.bai_end, c01for.cep_end, c01for.nom_cid,
> c01for.sig_est, c01for.nom_con, c01for.fon_001,
> c01for.fax_001,null, null, c01for.end_ema )
>

Try:

insert into cpforneced ( CODEMP, CODFILIAL, CODFOR,
RAZFOR, CODEMPTF, CODFILIALTF, CODTIPOFOR, CODEMPBO,
CODFILIALBO, CODBANCO, NOMEFOR, DATAFOR, ATIVOFOR, PESSOAFOR,
CNPJFOR, CPFFOR, INCFOR, RGFOR, ENDFOR, NUMFOR,
COMPLFOR, BAIRFOR, CEPFOR, CIDFOR, UFFOR, CONTFOR,
FONEFOR, FAXFOR, AGENCIAFOR, CONTAFOR, EMAILFOR )
select 99, 1, co1for.cod_for, ... etc etc
from co1for


Martijn Tonies
Database Workbench - tool for InterBase, Firebird, MySQL, NexusDB, Oracle &
MS SQL Server
Upscene Productions
http://www.upscene.com
My thoughts:
http://blog.upscene.com/martijn/
Database development questions? Check the forum!
http://www.databasedevelopmentforum.com

> There the two tables, C01FOR and CPFORNED on the same database, the
CPFORNED is the destination and C01FOR is the source data, that was migrate
from a DBF to inside the database.
>
> The error that I have is:
>
/***************************************************************************
****
> The next statement causes the following error:
> Column does not belong to referenced table.
> Dynamic SQL Error.
> SQL error code = -206.
> Column unknown.
> C01FOR.COD_FOR.
> At line 8, column 17.
>
****************************************************************************
***/
>
> There the table C01FOR and the column COD_FOR normaly.
>
> What I'm doing wrong ?