Copy data of some fields from one table to another

Table: AccountCodeLevel1
Screenshot from 2021-08-26 17-20-57

Table: AccountCodeLevel1Temp
Screenshot from 2021-08-26 17-22-18

Query:
Screenshot from 2021-08-26 17-24-21

insert into "AccountCodeLevel1Temp" ("AccountCodeLevel1", "AccountNameLevel1English", "AccountNameLevel1Local") select "AccountCodeLevel1", "AccountNameLevel1English", "AccountNameLevel1Thai" from "AccountCodeLevel1"

Error message:
Screenshot from 2021-08-26 17-45-59

What was wrong in this query ?

Fedora 34 Workstation Official Edition
Embedded Firebird
LibreOffice Community | Version: 7.1.5.2
Build ID: 10(Build:2)
CPU threads: 4
OS: Linux 5.13
UI render: default
VCL: gtk3
Locale: en-US (en_US.UTF-8); UI: en-US
Calc: threaded

Are you trying to insert through SQL by the query editor?

Copy the code into Tools → SQL. The query editor is only for queries. Code must start with SELECT.

The error seems to be misleading then.

1 Like

The result:


CopyDataOfSomeFieldsFromOneTableToAnother0.odb (144.7 KB)

=============================================

I have created a new database with the same tables, the error message is not the same as shown above.
Screenshot from 2021-08-26 23-42-28
Screenshot from 2021-08-26 23-43-16
CopyDataOfSomeFieldsFromOneTableToAnother1.odb (4.5 KB)

Question: Is Firebird Case-sensitive?
You have EngLish with L instead of l in your temp-table. Would fit to the error

You are right: Try the query

select "AccountCodeLevel1", "AccountNameLevel1English", "AccountNameLevel1Thai" from "AccountCodeLevel1Temp"

It won’t work because the “AccountNameLevel1English” is written “AccountNameLevel1EngLish” in the table. If you change the name of the column in the table it will work. The primary key isn’t needed, because both keys are auto values.

In the first sample the primary keys have auto values. In the second sample they do not.

Hello,

Using your last sample, it is missing the “ID” field as this is a primary key field and not an auto increment field. Including that all worked:

1 Like