Home>
I'm currently studying postgreSQL triggers ...! Has an error and the cause and response are unknown, so please let me know.
What i didI made the following stored procedure. After creating new user data, y is automatically added to test_flg.
Stored procedure creationCREATE OR REPLACE FUNCTION update_user () RETURNS TRIGGER AS $$
BEGIN
UPDATE User SET test_flg ='Y' WHERE test_flg ='N' and No like'No-M%';
END;
$$LANGUAGE plpgsql;
Registered as a trigger function
CREATE TRIGGER check_update
AFTER INSERT ON User
FOR EACH ROW
EXECUTE PROCEDURE update_user ();
The error that is occurring
DBExecuteError: ERROR: control reached end of trigger procedure without RETURN --Where: PL/pgSQL function
I don't need the return value this time, but I get a RETURN error.
What should I do here ...
-
Answer # 1
-
Answer # 2
For triggers in the first placeFunction(RETURNS TRIGGER is required), so be surereturnIs required.
* Return is not necessary for Function (returns void) that has no return value regardless of the trigger.The return value is not particularly necessary this time
return Null;
Please add.
Related articles
- is it possible to use the trigger function of postgresql to say "do not update when the data of a certain column of a certa
- postgresql - no method error with tagged function
- i want to resolve the error that occurred in cocnvim
- python - an error occurred in the code of "from smbus2 import smbus" on raspberry pi 4 (smbus2 installed)
- i want to add a comment function to a post with django, but i get an error
- php fatal error: call to a member function fetchrow () does not show site
- c ++ - error in loaddivgraph function
- php header function error
- error when implementing search function using ransack in ruby on rails
- an error occurs when installing the postgresql12 develop file on aws (ec2)
- postgresql - "psql: not found" error with docker-compose up
- python - about the error that occurred when creating the table
- [postgresql] a mysterious error could not connect to server when typing psql in terminal
- java - an error occurred while casting the reference type
- javascript - map is not a function error
- postgresql - an error occurs when scaffolding on aspnet core using ssl communication
- python - error occurred on raspberry pi 4 (type error)
- python - i want you to resolve the error that occurred when using wget on jupyter notebook
- postgresql - an error occurs when storing 2*10 9 or more int type data in the db defined by sequelize if it is less than this nu
Trends
- python - you may need to restart the kernel to use updated packages error
- dart - flutter: the instance member'stars' can't be accessed in an initializer error
- php - coincheck api authentication doesn't work
- php - i would like to introduce the coincheck api so that i can make payments with bitcoin on my ec site
- [php] i want to get account information using coincheck api
- the emulator process for avd pixel_2_api_29 was killed occurred when the android studio emulator was started, so i would like to
- javascript - how to check if an element exists in puppeteer
- sh - 'apt-get' is not recognized as an internal or external command, operable program or batch file
- i want to check the type of a shell script variable
- i want to call a child component method from a parent in vuejs
Does FUNCTION require RETURN?
So
It should be FUNCTION, but it is called by PROCEDURE.
If test_flg ='N' and No like'No-M%', why not just set the BEFORE INSERT trigger to code that just sets test_flg to'Y'?