resily
Database
Tables
(current)
Columns
Constraints
Relationships
Orphan Tables
Anomalies
Routines
copy_objective_parent_key_results
Parameters
Name
Type
Mode
organization_id
bigint
IN
objective_id_mapping
USER-DEFINED
IN
key_result_id_mapping
USER-DEFINED
IN
Definition
<<copy_objective_parent_key_results>> DECLARE old_objective_parent_key_result RECORD; BEGIN FOR old_objective_parent_key_result IN SELECT objective_parent_key_results.* FROM objective_parent_key_results WHERE objective_id::text = ANY (akeys(objective_id_mapping)) AND key_result_id::text = ANY (akeys(key_result_id_mapping)) LOOP EXECUTE $SQL$ INSERT INTO objective_parent_key_results ("organization_id", "objective_id", "key_result_id", "created_at", "updated_at") VALUES ($1, $2, $3, $4, $5) $SQL$ USING organization_id, (objective_id_mapping -> old_objective_parent_key_result.objective_id::text)::int8, (key_result_id_mapping -> old_objective_parent_key_result.key_result_id::text)::int8, old_objective_parent_key_result.created_at, old_objective_parent_key_result.updated_at; END LOOP; END;