Could the SQLite code add a new dummy function for a callback which we can then 
override with our own library?

That would provide an easy-to-use interface which would then still work in the 
shell (unless you're doing some other database functions inside the callback -- 
coider beware).



e.g.

void callback(sqlite3_context *context, int argc, sqlite3_value **argv)

{

    static int called;

    // spit out message about trigger callback called but not used -- maybe 
only spit it out once?

    // what effect would this have on the trigger?

    if (called == 0) {

        called = 1;

        sqlite3_result_text(context, "Using sqlite dummy 
callback",-1,SQLITE_STATIC);

    }

}

Would probably be nice to be able to turn off the message too with a pragma for 
completeness?





Michael D. Black

Senior Scientist

Advanced Analytics Directorate

Advanced GEOINT Solutions Operating Unit

Northrop Grumman Information Systems

________________________________
From: sqlite-users-boun...@sqlite.org [sqlite-users-boun...@sqlite.org] on 
behalf of Christian Smith [csm...@thewrongchristian.org.uk]
Sent: Friday, June 15, 2012 4:54 AM
To: General Discussion of SQLite Database
Subject: EXT :Re: [sqlite] Triggers in Sqlite using C

On Fri, Jun 15, 2012 at 11:59:33AM +0530, Bageesh.M.Bose wrote:
> Can anyone tell "How to use Triggers in Sqlite using C"
>

Triggers in SQLite can only contain SQL DML statements. But, you can
interface with C by defining functions, then calling those functions
using SQL SELECT command.

For example:

CREATE TRIGGER mytrigger AFTER INSERT ON mytable
FOR EACH ROW
BEGIN
        SELECT myfunction(NEW.field1, NEW.field2);
END;

where myfunction would be defined using:

        http://sqlite.org/c3ref/create_function.html

However, such usage would result in a database that can only be used
in your application. Using the database in the SQLite shell or some
other application might result in function not found errors if the
trigger is fired.

Hope that helps,
Christian
_______________________________________________
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