0

I have a update query. When i execute the below query it shows assignment to generated column.

Create Table Query :

CREATE TABLE  group1 (
  main_group varchar(20) GENERATED ALWAYS AS ('N/A'),
  group_name varchar(50) NOT NULL,
  group_id INTEGER GENERATED BY DEFAULT AS IDENTITY(start with 1)
);

Update Query :

update group1 set main_group = 'Asset' where group_name = 'Current Assets'

Error :

Error code -5513, SQL state 42513: assignment to generated column
Line 1, column 1

I have checked with syntax is right.

Edit : Added Create table query for group1 table.

Help me out of this issue...

Thanks in advance..

4

1 回答 1

1

This table definition meas the value of main_group is ALWAYS generated as the string 'N/A'. It therefore cannot be updated. Obviously you do not want this. You should remove the GENERATATED ALWAYS AS ('N/A') clause.

If you want the default value of this column to be 'N/A' then use a DEFAULT clause. You should also define a primary key for your table.

CREATE TABLE  group1 (
  main_group varchar(20) DEFAULT 'N/A',
  group_name varchar(50) NOT NULL,
  group_id INTEGER GENERATED BY DEFAULT AS IDENTITY(start with 1) PRIMARY KEY
);
于 2012-11-05T04:53:55.463 回答