Check for new attributes in the refcursor and refelct it into the destination table
If new questions are added to the form, we need to reflect it on the database side before inserting new data. We need to compare refcursor attribute list to destination table attribute list :
SELECT column_name
FROM information_schema.columns
WHERE table_name = 'xxx' AND table_schema = 'yyy'
ORDER BY ordinal_position
So maybe we could process ike this : 1 : Does the destination table already exists ?
- YES -> does exists tHEN check for new columns :
- if new columns the creat it
- else do nothing
- NO -> create the table (IF EXISTS statement is not needed) 2 : Process the INSERT statement
Then create new attributes to the destination table (alter table add column).
And add the attribute list to be inserted in the insert statement of insert_into_from_refcursor.sql using (JSON_EACH(TO_JSON(_row))).key