1

私は SQL プログラマーではありませんが、プロジェクト中に障害に遭遇し、挿入コマンドの後に起動するトリガーを作成する必要があります。問題は次のとおりです。

私は3つのテーブルを持っています:

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

今、.xml ファイルからデータを読み取り、C# で記述されたプロジェクトを介してデータベースにデータを追加します。各ビルドの後、データベースを更新し、「合格」値と「実行」値に基づいて各テストの fail_percentage をカウントする必要があります。

fail_percentage = (100)*(1 - (PassNumber/ExecutionNumber))

そのため、トリガーが必要です。1.挿入コマンドの後に起動します2.以前の値に基づいてfail_percentageをカウントします。

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

誰か手を貸してくれませんか?

前もってありがとう、アルトゥール

4

1 に答える 1

0

わかった

トリガーを使用せずに実行しました。アプリケーション内で、必要なすべてのデータを辞書に保存します。

  • キー値としてのテスト名
  • 値と実行値を値として渡す

次に、パーセンテージをカウントしてデータベースに挿入します。

于 2011-08-04T11:36:54.177 に答える