0

I would like to ask if there is a way to prohibit programs to change data in certain columns, at db2 level.

The problem is that I have some programs that change data in a group of tables but now I must not change data in some columns and I would like to know if there is a way that db2 can make that restriction.

I could change all the programs but would like to know if there is an easier way to block changes in a column.

VLAZ
  • 26,331
  • 9
  • 49
  • 67
Ricardo Pinto
  • 333
  • 1
  • 2
  • 11
  • Those existing programs that modify data in specific column(s), are they to be modified? What do you expect those programs to do , if they try to modify data in specific column and Db2 prevents it and throws an error? – mao May 05 '20 at 17:39
  • yes, I was expecting an error changing data in that columns – Ricardo Pinto May 06 '20 at 06:55

2 Answers2

1

You may create, let's say, BEFORE UPDATE OF COL1, ..., COLx trigger on this table with a SIGNAL statement inside.
Alternatively you may revoke the update privilege on this table from everyone and grant update on a subset of columns needed only.

Mark Barinstein
  • 11,456
  • 2
  • 8
  • 16
0

Another option is to create a view with a subset of the columns you need to update. It may be a little more complex in case you need to rebind your program(s)

Michael
  • 11
  • 2