I have a task to cancel more than 90 contracts, and I would like to know if it's possible to do it in one shot, rather than running manually all of them. I have 3 statements which I need to run per each contract. These are the examples below.
When I run the first statement:
UPDATE `dbo2`.`allcontracts` SET `ctr_status`='4' WHERE `ctr_id`='4483';
I'm changing the status of contract with id = 4483. Status will be 4 for all contracts ( more than 90 of them ).
When I run the second statement:
INSERT INTO `dbo2`.`tctrchanges`
(`chg_ctr_id`, `chg_type`, `chg_date`, `chg_status`,
`chg_appr_date`, `chg_emp_id`, `chg_req`, `chg_reserved`)
VALUES
('4483', '0', '2017-06-02 11:11:11', '1',
'2017-06-02 11:11:11', '3', '31', '4483');
I need to insert contract id from the first statement into chg_ctr_id
and chg_reserved
. I will also need id of column chg_id
which is PK AI from this second statement above, to automatically assign it to third statement below in column note_text
as URL parameter. ( For example below chg_id=5334 )
INSERT INTO `dbo2`.`allnotes`
(`note_dt`, `note_user`, `note_ref_id`, `note_type`,
`note_text`,
`note_emp_id`, `note_reserved`)
VALUES
('2017-06-02 11:11:11', 'mikeb', '328515', '2',
'<b>Automatic Note:</b> <a href=\"ctrchange4.asp?chg_id=5334\">Contract was Cancelled</a> ',
'31', '4483');
As you can notice, the column note_reserved
will have the same contract id from the first statement, and column note_emp_id
will have the same static value as columnchg_req
from the second statement.
All other values can be the same for all contracts.
Any ideas?
chg_req
/note_emp_id
the same for all contracts? if not, where does the value come from?tctrchanges
, using thecontract_id
/chg_ctr_id
values you provide, and the known hard-coded values from your script, but not usingchg_id
, can you uniquely identify a row? That is to say, I assume there could be multiple rows perchg_ctr_id
(if not, things become trivial), but would there be only one row perchg_ctr_id
andchg_date
(for example)?