How to add Auto-Number column

I want my PK column to be an Auto-Number field? Preferably like a number(10) col that has a seed of 1 and increments by 1, no cryptic guid #.
Also, how do I insert an explicit value into the Auto-Number field?
e.g. - preserving the ID column value of 1:
insert into mytable (ID, Name)
values (1, 'Chris')
Thanks in advance
Chris

You would have to use a sequence in combination with a before insert trigger.
In that trigger you will get the next value from the sequence and insert it into the correct field.
If you need the generated number in an other insert (e.g. parent-child tables), you can use the returning clause.
Technicly it is possible to insert a explicit value (in the trigger you would check if there is a value given for that field), but it would be bad practice if it concerned an key field.
greetings
Freek D
I want my PK column to be an Auto-Number field? Preferably like a number(10) col that has a seed of 1 and increments by 1, no cryptic guid #.
Also, how do I insert an explicit value into the Auto-Number field?
e.g. - preserving the ID column value of 1:
insert into mytable (ID, Name)
values (1, 'Chris')
Thanks in advance
Chris

Similar Messages

  • How to add a new column (Project Number) in the action items table under NPD Module?

    There are two projects with same name and created by same person in NPD.
    So when it is displayed in "Action Items" table, It looks similar.
    To avoid this, I need one more column (Project Number) to be added in the "Action Items" table and " Strategic briefs and projects" table.
    So, How to add a new column (Project Number) in the "Action Items" table and " Strategic briefs and projects" table under NPD Module?
    Please do the needful.

    There is no out of the box configuration available to add columns to NPD action items.   As always we welcome enhancement requests. 
    Thanks
    Kelly

  • How to add a formula column in a report

    Hi
    I have made a report based on a query.
    There are 3 columns in the query and all the 3 are displayed.
    Now I want to add a new column (fomula column) to the report.
    I want to write a query inside the formula column. To execute the query col1, col2 and col3 values are required in the formula column.
    Could you please tell me how to add a formula column in the report and how to pass database column value to inside the formula column
    regards

    Here is how you would create a formula column:
    Open data model of the report.
    Formula column button is on the left side of the tool palette.
    Click on that button.
    Now click in the query group where you want to place the formula column.
    You would see a new field something like CF_1. That is the formula column.
    Double click on the field CF_1. It will open property inspector.
    You would see, Datatype of the formula column is Number. Change this as per your requirement.
    Double click on PL/SQL Formula property. It would open up a editor. Here you can write the code.
    And now to access the data model column here, you can use : and column name. i.e. :col1 or :col2, etc
    And remember you have to return the value back to the formula column. Like this: RETURN(some value).
    You can also take a help from here:
    http://download.oracle.com/docs/html/B13895_01/orbr_howto.htm#sthref1309
    Hope this helps.

  • How to add one date column and charecter column

    hi all,
    i have 3 column start_date(date),end_date( date),duration (varchar2)
    i am trying to add start_time and duration like this
    end_date := to_char(start_time) + duration;
    but its showing value_error
    how to add one date column and charecter column.
    Thanks

    you need something that does:
    end_date (DATE) := start_date (DATE) + <number of
    days> (NUMBER)Not necessarily, because if the duration is just a string representation of a number then it will be implicitly converted to a number and not cause an error
    e.g.
    SQL> ed
    Wrote file afiedt.buf
      1  with t as (select to_date('01/07/2007','DD/MM/YYYY') as start_dt, '3' as duration_days from dual)
      2  -- END OF TEST DATA
      3  select start_dt + duration_days
      4* from t
    SQL> /
    START_DT+
    04-JUL-07

  • How to add a new column to specific position

    Hi,
    How to add a new column to specified position in a existing table.
    I have using the oracle database 10g.
    This below code is not working in oracle 10 g
    example:
    ALTER TABLE EMPLOYEE ADD DEPT NUMBER FIRST:
    ALTER TABLE EMPLOYEE ADD DEPT NUMBER AFTER JOB:
    Please provide the correct syntax.

    Hi,
    When you add a column to the existing table, the column added i.e., for ex updatedon appers in the last. If you want the columns to be
    displayed in Specific order. Just give the column names in the SELECT.. statement.
    For your Information, But it is not good in Table design. Just to give something useful.
    If you want to add a column at a specified position,
    Rename the position column to the new column name
    For Ex: (OLD_COLUMN_NAME-Hiredate)
    ALTER TABLE EMP RENAME COLUMN OLD_COLUMN_NAME TO TEMP_HIREDATE;Add a New Column to Table
    ALTER TABLE EMP ADD LAST_DATE DATE;Then, Alter the Table to rename the new column that is added.
    ALTER TABLE EMP RENAME COLUMN LAST_DATE TO OLD_COLUMN_NAME;And, Rename TEMP_HIREDATE to your actual collumn.
    ALTER TABLE EMP RENAME COLUMN TEMP_HIREDATE TO LAST_DATE;In practise, this won't be a good approach but you can get something useful about renaming the
    column atleast.
    Thanks,
    Shankar

  • Add auto increment column to trigger

    I want to add auto increment column to after insert trigger. so how can I do that?

    this is my query.
    Create Sequence Up_Seq
    Start With 1
    Increment By 1
    nomaxvalue;
    Create Or Replace Trigger Upf_Trig
    After Insert On members
    Referencing New As New
    For Each Row
    Begin
    Insert Into Upf_Kgl(Member_Id,Mem_Name,Nic,Division)
    Values (Up_Seq.Nextval
    *,:New.Mem_Name*
    *,:New.Nic*
    *,:New.Division);*
    end upf_trig;
    It's worked. but when inserting values to members table, there is an error.
    this is the error
    Error starting at line 21 in command:
    Insert Into Members(Mem_Name,Nic,Full_Name,Age,Sex,Mar_State,Birth_Date,Division,Religon)
    Values(
    *'IA Nawagamuwa'*
    *,'883324356V'*
    *,'Isuru Aravinda Nawagamuwa'*
    *,'22'*
    *,'Male'*
    *,'Single'*
    *,'21-Dec-88'*
    *,'kgl'*
    *,'Buddhist')*
    Error report:
    SQL Error: ORA-00001: unique constraint (SYSTEM.SYS_C004077) violated
    ORA-06512: at "SYSTEM.UPF_TRIG", line 2
    ORA-04088: error during execution of trigger 'SYSTEM.UPF_TRIG'
    *00001. 00000 - "unique constraint (%s.%s) violated"*
    **Cause: An UPDATE or INSERT statement attempted to insert a duplicate key.*
    For Trusted Oracle configured in DBMS MAC mode, you may see
    this message if a duplicate entry exists at a different level.
    **Action: Either remove the unique restriction or do not insert the key.*

  • How to file auto number in save for web ?

    Hi All,
    how to file auto number in save for web ?
    I have make an action script in Photoshop cs5 that
    change the image resolution and SaveForWeb...
    (but at this point user need to supply the file name)
    so, How to write the code/action such that when the
    action button is click the image will save into the file
    file2eMail_001,file2eMail_002,file2eMail_003,file2eMail_004
    or to any unused number ?
    thank for any help!

    You could also ask over in the Photoshop Scripting Forum, I’m pretty certain stuff like progressively numbered copies has been addressed there previously.

  • How to add an unique column to an existing table?

    How to add an unique column to an existing table?
    I have a large table which has no unique constraint. and I want to add an unique column for it. How to do it?
    Does adding a sequence is a good choice? How to do it?
    Thank you

    Hi,
    alter table tablename
    add constraint contraint_name unique (columnname);but before that you need to check in the table.column there is no duplicate record exist.
    Does adding a sequence is a good choice?
    Your talking about unique constraint then yes.
    Regards,
    Taj

  • How to add the Assignment column on this post outgoing payment in f-53

    Hi all,
    how to add the Assignment column on this post outgoing payment in f-53?
    thanks.
    Joo

    Hi ,
    If you want to see the assignment column in f-53 process open item screen
    1. First in O7V3 check for t.code FBz2 which line layout ( 2 digit code is assigned)
    2. Then in t.code O7z4s check in the line layout and if assignment field is not there then insert the field.
    then check in F-53.
    Hopw it will solve your problem.
    Assign points if useful
    Regards
    Prabhat

  • How to add few more columns in UWL screen

    Hi all
    Currently by default we are able to see the columns in UWL header as "Subject", "From", "Sent Date" , "Due Date" , "Status" .
    now i want to add few more columns  apart from standard columns.
    can you please let me know how to add our own columns in UWL header ??  if it is XML changes then pls let me know which xml file exactly we need to change??
    Thanks
    Sunil

    Hi Harini
    actually Standard XML file is not necessary for changing the column names in the UWL .
    we can use otherway as follows.
    go to system admin->UWL administration->click to configure item types and custom views using a wizard then it will take you to another screen -> select the radio button "Customize the look of the UWL main page" click on next then you can select what ever task item you want to change and click on the button respective button at the right end then it will take you to new screen there i added new columns  what ever required and saved also but the same one is not reflecting in UWL....
    can you please check the same in ur machine and let me know if any other things are required to be done and why this not been done our requirement??
    Regards
    Sunil

  • How to add auto play for audio in ibooks author?

    I cannot seem to get the low-down on how to add auto play for audio in ibooks author. I would like the audio to play when the reader opens the page?
    Thanks!

    There is no option for autoplay on page turn. There is no option for autoplay, only loop.

  • TS2432 I do not know how to add a number to my contacts

    I do not know how to add a number to my contacts

    Contacts then click on the plus sign in the top right hand corner to add a contact.
    If you are trying to do it from a call you received then go to phone>Recents and click on the blue arrow on the right then scroll down to either create new contact or add to existing contact.

  • How to add a new column as "Warehouse name" in Goods Receipt PO screen?

    Hi, Experts
    I hope to add a new column or just "display" warehouse name besides Whse column in Goods Receipt PO.  How can I do?
    Thanks

    still not work.
    Maybe I did something wrong in UDF definition. Please help to check.   Thanks
    I named UDF as WhseName, and set it as Alphanumeric and lengh is 20, structure is Regular. And all below check-boxes are not ticked.
    And in Goods Receipt PO screen, I marked the UDF as Visible and Active.
    Then I ALTSHIFF2 in the UDF fields, and FMS screen displayed.
    Then I chose the 3rd one: Search in Existing User-defined value According to Saved Query
    T05
    Auto Refresh when field changes is not ticked.

  • How to add a new column in 8.1.7

    Can anyone tell me how to add a column to table in 8.1.7
    Is it same like 9i
    Regards

    Here is example;
    SQL> select * from v$version;
                             BANNER
    Oracle8i Enterprise Edition Release 8.1.7.4.0 - Production
    PL/SQL Release 8.1.7.4.0 - Production
    CORE    8.1.7.0.0       Production
    TNS for IBM/AIX RISC System/6000: Version 8.1.7.4.0 - Production
    NLSRTL Version 3.4.1.0.0 - Production
    SQL> create table t1(col1 number);
    Table created.
    SQL> alter table t1 add (col2 date);
    Table altered.
    SQL> desc t1
    Name                                      Null?    Type
    COL1                                               NUMBER
    COL2                                               DATE

  • How to add a new column in between two other columns

    I need to add a new column in between two other existing columns. Does anyone know how to do that? The ALTER statement adds the column at the end. Can someone give an example.
    Thanks
    Murali
    null

    There is no simpler way of doing this because it is not strictly necessary: you can always see your data in the order you want simply by going SELECT col1, col2, col98, col4, etc. Thus the column order only matters when you execute SELECT * FROM...
    If that really is important enough to you you'll have to drop and re-create the table, for which there are a number of different strategies.
    Your final comment suggests that you don't retain your database build scripts. If you did then rebuilding your constraints would be painless. There is a lesson there. The good news is that if you have TOAD (download from www.quest.com) you can generate DDL scripts from your existing schema.
    HTH, APC

