dbTalk Databases Forums  

Trigger won't work

comp.databases.sybase comp.databases.sybase


Discuss Trigger won't work in the comp.databases.sybase forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
S. Stiller
 
Posts: n/a

Default Trigger won't work - 02-04-2004 , 10:38 AM






What is wrong on my trigger ?

CREATE TRIGGER tr_1
BEFORE INSERT ON Table1
REFERENCING NEW AS new_Table1
FOR EACH ROW
BEGIN
insert into Table2 (DUMMIES) values(1)
END


Reply With Quote
  #2  
Old   
Kristian Damm Jensen
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 01:43 AM






S. Stiller wrote:
Quote:
What is wrong on my trigger ?

CREATE TRIGGER tr_1
BEFORE INSERT ON Table1
REFERENCING NEW AS new_Table1
FOR EACH ROW
BEGIN
insert into Table2 (DUMMIES) values(1)
END
I wasn't aware that you could specify "before", "referencing ..." or "for each row" in sybase? But this is maybe a feature of a newer version, with which I am unfamiliar.

--
Kristian Damm Jensen damm (at) ofir (dot) dk
I've had a perfectly wonderful evening. But this wasn't it. -- Groucho
Marx


Reply With Quote
  #3  
Old   
S. Stiller
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 02:39 AM



Hi,

"Kristian Damm Jensen" <REdammMOVE (AT) ofir (DOT) dk> schrieb im Newsbeitrag
news:bvssdl$1060tm$1 (AT) ID-146708 (DOT) news.uni-berlin.de...

Quote:
I wasn't aware that you could specify "before", "referencing ..." or "for
each row" in sybase? But this >is maybe a feature of a newer version, with
which I am unfamiliar.

My Database is an
AS Enterprse 12.5
I'am not sure if "BEFORE" works but I found this
http://manuals.sybase.com/onlinebook...164;pt=39077/*

May be "for each row" won't work on an ASE 12.5 :-(

This is my complete script:

create table Table2
(
Table2_ID numeric not null,
NICKNAME varchar(100) null,
constraint PK_Table2 primary key (Table2_ID)
);

CREATE TABLE Table1
(
id numeric(10) IDENTITY PRIMARY KEY,
DUMMIES numeric
);

CREATE TRIGGER tr_Table2
BEFORE INSERT ON Table2
REFERENCING NEW AS new_Table2
FOR EACH ROW
BEGIN
insert into Table1(DUMMIES) values(1)
END;


--



Reply With Quote
  #4  
Old   
Kristian Damm Jensen
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 03:40 AM



S. Stiller wrote:
Quote:
Hi,

"Kristian Damm Jensen" <REdammMOVE (AT) ofir (DOT) dk> schrieb im Newsbeitrag
news:bvssdl$1060tm$1 (AT) ID-146708 (DOT) news.uni-berlin.de...

I wasn't aware that you could specify "before", "referencing ..." or
"for
each row" in sybase? But this >is maybe a feature of a newer version,
with which I am unfamiliar.

My Database is an
AS Enterprse 12.5
I'am not sure if "BEFORE" works but I found this
http://manuals.sybase.com/onlinebook...164;pt=39077/*

Couldn't make the link work, but it did help me to find an examle using all of the mentioned features. I am delighted. I've especially missed the before insert trigger.

Quote:
May be "for each row" won't work on an ASE 12.5 :-(
Should be fairly easy to test.

<sniP>

--
Kristian Damm Jensen damm (at) ofir (dot) dk
Yesterday is history, tomorrow is mystery and today is a gift. --
Eleanor Roosevelt


Reply With Quote
  #5  
Old   
S. Stiller
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 07:46 AM



Quote:
AS Enterprse 12.5
I'am not sure if "BEFORE" works but I found this

http://manuals.sybase.com/onlinebook...164;pt=39077/*

