I have a table with 6 columns program_id
, a
, b
, c
, d
and e
(there are actually other columns as well, but for the moment/question this is all that is needed). There is also a reference table with the following fields. id
, program_id
, a
, b
, c
, d
and e
.
Table 1:
program_id, a, b, c, d, e
1, , , , ,
2, , , , ,
1, , , , ,
3, , , , ,
Table 2 (ref):
id, program_id, a, b, c, d, e
1, 1, NULL, Y, NULL, Y, NULL
2, 2, Y, NULL, Y, NULL, NULL
3, 4, Y, NULL, Y, NULL, NULL
4, 5, NULL, Y, Y, NULL, Y
In my reference table the a-e columns are on/off or yes/no.
What I need to happen is that table 1 will only allow updates to fields that have a NULL value for the corresponding program_id
. So in the case of program_id 1
lets say. column a, c and e
will allow updates, column b and d
will not.
in the case of program_id 2
columns and and c
will not allow any updates and column b, d and e
will allow them.
I have a sql table with a trigger - I was thinking of building that logic into an insert trigger (although I'm not sure if that is the best place).
The plan is to run this code to enter the 50 or so programs into table 1 yearly. (there is also a year field to distinguish the data further). Once the data is inserted what is the best way to say can't update this data instead pull the values already calculated from a third (different table ... table 3).
This data will be displayed via infoamker/sybase into a third party software. But the big challenge is to get it into the code first then once its there how do i not allow the user to update those fields in infomaker and only update the NULL ones.
is this possible? (and how do i do it).
Thanks.