I`m not a SQL programmer, but I have encountered an obstacle during my project and have to construct a trigger, which will fire after insert command. The problem is as follows:
I have 3 tables:
dbo. Build
id (PK, int, not null)
date (smalldatetime, not null)
dbo.TestCase
id (PK, int, not null)
Name (nvarchar(200), not null)
dbo.TestCaseExecution
id (PK, int, not null)
build_id (FK, int, not null)
testcase_id (FK, int, not null)
passed (int, null) //1 or 0
executed (int, null) //1 or 0
duration (real, null)
fail_percentage (real, null) //null
now, I read data from .xml files and add the data to database via project written in C#. After each build I have to update the database and count fail_percentage for each test basing on 'passed' and 'executed' values.
fail_percentage = (100)*(1 - (PassNumber/ExecutionNumber))
so I need a trigger, which will: 1. fire after insert command 2. count fail_percentage basing on earlier values eg
after reading from file:
id build_id testcase_id passed executed duration fail_percentage
1 1 001 1 1 12:09 null
after trigger:
id build_id testcase_id passed executed duration fail_percentage
1 1 001 1 1 12:09 0
after reading from file:
id build_id testcase_id passed executed duration fail_percentage
1 1 001 1 1 12:09 0
2 2 001 0 1 12:32 null
after trigger:
id build_id testcase_id passed executed duration fail_percentage
1 1 001 1 1 12:09 0
2 2 001 0 1 12:32 50
could anyone give me a hand ?
Thanks in advance, Artur
ok
I did it without using triggers, inside my application I store all the needed data in a dictionary:
then I count percentage and insert it to the database.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.