It seems that this only works on Sybase Anywhere :-(



Reply With Quote
  #6  
Old   
Willie Kraatz
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 08:15 AM



Your link references the ASA (Adaptive Server Anywhere) version of sybase
not the ASE version.

For ASE see the reference manual at
http://sybooks.sybase.com/as.html
"S. Stiller" <thinkman99 (AT) gmx (DOT) de> wrote

Quote:
Hi,

"Kristian Damm Jensen" <REdammMOVE (AT) ofir (DOT) dk> schrieb im Newsbeitrag
news:bvssdl$1060tm$1 (AT) ID-146708 (DOT) news.uni-berlin.de...

I wasn't aware that you could specify "before", "referencing ..." or "for
each row" in sybase? But this >is maybe a feature of a newer version, with
which I am unfamiliar.

My Database is an
AS Enterprse 12.5
I'am not sure if "BEFORE" works but I found this

http://manuals.sybase.com/onlinebook...8/@Generic__Bo
okTextView/39164;pt=39077/*
Quote:
May be "for each row" won't work on an ASE 12.5 :-(

This is my complete script:

create table Table2
(
Table2_ID numeric not null,
NICKNAME varchar(100) null,
constraint PK_Table2 primary key (Table2_ID)
);

CREATE TABLE Table1
(
id numeric(10) IDENTITY PRIMARY KEY,
DUMMIES numeric
);

CREATE TRIGGER tr_Table2
BEFORE INSERT ON Table2
REFERENCING NEW AS new_Table2
FOR EACH ROW
BEGIN
insert into Table1(DUMMIES) values(1)
END;


--




Reply With Quote
  #7  
Old   
Daniel Morgan
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 09:40 AM



Willie Kraatz wrote:

Quote:
Your link references the ASA (Adaptive Server Anywhere) version of sybase
not the ASE version.

For ASE see the reference manual at
http://sybooks.sybase.com/as.html
"S. Stiller" <thinkman99 (AT) gmx (DOT) de> wrote in message
news:40220c0f$0$16724$99d2ed3e (AT) news (DOT) highwayone.de...
Can anyone make a definitive statement as to which versions of Sybase
have BEFORE triggers and which do not?

Thanks.

--
Daniel Morgan
http://www.outreach.washington.edu/e...ad/oad_crs.asp
http://www.outreach.washington.edu/e...oa/aoa_crs.asp
damorgan@x.washington.edu
(replace 'x' with a 'u' to reply)



Reply With Quote
  #8  
Old   
Michael Peppler
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 09:54 AM



On Thu, 05 Feb 2004 07:40:31 -0800, Daniel Morgan wrote:

Quote:
Willie Kraatz wrote:

Your link references the ASA (Adaptive Server Anywhere) version of
sybase not the ASE version.

For ASE see the reference manual at
http://sybooks.sybase.com/as.html
"S. Stiller" <thinkman99 (AT) gmx (DOT) de> wrote in message
news:40220c0f$0$16724$99d2ed3e (AT) news (DOT) highwayone.de...

Can anyone make a definitive statement as to which versions of Sybase have
BEFORE triggers and which do not?
ASEnterprise does NOT have BEFORE triggers through 12.5.0.x. I haven't
checked, but I don't think they are in 12.5.1 either.

BEFORE triggers may be available in ASAnywhere - but I don't know or use
that product personally.

Michael
--
Michael Peppler Data Migrations, Inc.
mpeppler (AT) peppler (DOT) org http://www.mbay.net/~mpeppler
Sybase T-SQL/OpenClient/OpenServer/C/Perl developer available for short or
long term contract positions - http://www.mbay.net/~mpeppler/resume.html



Reply With Quote
  #9  
Old   
Pablo Sanchez
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 11:44 AM



Daniel Morgan <damorgan@x.washington.edu> wrote in
news:1075995577.782758@yasure:

Quote:
Can anyone make a definitive statement as to which versions of
Sybase have BEFORE triggers and which do not?
There are two DB products:

- ASE
- ASA

You need to re-ask your question.
--
Pablo Sanchez - Blueoak Database Engineering, Inc
http://www.blueoakdb.com


Reply With Quote
  #10  
Old   
Bret Halford
 
Posts: n/a

Default Re: Trigger won't work - 02-05-2004 , 12:41 PM



"Michael Peppler" <mpeppler (AT) peppler (DOT) org> wrote

Quote:
On Thu, 05 Feb 2004 07:40:31 -0800, Daniel Morgan wrote:

Can anyone make a definitive statement as to which versions of Sybase have
BEFORE triggers and which do not?

ASEnterprise does NOT have BEFORE triggers through 12.5.0.x. I haven't
checked, but I don't think they are in 12.5.1 either.

BEFORE triggers may be available in ASAnywhere - but I don't know or use
that product personally.

Michael
ASE 12.5.1 does not have BEFORE triggers either, and I'm not
aware of plans to put them into the next release (15.0). There
is an open feature request for it, CR 338053.

ASA does support BEFORE triggers.

I believe the original trigger can be written for ASE as

CREATE TRIGGER tr_1 on Table1 for INSERT
as
insert Table2 (DUMMIES) select 1 from inserted


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.