Create new columns if not exist

Hi everyone,

Is there a way to export into a database table with a dynamic structure determined by a pivot in EasyMorph?

i have this table


that transform into this after the pivot.

If i add a new id type, the pivot add a new column, like this


wich is the right result i want. But i want to export the new column into the database table, like an update of the table. Is there a way to do that? i’ve serched a lot, but i didn’t find anything about exporting both data and table structure as well

Thank you to all that can help me,
Niccolò

The Pivot action should do what you like… :thinking:

Regards,

Jochen

create new column.morph (3.3 KB)

Thanks, but what i search for is the action after the pivot: i wanna create this new column (generated by the pivot) in the database table, when i export data to the database.

I want to make an “IF (Column not exists) then (create new column )”

Because, if E.M. don’t find the corrispondent column, goes into error.

In this case, we usually read the information schema of the database into a new table:

SELECT
table_name, ordinal_position, column_name
FROM information_schema.columns
WHERE “table_catalog” = <your_database>
AND “table_schema” = <your_schema>
AND “table_name” = <your_table>
order by table_name, ordinal_position

Then you can do a “remove matching”-action to keep only the columns which do not exist. For those, you can do a “create column”.