Alright, so let’s say I have a database with a table named “COMPANY_PARAMETERS” that looks something like this (the first two columns are the keys):
COMP_ID | PARAM_NAME | PARAM_VALUE
A | parameter 1| 10
A | sample_ind | Y
B | parameter 1| 20
B | sample_ind | N
I would like to insert a new parameter, let’s say parameter 2 into the table, for every company Id in the table. I do not know which company Id to expect, since any client can have any company Id they want, so one client might have company Ids 1,2,3,4 and another might have A,B,C,D, etc. We use a series of update scripts that we store on the repository any time we update the database. I’ve asked around and this is one of the rare (only) tables that is simply unique to every client, but I would like to try anyway.
I’ve been working with databases for less than a year and I don’t really know where to start with a problem like this. My guess would be to use a select statement to find all unique comp_Ids and then insert a row for every one of them.
Your help is much appreciated.
-Asaf
If you wanted to be extra careful, you could extend the query to make sure the new parameter doesn’t already exist.