X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 5F5CD52C9C for ; Mon, 18 Jul 2005 09:22:42 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 86614-09 for ; Mon, 18 Jul 2005 12:22:38 +0000 (GMT) Received: from ar-sd.net (unknown [82.77.155.72]) by svr1.postgresql.org (Postfix) with ESMTP id 7811152C8E for ; Mon, 18 Jul 2005 09:22:36 -0300 (ADT) Received: from localhost (localhost [127.0.0.1]) by ar-sd.net (Postfix) with ESMTP id 69E6F1737D for ; Mon, 18 Jul 2005 15:14:18 +0300 (EEST) Received: from ar-sd.net ([127.0.0.1]) by localhost (linz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 07025-07 for ; Mon, 18 Jul 2005 15:14:16 +0300 (EEST) Received: from forge (unknown [192.168.0.11]) by ar-sd.net (Postfix) with SMTP id C8451E6F2 for ; Mon, 18 Jul 2005 15:14:16 +0300 (EEST) Message-ID: <00e001c58b93$ad30b130$0b00a8c0@forge> From: "Andrei Bintintan" To: Subject: Create trigger for auto update function Date: Mon, 18 Jul 2005 15:24:41 +0300 MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00DD_01C58BAC.D134C760" X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 6.00.2900.2180 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180 X-Virus-Scanned: by amavisd-new at ar-sd.net X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.167 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, HTML_60_70, HTML_MESSAGE, UPPERCASE_25_50 X-Spam-Level: X-Archive-Number: 200507/149 X-Sequence-Number: 22127 This is a multi-part message in MIME format. ------=_NextPart_000_00DD_01C58BAC.D134C760 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Hi to all,=20 I have a table:=20 create table hoy( id serial, pass varchar(40),=20 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.=20 I tried this: CREATE FUNCTION update_pass(integer) RETURNS integer AS $$ UPDATE hoy SET pass_md5=3Dmd5(pass) WHERE id=3D$1; SELECT 1; $$ LANGUAGE SQL; and=20 CREATE TRIGGER triger_users_pass_md5=20 AFTER INSERT OR UPDATE ON hoy EXECUTE PROCEDURE update_pass(integer);=20 But it works not.=20 When I create the trigger it says that function does not exist.=20 I also tried with: CREATE OR REPLACE FUNCTION user2(integer)RETURNS TRIGGER AS' BEGIN UPDATE users SET pass_md5=3Dmd5(pass) WHERE id=3D$1; return NULL; END 'language plpgsql; .... the same Need some help!!!! Andy. ------=_NextPart_000_00DD_01C58BAC.D134C760 Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
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=20 automatically updates the pass_md5 with the md5 function of the pass.=20
 
I tried this:
 
CREATE FUNCTION update_pass(integer) = RETURNS=20 integer AS $$
    UPDATE hoy SET pass_md5=3Dmd5(pass) = WHERE=20 id=3D$1;
   SELECT 1;
$$ LANGUAGE SQL;
 
and
 
CREATE TRIGGER triger_users_pass_md5=20
 AFTER INSERT OR = UPDATE
 ON hoy
   =20 EXECUTE PROCEDURE update_pass(integer);
 
 
But it works not.
When I create the trigger it says that = function=20 does not exist.
 
I also tried with:
 

CREATE OR REPLACE FUNCTION user2(integer)RETURNS TRIGGER=20 AS'
BEGIN
    UPDATE users SET pass_md5=3Dmd5(pass) = WHERE=20 id=3D$1;
 return NULL;
END
'language plpgsql;
.... the same
 
 
Need some help!!!!
 
Andy.
------=_NextPart_000_00DD_01C58BAC.D134C760--