Is there a way to add a table as an input?

I find myself updating a certain set of fields/columns in different tables repeatedly. These columns appear as the same names same types across these different tables. I would like to be able to write one function that accepts the ā€œtable nameā€ and then simply update these columns/fields in the provided table instead of building one function for each table update.

e.g. I need to always edit start_date, end_date, ID, updated_at. Same fields are in the following tables:

employee, jobs, department etc.

I want a situation where I can provide these fields as inputs and the tables too as inputs. Such that the function takes the fields value provided and the edits the table provided, say, employees with them. If jobs table is provided, it updates jobs too with the same value provided for the fields. I don’t know whether the table name should be the input for the table or an object/schema of the the table type etc.

I know this might be almost impossible but would also appreciate another approach that avoids repeating same functions for each table. Thanks I’m advance.

2 replies