Hi to all,
I have a table:
create table hoy(
id serial,
pass varchar(40),
pass_md5 varchar(40);
Now, I want to write a trigger function that
automatically updates the pass_md5 with the md5 function of the pass.
I tried this:
CREATE FUNCTION update_pass(integer) RETURNS
integer AS $$
UPDATE hoy SET pass_md5=md5(pass) WHERE id=$1; SELECT 1; $$ LANGUAGE SQL; and
CREATE TRIGGER triger_users_pass_md5
AFTER INSERT OR UPDATE ON hoy EXECUTE PROCEDURE update_pass(integer); But it works not.
When I create the trigger it says that function
does not exist.
I also tried with:
CREATE OR REPLACE FUNCTION user2(integer)RETURNS TRIGGER AS' BEGIN UPDATE users SET pass_md5=md5(pass) WHERE id=$1; return NULL; END 'language plpgsql; .... the same
Need some help!!!!
Andy.
|
- [SQL] Create trigger for auto update function Andrei Bintintan