If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Sybase > Writing triggers in Sybase

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-11, 10:18
jeevana jeevana is offline
Registered User
 
Join Date: Jul 2011
Posts: 15
Red face Writing triggers in Sybase

Can someone help me with the following info:

1.Is there any before insert trigger supported for Sybase.
2.How to write the trigger and sequence go hand in hand just like in oracle.
3.Any idea on translating the following piece of oracle code to Sybase.sample_phones_id is a Oracle sequence here.

CREATE TRIGGER sample_id
BEFORE INSERT
ON sample_phones
FOR EACH ROW
Declare rollNum number;
BEGIN
select sample_phones_id.nextval into rollNum from dual;
:new.rollNum:=rollNum;
END;

Regards,
Jeevana.
Reply With Quote
  #2 (permalink)  
Old 07-18-11, 02:00
ishu.cs ishu.cs is offline
Registered User
 
Join Date: Mar 2008
Posts: 59
It seems you are trying the auto increment thing here.
It can be easily achieved in Sybase by using auto identity column without writing any trigger for more info refer Transact-SQL User's Guide
Reply With Quote
Reply

Tags
trigger

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On