I have a code testing table in my database called multi_add. It has 3 columns, MA_ID, Name, List. I’m trying to create a button that will allow me to select 1 or more records on a grid, copy all of their data and make new records using that data into the same table for editing later. I’ve successfully been able to copy the records in SQL and through your SQL builder with this code:
SQL:
INSERT INTO multi_add
(Name
, List
)SELECT Name
, List
FROM multi_add
SQL Builder in Scriptcase:
INSERT INTO multi_add
(Name
, List
)
SELECT Name
, List
FROM multi_add
Unfortunately when I try to build a RUN button using scriptcase 7 and add this code to the OnFinish it does not work.
After a lot of review I found that using the OnRecord code for inserting data into a different table in the OnFinish area of the run button, seems to work for this scenario, however, I can’t seem to get the data to populate with what I need it to. It will create a new record, with a new ma_id but Name and List are either blank or whatever I type into the array. Here is the code:
$insert_table = ‘multi_add’; // Table name
$insert_fields = array( // Field list, add as many as needed
‘Name’ => ‘Name’,
‘List’ => ‘List’,
);
// Insert record
$insert_sql = ‘INSERT INTO ’ . $insert_table
. ’ (’ . implode(’, ‘, array_keys($insert_fields)) . ‘)’
. ’ VALUES (’ . implode(’, ', array_values($insert_fields)) . ‘)’;
sc_exec_sql($insert_sql);
I have tried creating global variables, adding brackets and a whole lot more with no luck. I know I’m missing something and it’s probably going to be one of those duh moments but could someone please help? I need a fresh set of eyes.
Thanks in advance!