Invalid use side-effecting operator Insert within a function

You can’t use a function to insert data into a base table. Functions return data. This is listed as the very first limitation in the documentation:

User-defined functions cannot be used to perform actions that modify the database state.

“Modify the database state” includes changing any data in the database (though a table variable is an obvious exception the OP wouldn’t have cared about 3 years ago – this table variable only lives for the duration of the function call and does not affect the underlying tables in any way).

You should be using a stored procedure, not a function.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)