Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2011
    Posts
    15

    Red face Unanswered: 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.

  2. #2
    Join Date
    Jan 2003
    Location
    Massachusetts
    Posts
    5,799
    Provided Answers: 11
    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))

  3. #3
    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.

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •