0

I made the following table:

CREATE table IF NOT EXISTS redirect (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            url_from TEXT not null,
            url_to TEXT not null,
            method TEXT not null,
            http_status_code INTEGER not null CHECK( http_status_code IN (300,301,302,304,304,308,307) ) DEFAULT 301,
            use_in_https INTEGER not null CHECK(use_in_https IN (0,1)) DEFAULT 0,
            use_in_http INTEGER not null CHECK(use_in_http IN (0,1)) DEFAULT 1,
            exact_match INTEGER not null CHECK(exact_match IN (0,1)) DEFAULT 1
        );

And I made the following trigger:


        CREATE TRIGGER remove_http_https BEFORE INSERT ON redirect BEGIN 
           SELECT CASE WHEN NEW.url_from THEN REPLACE(REPLACE(NEW.url_from,"http:\/\/",""),"https:\/\/","")   END;
        END;

But I want the trigger to run at both when I update a value OR insert a value. Is there a way to define a single trigger for both insert and update as sqlite3?

1 Answer 1

1

No, it isn't possible with a single trigger to handle both insert and update.

The CREATE trigger statement on the graph shows that only one of the DELETE, INSERT, UPDATE can be used.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.