Hi,
I have tried to find the answer…
I have cca. 350 fields to insert into table. This is the situation:
origirnal table will change and I need to write history before data changes.
Original value: “1234”
Changed value (new value is empty): “”
History value: 1234
And when I try to insert new empty value, I get error. It is logical to me why it is error - because I cannot insert it. But how to solve it?
I used this:
/**
- Insert a record on another table
*/
// SQL statement parameters
$insert_table = ‘my_table_HISTORY’; // Table name
$insert_fields = array( // Field list, add as many as needed
‘group_id’ => [group_id],
‘idStrankeObjekti’ => {idStrankeObjekti} ,
);
// Insert record
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
Now I have problems when one of fields is empty.
How to solve it? How to skip it when new value doesn’t exist?
I hope I was clear with my question.