> I intended to use sqlite3_bind_int() to bind the maximal number of employees 
> a department can contain to the template. The C program works without error. 
> However, the trigger does not work when I insert into the employees table.
> I used the latest sqlite-3.7.2. Is this a bug of SQLite? Or did I misused the 
> C API?

Trigger is a plain text remembered and executed at certain points of
time. If you know your maximum number of employees at the time when
you create trigger then just put it there instead of question mark. If
you wanted to change that maximum at each trigger execution then it
won't work that way. You should use some other table to contain that
number instead.


Pavel

2010/9/8 Zhixiang Zhu <zzxiang2...@hotmail.com>:
> Hi everyone,
>
> My C program has a CREATE TRIGGER statement which contains a template "?":
>
> CREATE TABLE employees (
>  employee_id INTEGER PRIMARY KEY,
>  dep_id TINYINT,
>  score FLOAT
> );
> CREATE TRIGGER on_ins_employee AFTER
> INSERT ON employees
> WHEN ? < (SELECT count(1) FROM employees WHERE dep_id == NEW.dep_id)
> BEGIN
> DELETE FROM employees
> WHERE score == (SELECT min(score) FROM employees WHERE dep_id == NEW.dep_id);
> END;
>
> I intended to use sqlite3_bind_int() to bind the maximal number of employees 
> a department can contain to the template. The C program works without error. 
> However, the trigger does not work when I insert into the employees table.
>
> I used the latest sqlite-3.7.2. Is this a bug of SQLite? Or did I misused the 
> C API?
>
> Thanks.
>
>
>
> Zhixiang Zhu
> zzxiang2...@hotmail.com
> 2010-09-08
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
>
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to