SQLiteÓï·¨ CREATE TRIGGER
ʱ¼ä:
2009-08-14 21:18:18À´Ô´:
ÍøÂç ×÷Õß:
δ
Öª µã»÷:
214
´Î
CREATE TRIGGER
sql-statement ::=
CREATE [TEMP | TEMPORARY] TRIGGER trigger-name [ BEFORE | AFTER ]
database-event ON [database-name .] table-name
CREATE TRIGGER
sql-statement
::=
CREATE
[TEMP
|
TEMPORARY
] TRIGGER
trigger-name
[ BEFORE
|
AFTER
]
database-event
ON
[database-name
.
]
table-name
trigger-action
sql-statement
::=
CREATE
[TEMP
|
TEMPORARY
] TRIGGER
trigger-name
INSTEAD OF
database-event
ON
[database-name
.
]
view-name
trigger-action
database-event
::=
DELETE
|
INSERT
|
UPDATE
|
UPDATE OF
column-list
trigger-action
::=
[ FOR EACH ROW
|
FOR EACH
STATEMENT
]
[ WHEN
expression
]
BEGIN
trigger-step
;
[
trigger-step
;
]*
END
trigger-step
::=
update-statement
|
insert-statement
|
delete-statement
|
select-statement
CREATE
TRIGGERÓï¾äÓÃÓÚÏòÊý¾Ý¿âschemaÖÐÌí¼Ó´¥·¢Æ÷¡£´¥·¢Æ÷ÊÇһЩÔÚÌض¨µÄÊý¾Ý¿âʼþ(database-event
)
·¢Éúʱ×Ô¶¯½øÐеÄÊý¾Ý¿â²Ù×÷(trigger-action
).
´¥·¢Æ÷
¿ÉÓÉÔÚÌØÊâ±íÉÏÖ´ÐеÄDELETE, INSERT, UPDATEµÈÓï¾ä´¥·¢£¬»òUPDATE±íÖÐÌض¨µÄ×Ö¶Îʱ´¥·¢¡£
ÏÖÔÚ
SQLite½öÖ§³ÖFOR EACH ROW´¥·¢Æ÷£¬²»Ö§³ÖFOR EACH STATEMENT´¥·¢¡£Òò´Ë¿ÉÒÔ²»ÓÃÃ÷ȷ˵Ã÷FOR EACH ROW
.FOR EACH ROWµÄÒâ˼ÊÇÓÉtrigger-steps
˵Ã÷µÄSQLÓï¾ä¿ÉÄÜÔÚ(ÓÉWHEN×Ó¾ä¾ö¶¨µÄ)Êý¾Ý¿â²åÈ룬¸ü¸Ä»òɾ³ý
µÄÿһÐд¥·¢trigger.
WHEN
×Ó¾ä
Ïà¹ØÎĵµ£º
ÎÒÀÏÆŹ¤×÷Òª¹ÜÀíºÃ¶àµÄexcel±í¸ñ±È½ÏµÄÂé·³£¬ÓÚÊÇÏë×Å°ïæд¸öÈí¼þÈÃËý·½±ãµã
ÆäʵÎÒwinformÈí¼þ»¹Ã»ÓÐд¹ýÄØ£¬ÒÔǰдµÄ¶¼ÊÇwebµÄ
ÒòΪдµÄÈí¼þ¾ÍÊÇËý×Ô¼ºÓÃÓÃÎÒÏëÓ¦¸Ã²»ÐèÒªÓÃʲô´óµÄÊý¾Ý¿âµÄ£¬ËùÒÔÎÒ×îÏÈÏëµ½ÓÃaccessÊý¾Ý¿âͦ·½±ãµÄÎļþ¸´ÖƾͿÉÒÔÁË
¿ÉÊÇÎÒûÓÐoffice access°¡£¬²»¹ýÎҼǵõçÄÔÉϺÃÏñÓÐaccessÊý¾Ý¿â ......
ÊÂÎñ£¨DbTransaction£©£º
SQLite ȱʡΪÿ¸ö²Ù×÷Æô¶¯Ò»¸öÊÂÎñ£¬ËùÒÔ³ÉÅú²åÈëµÄʱºò£¬Æô¶¯ÊÂÎñ£¬±È²»Æô¶¯ÊÂÎñ¿ìn±¶¡£
ÔÚûÆô¶¯ÊÂÎñ֮ǰÍùSqliteÊý¾Ý¿âÀï²åÈë1000¶àÌõÊý¾ÝµÄÇé¿ö,½á¹ûÿ´Î¶¼ÐèÒªÒ»Á½·ÖÖÓ²ÅÄÜÍê³É.
¶øÔÚÆô¶¯ÊÂÎïÒÔºóËùÐèÒªµÄʱ¼äÖ±½Ó±ä³É²»µ½2Ãë!ÔÀ´sqlite»¨Á½·ÖÖÓÊÇÓÉÓÚExecuteNonQuery·½·¨Ö´ÐÐʱ×Ô¼ºÌá½» ......
//ËѼ¯ÕûÀíÁËÒ»ÏÂÍøÉϵĴúÂë.ÕÒÁË°ëÌì¾ÓÈ»ÕÒ²»µ½Ò»Ìõ²åÈëÓï¾ä.ºÃÓôÃƵÄ
//¸Ð¾õËٶȻ¹¿ÉÒÔ.СÎļþ.ºÜ¶àСӦÓóÌÐòÔÚÓÃÕâ¸öÊý¾Ý¿â
//SQLiteʹÓð취.Ö±½ÓCOPYDLLÎļþSystem.Data.SQLite.DLLµ½Ó¦ÓóÌÐòDEBUGĿ¼Ï¡£ È»ºóÔÚÏîÄ¿ÖÐÌí¼ÓÒýÓÃ,ÕÒµ½Õâ¸öÎļþ¼´¿É
//Ìí¼ÓÒýÓÃ
using System;
using System.Collections.Generic;
......
½ñÌìÓöµ½ÁËÂé·³£º
ÓÃEclipse±àÒëpythonÏòsqliteÊý¾Ý¿â²åÈëÊý¾Ý×ÜÊÇÌáʾ±àÂëµÄÎÊÌ⣬ÎÒÉèÖÃÁËEclipseµÄworkspaceÓÃutf-8±àÂ뻹ÊDz»ÐÐ
µ«ÊÇÓÃEclipseдµÄ³ÌÐò±£´æÔÙÓÃIDLE´ò¿ªÈ´ÄܱàÒ룬Ææ¹ÖÁË
ÎÒ¿¼Âǵ½¿ÉÄÜÊÇÅäÖõÄÔÒò£¬ÕÒÕÒ±éÁËËùÓеÄÅäÖ㬶¼Ã»ÓÐÎÊÌ⣬°üÀ¨¹¤³ÌÎļþ
×îºóÎÒÓÃxvi32´ò¿ ......
ÎÒÏÖÔÚҪʹÓÃSQLite3.0´´½¨Ò»¸öÊý¾Ý¿â£¬È»ºóÔÚÊý¾Ý¿âÖд´½¨Ò»¸ö±í¸ñ¡£
Ê×ÏÈÒªÒýÈëSQLite3.0µÄlib¿â¡£È»ºó°üº¬Í·Îļþ#import <sqlite3.h>
¡¾1¡¿´ò¿ªÊý¾Ý¿â£¬Èç¹ûûÓУ¬ÄÇô´´½¨Ò»¸ö
sqlite3* database_;
-(BOOL) open{
NSArray *paths = NSSearchPathForDirectoriesInDomai ......