Maybe you are looking for

  • Master Data Deletion in SAP BW

    Hi, We are having HR Master Data in BW - 0EMPLOYEE. User has deleted some of the personel numbers in the source system (SAP HR system) as the contract of the employee was ended. My problem here is that the Personnel numbers are still existing in SAP

  • Preventing SO moved from one PC to another

    I have an application that needs to store a "key" on a specific PC and it's important that the user can't simply move a Shared Object from one PC to another to "Key" the 2nd PC. Is there any way of reading PC Specific information to identify the PC i

  • Peak Detection and Display of TDMS file of 4 channels

    The Peak Detection and Display sample VI in the NI Example finder is exactly what I am looking for but I would like to use a recoded TDMS file as its input. The TDMS file is a 4 channel data file. Does someone have an example code on how to do this?

  • Procedure Function to dequeue a message and return cursor

    Hi Guys, We are looking for ways to dequeue a message from an oracle queue and pass it to the java code. Namely we would like to create a procedure/function to dequeue a message which can be called by the java code for further processing. So far we h

  • How can we access Page metadata in DataView Webpart in SharePoint Designer 2013?

    Hi,  I need to access Page metadata in my Data view web part and I am having a feeling, that the "Form" option can help me getting Page metadata, but I am not able to get much information about using this field as a parameter source on net? Can anybo