0

I'm using Heidi SQL and I keep getting this error. I want to create a trigger to update the attributes of the project table with those inserted into the histproject table AFTER INSERT. Here's the code:

DROP TRIGGER IF EXISTS setProjectAttributes;

CREATE TRIGGER setProjectAttributes
ON histproject
AFTER INSERT
AS
BEGIN
    INSERT INTO project(
            ProjectID, 
            ProjectName, 
            State, 
            Age, 
            TotalDays, 
            ProjectStatusID, 
            MRRStartDate, 
            PreConversionSetupDate, 
            InitialConversionDate, 
            ContractDate, 
            DueDate, 
            KickoffCallDate,
            TargetGoLiveDate, 
            GoLiveSignoffDate, 
            SupportTurnoverDate, 
            HardGoLive, 
            AgeSinceGoLive, 
            DataRecievedDate, 
            LegacyBillingVendor, 
            IntialAACount)
    
     SELECT
         ProjectID, 
           ProjectName, 
            State, 
            Age, 
            TotalDays, 
            ProjectStatusID, 
            MRRStartDate, 
            PreConversionSetupDate, 
            InitialConversionDate, 
            ContractDate, 
            DueDate, 
            KickoffCallDate,
            TargetGoLiveDate, 
            GoLiveSignoffDate, 
            SupportTurnoverDate, 
            HardGoLive, 
            AgeSinceGoLive, 
            DataRecievedDate, 
            LegacyBillingVendor, 
            IntialAACount
            
        FROM
            histproject;
END

All of the attributes listed are apart of both tables, and I just want to do a simple insert.

tae923
  • 1
  • You say you want to "update" attributes on your "Project" table, but the statement in your trigger is just INSERTing all records from "HistProject" into the "Project" table? The statement is obviously not doing what you think it's doing – Craig Mar 31 '21 at 02:39
  • try to quote `state` in your column list , its a reserved word – eshirvana Mar 31 '21 at 02:42
  • You need to define a different query separator, so you don't use semicolon _between_ queries, and _inside_ a (compound) query. HeidiSQL is otherwise splitting your `CREATE ...` after the `... FROM histproject;`. See the [help section](https://www.heidisql.com/help.php#queries). – Anse Mar 31 '21 at 05:05

0 Answers0