ok..i have this sample code:

[code]
void printIfInsert()
{
    printf( "Insertion was done in t1\n" );
}

void createTrigger( sqlite** db, sqlite_vm** pvm )
{
    char* errMsg;
    const char** psql = NULL;
    const char* sql = "CREATE TRIGGER onInsertTrig AFTER INSERT on t2 BEGIN
printIfInsert; END";

    if( sqlite_create_function( *db, "printIfInsert", 0, &printIfInsert,
NULL ) != 0 )
    {
        printf( "hahahaha! no function was created\n" );
        exit(1);
    }

    if ( sqlite_compile(*db, sql, psql, &*pvm, &errMsg) != SQLITE_OK )
    {
        printf( "CREATE TRIGGER FAILED: %s\n", errMsg );
    }
}
[/code]

im not really sure if this is correct..i have read a documentation of
sqlite_create_function in sqlite.org but its not really that clear to
me..can you please guide me on this?..what i wanted to happen is that every
time, i insert on table t2, there should be something printed on the
console..actually, this is just for test..what i really wanted is it to log
in a log file every time a new record is inserted in the table..but my
concern is just i dont know how to call that function (printIfInsert()) in
the trigger statement..

please help me on this..

thank you and God bless!.. c",)


John Stanton-3 wrote:
> 
> I that case you need to implenment a custom function and launch it from 
> a trigger.
> 
> d_maniger06 wrote:
>> im sorry but i havent get your point..im rather new in sqlite and i just
>> need
>> to make a c program, that when i insert on a table in my database,
>> something
>> is written on a file, or even just be printed out in the console saying
>> that
>> my table in my database has been updated/inserted..
>> 
>> 
>> John Stanton-3 wrote:
>> 
>>>d_maniger06 wrote:
>>>
>>>>good day!..
>>>>
>>>>i would just like to ask if you can set a trigger to call on a
>>>>non-database
>>>>event (e.g. writing to a file) whenever an update/insert has been made
to
>>>>the database..im using c programming language for this..if this is
>>>>possible,
>>>>can u give me some links or direct examples on how to do this?..
>>>>
>>>>thank you and God bless!..
>>>
>>>If you are intercepting some event in your C program why not just make 
>>>the event execute some SQL?
>>>
>>>-----------------------------------------------------------------------------
>>>To unsubscribe, send email to [EMAIL PROTECTED]
>>>-----------------------------------------------------------------------------
>>>
>>>
>>>
>> 
>> 
> 
> 
> -----------------------------------------------------------------------------
> To unsubscribe, send email to [EMAIL PROTECTED]
> -----------------------------------------------------------------------------
> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/trigger-a-non-database-event-in-sqlite-tf4674795.html#a13377654
Sent from the SQLite mailing list archive at Nabble.com.


-----------------------------------------------------------------------------
To unsubscribe, send email to [EMAIL PROTECTED]
-----------------------------------------------------------------------------

Reply via email to