Auto number by sequence and trigger - issue

Hi,
i need to insert auto number in one of the column of my table, and i tried like the following way..
CREATE TABLE STOP_TRACKING
  ID                    NUMBER                           primary key,
  MSISDN                NUMBER                  NOT NULL,
  TIME_STAMP            DATE                    DEFAULT SYSDATE,
  STOP_TRACKING_RESULT  NUMBER,
  REQUEST_ID            VARCHAR2(60 BYTE)
TABLESPACE SYSTEM
PCTUSED    40
PCTFREE    10
INITRANS   1
MAXTRANS   255
STORAGE    (
            INITIAL          64K
            MINEXTENTS       1
            MAXEXTENTS       2147483645
            PCTINCREASE      0
            FREELISTS        1
            FREELIST GROUPS  1
            BUFFER_POOL      DEFAULT
LOGGING
NOCACHE
NOPARALLEL;
COMMENT ON COLUMN STOP_TRACKING.STOP_TRACKING_RESULT IS 'IF RESULT ID "0" - OK AND IF RESULT ID "1" - NOT OK';
create sequence seq_autonumber;
CREATE OR REPLACE TRIGGER trg_autonumber
BEFORE INSERT ON STOP_TRACKING
FOR EACH ROW
WHEN (new.id IS NULL)
BEGIN
  SELECT seq_autonumber.NEXTVAL
  INTO   :new.id
  FROM   STOP_TRACKING;
END;
/when i execute the create trigger sql in toad sql editor am getting a pop up saying
>
variable name:NEW
Type: drop down list ...here i tried almost relevant data types, int,long,....
Value:...here i entered 1
and clicked ok...and got the error as
ORA-01036: illegal variable name/number
>
what could be issue?
Edited by: Aemunathan on Nov 22, 2009 2:55 PM

I just copy pasted your code.
Works just fine.
I believe you issue is realed to TOAD rather than pl/sql.
Would have loved to help you but i use pl/sql developer.
However if possible send a screen shot.
Cheers!!!
Bhushan

Similar Messages

  • Suppress auto sequence and trigger DDL for surrogate keys?

    Is there a way to suppress trigger and sequence creation for surrogate keys when export to DDL file?
    I know most of the time the automatic sequence and trigger creation is welcome and very handy.
    However I'm migrating from an old Designer model and there only the needed sequences are created.
    They have a different name and trigger logic is custom (and  generated outside designer).
    There is a lot of package code depending on this. So I prefer to create and use different sequences.
    Is there a way to achieve this? Any tips are welcome.Create

    Hi,
    Note that generating the DDL for Oracle 12c means that it will attempt to use your Oracle 12c Physical model.  So if you normally use Oracle 10g or 11g, you will find that any details from your Oracle 10g or 11g Physical Model will not be included.  So this approach may have other implications for you.
    If you are not using Oracle 12c, there are some relevant properties on the Auto Increment tab of the Relational Model properties dialog for the Column which may help:
    Sequence Name - allows you to specify the name of the Sequence (which can be the name of a Sequence defined in the relevant Physical Model).
    Trigger Name - allows you to specify the name of a Trigger (which can be the name of a Trigger that is defined for the Table in the Physical Model).
    Generate Trigger - unsetting this will stop the Trigger being generated.
    David

  • Creation of sequence and trigger for each table!!!!!!!1

    Hi
    I am new to trigger and Sequence field. In one of my database we have many tables with fields for specifing ID numbers. Iam planning to insert the ID field with help of a Sequence and trigger...that trigger fires by adding the sequence value from the dual table. Now the point is here we r having around *60* table with ID field. And i am planning use the above process for each table by creating sequences and trigger for each table.
    Will this affects the performance of database.
    Is there any other option other than the above process, I mean other than creating sequences and trigger for each table.
    PLzz help to resolve this issuee......
    Shiyas
    Edited by: user13170361 on Jun 7, 2010 12:37 AM

    Tiger, I didn't mind about your comment, but the point is try to use
    select NVL(max(a) + 1,1) into i from p1_temp;This line in your trigger code and see what is happening. The problem is with your trigger. You are using group by function and you will not get no_data_found !
    For more help, this is some modification of your code.
    SQL> create table p1_temp (a number(10) primary key, b number(10));
    Table created.
    SQL> create or replace trigger trg_p1_temp
      2  before insert on p1_temp for each row
      3  declare
      4  i number(10);
      5  begin
      6  begin
      7  select NVL(max(a) + 1,1) into i from p1_temp;
      8  exception
      9  when no_data_found then
    10  i := 1;
    11  end;
    12  :new.a := i;
    13  end;
    14  /
    Trigger created.
    SQL> insert into p1_temp(b) values (1);
    1 row created.
    SQL> insert into p1_temp(b) values (2);
    1 row created.
    SQL> commit;
    Commit complete.
    SQL> select * from p1_temp;
             A          B
             1          1
             2          2
    SQL> Edited by: Saubhik on Jun 7, 2010 2:30 AM

  • Oracle jdbc creating a table, sequence and trigger

    I'm trying to create a table with a sequence and with a trigger for that sequence. When I do this within Oracle Express edition I have the following SQL statements. Which DO run correctly inside Oracle Express using the same user I log in with JDBC.
    CREATE table "TEST" (
    "ID" NUMBER(10) NOT NULL,
    "NAME" VARCHAR2(20),
    constraint "TEST_PK" primary key ("ID")
    CREATE sequence "TEST_SEQ"
    CREATE trigger "BI_TEST"
    before insert on "TEST"
    for each row
    begin
    if :NEW."ID" is null then
    select "TEST_SEQ".nextval into :NEW."ID" from dual;
    end if;
    end;
    So now what I do is put each of these into a List of Strings and execute 1 by one like this:
    List<String> commands = new ArrayList<String>(4);
    commands.add("Create table ...");
    commands.add("Create sequence ...");
    commands.add("Create trigger...");
    st = con.createStatement();
    for (String command : commands) {
    st.execute(command);
    etc...
    But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"
    It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?
    TIA

    SproketBoy wrote:
    But I get an error with the trigger statement. "Error with Oracle command: ORA-00942: table or view does not exist"Keep in mind: Oracle is not lying to you.
    >
    It seems to me that Oracle has not yet seen the new table at this point. or maybe my user can create tables but not triggers? If that's the case why did it work in the express application itself?No, DDL commands cause an explicit commit. As soon as you invoke them, the change is permanent. If it was a rights problem, you'd get a different ORA error stating that, it won't silently fail.
    Lets not assume it is anything difficult, perhaps there is simply a typo in a name somewhere?

  • Sequence and trigger

    Hello,
    Ia have created a Sequence and a trigger
    The Sequence ïs:
    CREATE SEQUENCE "WABO"."WABO_VERG_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 1 CACHE 20 ORDER NOCYCLE;
    The trigger is:
    create or replace
    TRIGGER WABO.WABO_VERGUNNING_TRIC
    BEFORE INSERT ON WABO.WABO_VERGUNNING FOR EACH ROW
    WHEN (new.WABO_ID IS NULL) BEGIN
    SELECT WABO_VERG_SEQ.NEXTVAL INTO :new.WABO_ID FROM dual;
    END;
    When I insert a row in the table the sequence counter is 21 and it's stay's 21 even when I insert a new row
    When I cal the DDL it's showes me this
    CREATE SEQUENCE "WABO"."WABO_VERG_SEQ" MINVALUE 1 MAXVALUE 9999999999999999999999999999 INCREMENT BY 1 START WITH 21 CACHE 20 ORDER NOCYCLE;
    What am I doning wrong.
    Thanks

    Solved

  • Sequencing and Trigger on Oracle 9i lite database

    We created a schema (TESTSCHEMA) on Oracle 8.1.7 Enterprise edition and have a created a trigger which will use the sequence object to generate primary key for the table (TEST_TABLE)
    Sequence creation:
    CREATE SEQUENCE TESTSCHEMA.TEST_TABLE_SEQUENCE START WITH 6000 INCREMENT BY 1 MINVALUE 6000 MAXVALUE 6999 NOCACHE NOCYCLE NOORDER ;
    Trigger creation:
    CREATE OR REPLACE TRIGGER TEST_TABLE INSERT BEFORE INSERT ON TEST_TABLE FOR EACH ROW
    DECLARE
    pkValue NUMBER;
    BEGIN
    pkValue := 0;
    Select TEST_TABLE_SEQUENCE.NextVal into pkValue from dual;
    :NEW.TEST_KEY := pkValue;
    END TEST_TABLE_INSERT;
    We have created a snapshot of the schema on mobile server, synchronized the data with the client (Win32 for testing purpose).
    The trigger works fine on the server, but when I run the same query on the lite database with msql it gives me an error:
    [POL-3221] null key in primary index
    I was wondering if Sequence generation and Triggers are supported on Oracle 9i lite database ? Or am I missing out something ??
    Any information/ help is appreaciated
    Thanks
    Neeraj

    You can't use SAVEPOINT / ROLLBACK TO SAVEPOINT statements in the database trigger:
    ORA-04092: cannot SET SAVEPOINT in a trigger
    ORA-04092: cannot ROLLBACK in a trigger
    I am not sure what you need exactly, but you can try this:
    Simulating ROLLBACK TO SAVEPOINT Behavior in a Database Trigger
    http://www.quest-pipelines.com/pipelines/plsql/tips02.htm#JUNE
    Regards,
    Zlatko Sirotic

  • AUTO Increment on TABLE or TRIGGER

    I have a table that I created. I want the first column in the table to auto increment. Some of the examples I have seen create a sequence, and then do the update on a trigger?
    Is is possible to just start with 1 and increment by one when something is inserted into the table in the CREATE or ALTER Table syntax?
    Or Do I have to create a sequence, and trigger for this?

    I have already created a trigger for this table. I am doing an insert.
    IF UPDATE THEN
      INSERT INTO EQUIPMENT_USER_DATA_AUDIT (
        equipment_id,
        old_cpe_status,
        new_cpe_status,
        cpe_status_changed,
        old_ne_status,
        new_ne_status,
        ne_status_changed,
        date_modified,
        modifiers_name)
    VALUES (
        :new.equipment_id,
        :old.cpe_status,
        :new.cpe_status,
        (CASE WHEN :old.cpe_status = :new.cpe_status
               THEN 'N'
               ELSE 'Y'
         END),
        :old.ne_status,
        :new.ne_status,
        (CASE WHEN :old.ne_status = :new.ne_status
               THEN 'N'
               ELSE 'Y'
         END),
        SYSDATE,
        SYS_CONTEXT ('USERENV','CURRENT_SCHEMA'));
       END IF;Do I need to declare the first column in my insert? which is named seq_id?

  • I cannot get the new mac mini to wake from sleep and trigger the displays - this is the second mac mini I have had and both have had the same issues. It worked before on my macbook extremely well...

    I cannot get the new mac mini to wake from sleep and trigger the displays - this is the second mac mini I have had and both have had the same issues. It worked before on my macbook extremely well...
    Using 2 displays, connected via HDMI and thunderbolt
    Been on to support a number of times now - is anyone experiencing the same issues?

    BUMP.
    I actually showed this to Apple geniuses when I took my computer to the apple store, and it's still here. In console it says:
    kernel[0]: Previous Shutdown Cause: -128
    I don't know if that's related or not, but maybe helps?

  • How can I export photos from Aperture with a new sequence and ignore the embedded JPEG number? Have tried renumbering to no avail.

    How can I export photos from APERTURE with a new sequence and ignore the embedded JPEG number? Have tried renumbering to no avail.
    has anyone resolved this issue?
    This is now the second big Problem with using Apple's Appeture with NO apparent FIX...
    Aperture has NO DIRECT way to Burn to a CD/DVD & apparently NO way to RE-SEQUENCE the numbering system????
    ANYONE... I wish APPLE would address/fix these 2 problems... LIGHTROOM I guess is next?

    Hi David,
    Coming in and whining loudly is rude.  We are all volunteers here, voluntarily sharing our expertise so that users like you can make the most of their time with Aperture.  Speaking just for myself:  although I do care about your success with software (it's why I'm here), I don't care what software you use.  If you want to use Lightroom, do so, and post your questions in an appropriate forum.
    Burning files to a CD is a file operation done at the system level (it is built into OS X).  Aperture lets your create sharable image-format files from your Images.  You then use OS X's tools to burn those files to a CD.  Iirc, you can set up a "Burn Folder" in Finder, into which you can export files created from your Images, and with a single click burn your CD.
    Naming the files you create by exporting your Images can be tricky.  There are _many_ possibilities.  Some things can't be done.  Sequencing can be done in a number of ways (see Léonie's answer above).  What have you tried?  What was the result?  In what way did this differ from what you expected?
    --Kirby.

  • PO number and material issued against this PO for subcontracting

    How to know the link in between the PO number and material issued against this PO for subcontracting.
    I have checked that PO history is not getting updated.
    Thanks,

    Hi,
    We have 2 different scenarios where you can post a goods issue to Subcontract Venodrs.
    Scenarios 1: You can post the goods issue against a subcontrac vendor with out referencing the Subcon PO from ME2O, at this stage we will be knowing what is the stock at subcontract vendor but we will not be knowing the issues against which and how much Quantities are posted.
    So when we are post goods receipt, then we will come to know the consuption quantities.
    Scenario: 2, If we use the delivery concept then we can track the goods issues against the subcon POs.
    If you really keen to track the material issued to Subcon vendor against a PO so better use with delivery.
    Thansk,
    Satya.

  • How do I create and header on the left and auto number pages on the top right? I can't rearrange my document by making page 10 page 5 and so forth

    I've just completed my school report however I seem to be having difficulty with creating a header. I've managed to create the header for all pages in my document by however I also need to use APA style and insert page number on the top right hand corner of each page. I've chosen to auto number them and clicked on INSERT --AuTO PAGE NUMBERS however if I need to make changes to the page numbers, each change i make repeats on every page. Please help.
    I also can't seem to rearrange my document. It's 10 pages long and i want to make page 10 page 1. I thought I could click on that page and drag it into page 1 position like in Keynote however it's not offering me that option. when i click on page 10 in my page thumbnails, all of my pages are highlighted yellow instead of that 1 particular page. what am I doing wrong? someone please help

    You can chose to make left and right headers different in:
    Inspector > Layout > Section
    To move material the best solution is always to copy and paste the content where you want it. You can move sections however so:
    click at end of page 9 > Menu > Insert > Section Break
    You will then have a separate yellow border around the page 10 thumbnail and can drag it to the beginning.
    Peter

  • My Apple Macbook hard drive crashed and I had to replace. Now trying to reload CS5 and having issues. When I click download from Adobe download page, a screen pops up saying "Access Denied". I have serial number, but don't even get to a page to enter. Ple

    My Apple Macbook hard drive crashed and I had to replace. Now trying to reload CS5 and having issues. When I click download from Adobe download page, a screen pops up saying "Access Denied". I have serial number, but don't even get to a page to enter. Please help…Thanks!!

    Make sure you have cookies enabled and clear your cache.  If it continues to fail try using a different browser.
    You can also download the trial version of the software thru the page linked below and then use your current serial number to activate it.
    Be sure to follow the steps outlined in the Note: Very Important Instructions section on the download pages at this site and have cookies enabled in your browser or else the download will not work properly.
    CS5: http://prodesigntools.com/all-adobe-cs5-direct-download-links.html

  • Auto Date field and Auto Number field

    I am fairly new to this,
    I have crated a form using the form wizard in Acrobat Pro 9.0 and I would like to make a field an Auto date field and another an Auto Numbering field. I have read a lot of the posts and there are a lot of recommendation to point the auto number to a database. This is fine but I do not know how to reference that field to an external database. PLEASE HELP!!!! Somebody GEEK me!!

    I am fairly new to this,
    I have crated a form using the form wizard in Acrobat Pro 9.0 and I would like to make a field an Auto date field and another an Auto Numbering field. I have read a lot of the posts and there are a lot of recommendation to point the auto number to a database. This is fine but I do not know how to reference that field to an external database. PLEASE HELP!!!! Somebody GEEK me!!

  • What sequence setting would you use to edit 1280 x1080 DVCProHD (P2) and 1920 x 1080 AVCHD (Sony) in FCP. Experiencing Quality and rendering issues.

    What sequence setting would you use to edit both 1280 x1080 DVCProHD (P2) and 1920 x 1080 AVCHD (Sony) in a single timeline in FCP. I'm experiencing quality and rendering issues.  I've tried numerous settings but can't seem to figure this one out.  Thanks for your assistance.

    Although you can combine the avchd 1920x1080 material with prores 1920x1080 in the same timeline, you might land up saving time just converting everything to 1920x1080 prores 422.   You'd probably reduce the amount of rendering while you're working and exporting when you're done by a great deal.  This workflow will require much more drive space.

  • Find sequence and thread number of Oracle 10g Database

    Hallo!I am a newbie Oracle DBA studying for OCP.I am trying various methods of performing flashback of the database.
    Out of these options there is one that uses the sequence and thread numbers of the database as below
    RMAN> FLASHBACK DATABASE
    2> TO SEQUENCE=223 THREAD=1;
    How can I find out current sequence and thread numbers of the db to enable me implement such a flashback strategy?
    Thanks.

    Current sequence# is the one with status = CURRENT
    SELECT group#, thread#, sequence#, status FROM v$log;Lukasz

Maybe you are looking for