waiter.james
waiter.james

Reputation: 641

can I create variable in trigger of sqlite?

I want to create a update trigger,

can I create a variable betweent "BEGIN" and "END" , and set value by query from a select sql statement ?? And then execute "if" "else" statement by judging this variable

Upvotes: 6

Views: 2576

Answers (2)

vvv
vvv

Reputation: 31

you can create temporary tables with a single row instead of variables, and cross join with them in the rest of the trigger statements, using where clauses instead of if statements

Upvotes: 0

CL.
CL.

Reputation: 180270

As an embedded database, SQLite is designed to be used directly from another programming language, so it does not have programming constructs like variables or IF statements.

If it is not possible to implement your logic with the trigger's WHEN clause or subqueries, you have to do this in Java (i.e., without a trigger).

Upvotes: 4

Related Questions