# SQLCODE -151: Column cannot be updated

Source: https://wndsoftware.com/mainframe-errors/sqlcode-151

### SQLCODE -151: Column cannot be updated

SQLCODE -151 (SQLSTATE 42808) means an UPDATE tries to change a column that the Db2 catalog marks as not updatable. Typical cases are a view column that is calculated rather than taken from a table, and a catalog column that users may not change.


#### Other names for this code

Also written as `SQL -151`, `SQLCODE=-151`, `SQLCODE = -151`, `db2 -151`, `sqlstate 42808`, `SQL0151N`, `column cannot be updated`.


### What it means

Db2 records, for every column of every table and view, whether it can be updated. The flag is the UPDATES column of SYSIBM.SYSCOLUMNS. When an UPDATE, or the update part of a MERGE, sets a column whose flag says no, Db2 rejects the statement with -151 and names the column.

A view column can only be updated if it maps straight to a column of a base table. If the view defines it as an expression, a constant, a function result or a column of another view that is itself not updatable, there is nowhere to put the new value. The rest of the view may still be updatable. Only that column is blocked.

The Db2 catalog is the other common place. Some catalog columns, such as many statistics columns, can be updated by authorized users. Others are maintained only by Db2, and an UPDATE on them gets -151.

This is different from -150, which means the whole view or table can't be changed.


### Common causes

- A view column defined as an expression, such as `SALARY * 12 AS ANNUAL_PAY`, or as SUBSTR, CONCAT or another function.
- A view column defined as a constant, such as `'ACTIVE' AS STATUS`.
- A view built on another view whose column is already not updatable.
- An UPDATE on a column of a Db2 catalog table that Db2 doesn't let users change, often in a statistics or migration script.


### How to find the problem

- Take the column name from the `DSNT408I` message or SQLERRMC.
- Check the flag with `SELECT NAME, UPDATES FROM SYSIBM.SYSCOLUMNS WHERE TBCREATOR = 'PAYPROD' AND TBNAME = 'EMP_VIEW'`. N means the column can't be updated.
- Read the view definition in SYSIBM.SYSVIEWS to see how the column is derived.
- For a catalog update, check the catalog table description in the SQL Reference for which columns can be updated.


### How to fix it

- Update the base column the view column is derived from, through the view if that column is exposed, or on the base table.
- Leave calculated columns out of the SET clause. They change on their own when their source columns change.
- If users must update the column through the view, redefine the view so the column maps directly to a base column, or add an INSTEAD OF trigger.
- For catalog statistics, update only the columns IBM documents as updatable, or let RUNSTATS set them.


### What it looks like


```text
DSNT408I SQLCODE = -151, ERROR:  THE UPDATE OPERATION IS INVALID BECAUSE THE CATALOG
         DESCRIPTION OF COLUMN ANNUAL_PAY INDICATES THAT IT CANNOT BE UPDATED
DSNT418I SQLSTATE   = 42808 SQLSTATE RETURN CODE
```


### IBM documentation

[IBM documentation: -151](https://www.ibm.com/docs/en/db2-for-zos/13.0.0?topic=codes-151). Use the documentation for your installed release.

[Report a correction to WND Software](https://wndsoftware.com/contact#message).

Technical reviewer: [Albert Joseph](https://wndsoftware.com/authors/albert-joseph), WND Software.

Last reviewed 2026-10-18 by the WND Software team. Written in our own words. For the full reference, check IBM’s Db2 for z/OS documentation for your release.


### Related codes

[SQLCODE -150 Operation not allowed on this view or table Read →](https://wndsoftware.com/mainframe-errors/sqlcode-150)
[SQLCODE -206 Column name not valid Read →](https://wndsoftware.com/mainframe-errors/sqlcode-206)
[SQLCODE -205 Column not in the named table Read →](https://wndsoftware.com/mainframe-errors/sqlcode-205)
[SQLCODE -117 Number of values doesn't match columns Read →](https://wndsoftware.com/mainframe-errors/sqlcode-117)

### Questions


#### Why can I update some columns of the view but not others?

Each view column is checked on its own. Columns taken straight from a table can be updated, while calculated or constant columns can't.


#### What is the difference between -150 and -151?

-150 means the whole view or table doesn't allow the operation. -151 means the object allows updates, but the named column doesn't.


#### Is it the same on Db2 for LUW?

Yes. SQL0151N has SQLSTATE 42808 and also means the named column can't be updated.

[Db2 SQLCODEs](https://wndsoftware.com/mainframe-errors/db2-sqlcodes) · [SQLCODE -150](https://wndsoftware.com/mainframe-errors/sqlcode-150) · [SQLCODE -171](https://wndsoftware.com/mainframe-errors/sqlcode-171)

[← All error codes](https://wndsoftware.com/mainframe-errors/)
