Home > Net >  EF postgre partition problem
EF postgre partition problem

Time:09-17

Use EF link postgreSQL, insert data found that need to return Id
But after setting the trigger, the main table increased two data


 CREATE OR REPLACE the FUNCTION "dbo". "measurement_insert_trigger () 
"RETURNS "pg_catalog". "trigger" AS $BODY $
DECLARE
Id is an integer;
The BEGIN
IF (NEW. "ReceivedTimestamp" & gt;=the DATE '2020-01-01' AND
NEW. "ReceivedTimestamp" & lt; THEN the DATE '2020-06-30')
INSERT INTO dbo. Orders_202001 VALUES (NEW. *);
ELSIF (NEW. "ReceivedTimestamp" & gt;=the DATE '2020-07-01' AND
NEW. "ReceivedTimestamp" & lt; THEN the DATE '2020-12-31')
INSERT INTO dbo. Orders_202002 VALUES (NEW. *);
The ELSE
RAISE the EXCEPTION 'Date out of range. Fix the measurement_insert_trigger () function. ';
END IF;
The RETURN of NEW;
END;
$BODY $
LANGUAGE PLPGSQL VOLATILE
COST 100


CREATE the TRIGGER insert_measurement_trigger
BEFORE the INSERT ON dbo. "Orders"
FOR EACH ROW EXECUTE PROCEDURE dbo. Measurement_insert_trigger ();

The above is the trigger
  •  Tags:  
  • C#
  • Related