Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create a trigger? #1146

Closed
AlexanderOliverAustin opened this issue Aug 7, 2024 · 1 comment
Closed

How to create a trigger? #1146

AlexanderOliverAustin opened this issue Aug 7, 2024 · 1 comment

Comments

@AlexanderOliverAustin
Copy link

The language of WCDB

Swift

The version of WCDB

v2.1.6

The platform of WCDB

iOS

The installation of WCDB

Carthage

What's the issue?

I want to create a trigger for Table A so that when a set of data is inserted into Table A, it simultaneously triggers an operation to insert the current data into Table B. I have already read the WCDB project (StatementCreateTrigger) and related wikis, but I have no idea how to use WCDB’s API to handle NEW.ColumnName in the trigger. How can I express NEW.ColumnName using WCDB's API? Here is the SQL statement:

 CREATE TRIGGER IF NOT EXISTS  ATrigger
    AFTER INSERT ON ATable
    FOR EACH ROW
    BEGIN
    INSERT INTO BTable(id,title,content) VALUES(NEW.id,NEW.title,NEW.content);
    END;
@Qiuwen-chen
Copy link
Collaborator

Column(named: "NEW.id")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants