Need help creating SQLite trigger for keeping running totals

This is my first attempt at creating a trigger and I'm confused. Here's the basic database schema with the pertinent columns:

DATABASE_NAME

TABLE_100               
| C100_ROWID | C101_NAME | ... | C105_COUNT |

TABLE_200               
| C200_ROWID | C201_NAME | ... | C207_FOREIGNKEY (C101_NAME) |

TABLE_100 is created first, then TABLE_200's rows are populated based on user input, so TABLE_200 is empty when the application is first launched.

What I'm trying to do is create a trigger when there is an INSERT on TABLE_200, to ADD +1 to the C105_COUNT of the specific C101_NAME row that was used as the C207_FOREIGNKEY.

The purpose is to keep a running total of all the times C101_ROWID/C100_NAME is used in TABLE_200.

Here's what I got so far and it's obviously completely wrong so any help would be appreciated:

CREATE TRIGGER runningcount AFTER INSERT ON TABLE_200
BEGIN
    UPDATE TABLE_100
    SET C105_COUNT = C105_COUNT + 1
    WHERE (??? newly inserted row on TABLE_200 ???) C207_FOREIGNKEY = C101_NAME
END

Edit:

I figured it out after about 2 hours of frustration. In case anyone needs this in the future:

CREATE TRIGGER trigger AFTER INSERT ON TABLE_200
    BEGIN
    UPDATE TABLE_100
        SET C105_COUNT = C105_COUNT + 1
        WHERE C101_NAME = new.C207_FOREIGNKEY
    END

Answers


I figured it out after about 2 hours of frustration. In case anyone needs this in the future:

CREATE TRIGGER trigger AFTER INSERT ON TABLE_200
    BEGIN
    UPDATE TABLE_100
        SET C105_COUNT = C105_COUNT + 1
        WHERE C101_NAME = new.C207_FOREIGNKEY
    END

Need Your Help

MonoTouch UISplitViewController - Device and Simulator different

ipad monotouch uisplitviewcontroller ios5.1

Are there any known issues with UISplitViewController in MonoTouch? I am using MonoDevelop 2.8.8.4, MonoTouch 5.2.10 and xCode 4.3.2 (4E2002)

Some basic questions about MethodHandle API

java reflection java-7

How can I obtain all declared method through MethodHandles.lookup()? How can I obtain all declared fields?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.