triggers

How to set a variable to the result of a stored procedure inside a Trigger MYSQL?

社会主义新天地 提交于 2020-08-26 04:58:25
问题 I have a little problem here, I'm making a trigger for my DB work, but I don't know how to use a stored procedure inside a trigger, I want to save the result of the procedure in a variable and then use the variable later on an IF comparator, this is my code: DELIMITER @ CREATE TRIGGER insert_players AFTER INSERT ON players FOR EACH ROW BEGIN DECLARE A varchar(50); set A = CALL consult_sex(player_name); //I WANT SOMETHING LIKE THIS IF A != FEMALE THEN INSERT INTO males (id_player, player

How do I restrict a trigger to a specific sheet/tab?

*爱你&永不变心* 提交于 2020-08-25 07:55:38
问题 I have written a script in google sheets that will change the time stamp in the selected cell anytime the entire spreadsheet is updated at all. However, I need the timestamp to only update when one single sheet(tab) is updated. Here is my current function: function onEdit() { var sheetActive = SpreadsheetApp.getActiveSpreadsheet() .getSheetByName("Board") .getRange('A28') .setValue(new Date()); } The name of the sheet(tab) that I want to check for an update in is "Input" and the specific cell

conditional insert statement in sqlite triggers

老子叫甜甜 提交于 2020-08-21 05:18:07
问题 Are conditional if/case/when statements supported in sqlite triggers? Let`s say I have the following setup: CREATE TABLE someTable (id INTEGER PRIMARY KEY, someValue INTEGER); CREATE TRIGGER update_another_table AFTER INSERT ON someTable BEGIN IF(new.someValue==0) DELETE FROM another_table WHERE (...some condition); ELSE IF NOT EXISTS(SELECT anotherValue FROM another_table WHERE anotherValue =new.someValue) INSERT INTO another_table VALUES(new.someValue, ...); ELSE UPDATE another_table SET

Run trigger at specific date and time

我是研究僧i 提交于 2020-08-11 07:30:26
问题 I want to run a trigger at specific date and time (+or - 15 min). I have a date min string with YYYY-MM-DD HH:MM format say 2017-04-01 18:05 How will I modify the below script to run at 18 hours and 5 minutes. var triggerDay = new Date(2017, 04, 01); ScriptApp.newTrigger("myFunction") .timeBased() .at(triggerDay) .create(); 回答1: You can try this: function createTimeDrivenTriggers() { // Trigger on 2017-04-01 around 18:00 (±15 min). ScriptApp.newTrigger('myFunction') .timeBased() .atDate(2017,

ORACLE updating records with 1 to many table relationship in a trigger

自古美人都是妖i 提交于 2020-08-10 13:11:28
问题 I'm stuck, I don't know what I'm doing wrong, I need some help! Given a table PERSON which maps to a person: create table person ( ID integer, registration_number varchar(9), primary_number varchar(9), women_act varchar(1) ); Given a table CONSOLIDATED_NUMBERS which specifies a mapping between multiple entries from PERSON: create table consolidated_numbers ( SECONDARY_NUMBER varchar(9), person_id integer ); Given a table TRANSACTION_HISTORY which keeps a record of all activity associated with

ORACLE updating records with 1 to many table relationship in a trigger

一笑奈何 提交于 2020-08-10 13:11:20
问题 I'm stuck, I don't know what I'm doing wrong, I need some help! Given a table PERSON which maps to a person: create table person ( ID integer, registration_number varchar(9), primary_number varchar(9), women_act varchar(1) ); Given a table CONSOLIDATED_NUMBERS which specifies a mapping between multiple entries from PERSON: create table consolidated_numbers ( SECONDARY_NUMBER varchar(9), person_id integer ); Given a table TRANSACTION_HISTORY which keeps a record of all activity associated with

Google Apps Script recursive schedule trigger

我是研究僧i 提交于 2020-08-09 09:10:55
问题 I am trying to programmatically add a trigger to a Google Apps Script - I have a function main() I want to schedule, which wraps another timebased trigger call using the ScriptApp.newTrigger().create() call like this function main(){ /* * do stuff */ doScriptCallback(); } function doScriptCallback(){ if(CONFIG.CALLBACK_SCRIPT_NAME != ''){ try { ScriptApp.newTrigger(CONFIG.CALLBACK_SCRIPT_NAME) .timeBased() .after(5000) .create() Logger.log('Scheduled ' + CONFIG.CALLBACK_SCRIPT_NAME); } catch

Google Apps Script recursive schedule trigger

假如想象 提交于 2020-08-09 09:10:16
问题 I am trying to programmatically add a trigger to a Google Apps Script - I have a function main() I want to schedule, which wraps another timebased trigger call using the ScriptApp.newTrigger().create() call like this function main(){ /* * do stuff */ doScriptCallback(); } function doScriptCallback(){ if(CONFIG.CALLBACK_SCRIPT_NAME != ''){ try { ScriptApp.newTrigger(CONFIG.CALLBACK_SCRIPT_NAME) .timeBased() .after(5000) .create() Logger.log('Scheduled ' + CONFIG.CALLBACK_SCRIPT_NAME); } catch

MySQL: update without changing data, possible?

喜欢而已 提交于 2020-08-07 01:35:03
问题 Is it possible in MySQL to update a row, without changing any data? I just need a trigger to do its work, but the data should not be changed. Of course I could do an update and then another update, but the trigger is quite slow (deletes and inserts 500 rows everytime) and I have to update thousands of rows, so I'd rather not do it twice. I could also just update a dummy field with NOW(), but I'm just curious if it's possible without 'tricks'. 回答1: How about: UPDATE table SET id=id WHERE ...

Pros and Cons of Triggers vs. Stored Procedures for Denormalization

◇◆丶佛笑我妖孽 提交于 2020-08-02 06:34:10
问题 When it comes to denormalizing data in a transactional database for performance, there are (at least) three different approaches: Push updates through stored procedures which update both the normalized transactional data and the denormalized reporting/analysis data; Implement triggers on the transactional tables that update the secondary tables; this is almost always the route taken when maintaining histories; Defer the processing to a nightly batch process, possibly doing an ETL into a data