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 > Auto Sequencing using trigger

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 07-08-11, 09:06
jeevana jeevana is offline
Registered User
 
Join Date: Jul 2011
Posts: 15
Red face Auto Sequencing using trigger

Hi ,

I have only beginner level knowledge in Oracle and very new to sybase.
I would need to tranlate the below oracle code snippet to Sybase.

Can some one tell me what exactly this piece of code mean and what its equivalent in sybase.

CREATE TRIGGER voip_id
BEFORE INSERT
ON voip_phones
FOR EACH ROW
Declare phoneId number;
BEGIN
select voip_phones_id.nextval into phoneId from dual;
:new.phone_id:=phoneId;
END;

Also found that there is no sequence concept in sybase.How do i go with the sequencing as i suppose the above code if for that only.

Any immediate help on this is highly appreciated.

Thank u,
Jeevana.
Reply With Quote
  #2 (permalink)  
Old 07-08-11, 09:13
MCrowley MCrowley is offline
Wage drone 24601
 
Join Date: Jan 2003
Location: Massachusetts
Posts: 4,899
The equivalent on Sybase would be to use an identity column:
Code:
create table test1
(id int identity(1, 1) not null
 moreFieldsHere varchar(20))
Reply With Quote
  #3 (permalink)  
Old 07-08-11, 10:19
pradyut.dhara pradyut.dhara is offline
Registered User
 
Join Date: May 2011
Posts: 28
Auto Sequencing using trigger

Hi,
In addition you can use identity_gap of your choice while creating the table. This will be the gap between last number assigned and the next number assigned when server restarts.
Reply With Quote
Reply

Tags
autosequencing, 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