I just realized that I need to something a bit more complicated. Basically, I
need myfunction() to take parameters. The parameters should be generated
based on the entry inserted, like something below:

create trigger triggerName before insert on tableName1
  when not myfunction(tableName1.name, tableName2.name (where tableName2.id
== tableName1.parent))
begin
  select RAISE(ROLLBACK, 'error message');
end;

Is it possible to do this in sqlite? I've been reading this document, and it
doesn't look good:
http://www.sqlite.org/lang_createtrigger.html

It seems doable in other systems:
http://www.sqlteam.com/article/an-introduction-to-triggers-part-i

Thanks!





Igor Tandetnik wrote:
> 
> Simon Chen <simonche...@gmail.com> wrote:
>> What I want is:
>>
>> - whenever I insert/update/delete a table entry, the specified c/c++
>> function is called
>> - if the function returns true, the db action can proceed; otherwise,
>> the db action should be rolled-back.
> 
> create trigger triggerName before insert on tableName
>   when not myfunction()
> begin
>   select RAISE(ROLLBACK, 'error message');
> end;
> 
> -- or
> 
> create trigger triggerName before insert on tableName
> begin
>   select RAISE(ROLLBACK, 'error message')
>   where not myfunction();
> end;
> 
> Similarly for update and delete.
> 
> Igor Tandetnik 
> 
> 
> 
> _______________________________________________
> sqlite-users mailing list
> sqlite-users@sqlite.org
> http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users
> 
> 

-- 
View this message in context: 
http://www.nabble.com/how-to-call-c-c%2B%2B-function-in-trigger-tp22815938p22831836.html
Sent from the SQLite mailing list archive at Nabble.com.

_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to