Re: [SQL] Create trigger for auto update function

2005-07-19 Thread Andy
Off topic :) I think we posted in the same time :)) - Original Message - From: "Richard Huxton" To: "Andrei Bintintan" <[EMAIL PROTECTED]> Cc: Sent: Tuesday, July 19, 2005 12:11 PM Subject: Re: [SQL] Create trigger for auto update function Andrei Bintint

Re: [SQL] Create trigger for auto update function

2005-07-19 Thread Richard Huxton
Andrei Bintintan wrote: 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;

Re: [SQL] Create trigger for auto update function >> SOLVED!!!

2005-07-19 Thread Andy
Took some time to figure it out. (ignore the function names --- test functions) Best regards, Andy. - Original Message - From: "daq" <[EMAIL PROTECTED]> To: "Andrei Bintintan" <[EMAIL PROTECTED]> Cc: Sent: Monday, July 18, 2005 4:32 PM Subject: Re: [SQ

Re: [SQL] Create trigger for auto update function

2005-07-19 Thread daq
Hello Andy, Tuesday, July 19, 2005, 9:55:41 AM, you wrote: >> CREATE FUNCTION update_pass() RETURNS integer AS $$ >> UPDATE hoy SET pass_md5=md5(pass) WHERE id=new.id; >>SELECT 1; >> $$ LANGUAGE SQL; >> >> CREATE TRIGGER triger_users_pass_md5 >> AFTER INSERT OR UPDATE >> ON hoy FOR EACH

Re: [SQL] Create trigger for auto update function

2005-07-19 Thread Andy
know how to apply it. I also receive the error that NEW must be definde as a rule. Still... not working... - Original Message - From: "daq" <[EMAIL PROTECTED]> To: "Andrei Bintintan" <[EMAIL PROTECTED]> Cc: Sent: Monday, July 18, 2005 4:32 PM Subje

Re: [SQL] Create trigger for auto update function

2005-07-18 Thread daq
Hello Andrei, Monday, July 18, 2005, 2:24:41 PM, you wrote: AB> Hi to all, AB> I have a table: AB> create table hoy( AB> id serial, AB> pass varchar(40), AB> pass_md5 varchar(40); AB> Now, I want to write a trigger function that automatically updates the pass_md5 with the md5 function of th

Re: [SQL] Create trigger for auto update function

2005-07-18 Thread PFC
CREATE TRIGGER triger_users_pass_md5 AFTER INSERT OR UPDATE ON hoy EXECUTE PROCEDURE update_pass(integer); Try : FOR EACH ROW EXECUTE ---(end of broadcast)--- TIP 1: if posting/reading through Usenet, please send an appropriate

[SQL] Create trigger for auto update function

2005-07-18 Thread Andrei Bintintan
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