Create trigger problem :

Started by De Leeuw Guyabout 25 years ago3 messagesgeneral
Jump to latest
#1De Leeuw Guy
G.De_Leeuw@eurofer.be

Hi all,

I try this :

CREATE FUNCTION DelArtFather(INT4)

RETURNS INT4

AS '

DELETE FROM TArticles WHERE IdArtFather = $1;

SELECT 1 AS ignore_this

'

LANGUAGE 'sql';

CREATE TRIGGER trigger_TArticles

BEFORE DELETE ON TArticles

FOR EACH ROW EXECUTE PROCEDURE DelArtFather(old.IdArt);

and i obtain this error :

ERROR: parse error at or near "old"

How can i correct my command ??

Thanks in advance

Guy De Leeuw

#2Mark G. Gilmore
mgilmore@pobox.com
In reply to: De Leeuw Guy (#1)
Re: Create trigger problem :

Instead of sending old.ldArt in as a parameter, try just referencing old
inside the function body.
So the function then has no argument.

Mark

"De Leeuw Guy" <G.De_Leeuw@eurofer.be> wrote in message
news:98imbv$2hk2$1@news.tht.net...

Show quoted text

Hi all,

I try this :

CREATE FUNCTION DelArtFather(INT4)

RETURNS INT4

AS '

DELETE FROM TArticles WHERE IdArtFather = $1;

SELECT 1 AS ignore_this

'

LANGUAGE 'sql';

CREATE TRIGGER trigger_TArticles

BEFORE DELETE ON TArticles

FOR EACH ROW EXECUTE PROCEDURE DelArtFather(old.IdArt);

and i obtain this error :

ERROR: parse error at or near "old"

How can i correct my command ??

Thanks in advance

Guy De Leeuw

#3De Leeuw Guy
G.De_Leeuw@eurofer.be
In reply to: De Leeuw Guy (#1)
Re: Create trigger problem :

I try also this solution, but i receive the error :
CURRENT : used in non-rule query
CreateTrigger: function delartfather() does not exist

CREATE FUNCTION DelArtFather()
RETURNS INT4
AS '
DELETE FROM TArticles WHERE IdArtFather = OLD.IdArt;
SELECT 1 AS ignore_this
'
LANGUAGE 'sql';

CREATE TRIGGER trigger_TArticles
BEFORE DELETE ON TArticles
FOR EACH ROW EXECUTE PROCEDURE DelArtFather();

Guy

"Mark G. Gilmore" <mgilmore@pobox.com> a �crit dans le message news:
98isoh$2irm$1@news.tht.net...

Show quoted text

Instead of sending old.ldArt in as a parameter, try just referencing old
inside the function body.
So the function then has no argument.

Mark

"De Leeuw Guy" <G.De_Leeuw@eurofer.be> wrote in message
news:98imbv$2hk2$1@news.tht.net...

Hi all,

I try this :

CREATE FUNCTION DelArtFather(INT4)

RETURNS INT4

AS '

DELETE FROM TArticles WHERE IdArtFather = $1;

SELECT 1 AS ignore_this

'

LANGUAGE 'sql';

CREATE TRIGGER trigger_TArticles

BEFORE DELETE ON TArticles

FOR EACH ROW EXECUTE PROCEDURE DelArtFather(old.IdArt);

and i obtain this error :

ERROR: parse error at or near "old"

How can i correct my command ??

Thanks in advance

Guy De Leeuw