Auto generate employee/applicant number

Hi All
I want to auto generate the employee and applicant number as follows:
ABCW0000001
ABCS00000001
Where first 3 characters i.e., ABC stands for the company name and fourth characters i.e., W stands for Workers and followed by the employee number.
The category of employee i.e., Staff or Worker is captured in the People Group segment in assignments.
I can write a fast formula to auto generate the employee numbers, but as employee number has to be generated first before updating the assignments.
How to auto generate the numbers before updating the assignments?
Thanks in advance for any help.
Regards
Rahman

Hi
Do you have multiple assignments over there?There are no multiple assignments.
If not, can you move the people group segment to the people screen?How can I move this to People Screen?
What should be the empl number if the people group changes anyway?If the employee gets promoted, say from worker to staff, then a new number should be generated from the date of new assignment. Also the old number should not be used in future.
Thanks for the help.
Regards
Rahman

Similar Messages

  • Auto generate employee id

    Hi All,
    I am trying to follow the 2 day developer course. I am on "Building Your Application" => "Adding an Employees Report and Form". Point 11 says "In Define the source for the primary key columns, accept the default, Existing trigger, and click Next.
    Your table, OEHR_EMPLOYEES, already has a trigger that populates the primary key."
    Unfortunately I couldnt find the trigger in the objects I have installed. Could you please tell me what trigger should I create and how to associate it with the create button.
    Regards
    Raj

    A trigger is independant from a button. It will fire on an event which is either insert or update
    or delete (the most common). If you choose Existing Trigger, then it should proceed without
    any error message.
    Denes Kubicek
    http://deneskubicek.blogspot.com/
    http://www.opal-consulting.de/training
    http://htmldb.oracle.com/pls/otn/f?p=31517:1
    -------------------------------------------------------------------

  • Excise Invoice number not display in case auto generate

    Dear Experts,
    we have use auto excise invoice generation functionality, it is working properly, but only Excise Invoice number not display after saving billing document. what to do for display the same after saving billing document.
    Regards
    BK GAIKWAD

    Thank you Lakshmipathiji,
    My question is when we have create excise invoice through J1IIN excise invoice number has been display in bottom line after saving billing document.
    But in case we have creating  auto generate Excise invoice, Excise Invoice number not display in same screen. How to do to display excise invoice after saving billing document.(Excise invoice generating in background but number not display in same screen)
    We have changeover manual to auto generate excise invoice system.
    Regards
    BK GAIKWAD

  • How to Create a Auto Generated number with some preceding text in Sharepoint 2010

    I am trying to create a auto generated number field in Sharepoint 2010 list item. My requirement is to have the following format number generated when new request is created in Sharepoint using form. Auto generated Ticket ID should be in the following format
    "IR13000" "IR13001" "IR13002"....... Please let me know how to get this done. I tried to use combination of default ID and Characters but its not working for new requests, its only reflecting for existing uploaded requests. I
    am trying this for taking up Ticket requests by filling up some fields in the form. Any quick help is much appreciated.
    Thanx

    Here are the steps:
    1 - Open your SharePoint site in SP Designer 2010.
    2 - Click Workflows and add a List workflow. Associate this workflow on the list where you want the Random Text to be generated.
    3 - Inside the workflow editor, select the Action "Update list item"
    4 -  Select 'Current Item'.
    5 - Click Add.. and select the field which needs to be updated with the Random Text. Make sure this column is not of type "Calculated" type, otherwise you won't see it in the list of the fields within the workflow.
    6 - Click "..." button in the next textbox which will open String Builder dialog box.
    7 - Type IR and then click 'Add or Change Lookup and select ID column from "Field from source". Hit OK.
    8 - It should look like IR[%Current Item:ID%]
    9 - Hit OK.
    10 - Save and publish the workflow. (Please note that currently this workflow is not set to auto run on creating new items. That's because we want to test it at this point of time).
    11 - Go to your list in SharePoint and create a new item. After creating, select the item and click Workflows and then run this workflow.
    12 - You should be able to see the text "IR1" in the designated column.
    13 - Once you see that it's working, go to SPD and set the workflow to run automatically on creation of the new item. Save and publish and then return to your list in SharePoint.
    14 - Create a new item there and you should see the Random value in the column.
    15 - You will also see the column in the New form. In order to remove it, go to List settings > content types > Item content type > and select Hidden for this column so that it doesn't showup in any form.
    Try it and let me know how it goes.
    Thanks,
    Ashish

  • Auto-Generated Number For All Users

    We're on Lync Server 2013, running a front-end pool consisting of 3 front-end servers. Users are VoIP enabled. We're seeing some inconsistent behavior while right-clicking an user and selecting the "Call" option. Even though the respective target
    users don't have an "Other" phone number set in AD, the Lync client seems to be somehow auto-generating a normalized entry and presenting this as an "Other" entry in the contextual menu that allows calls. The entry always begins with +1
    (425). Strange enough, this is the prefix used in some sample normalization rules in a Microsoft article
    here.
    Even though Dial Plans - to my understanding - shouldn't alter this (they only apply normalization rules for manually dialed numbers only), I've searched through all the normalization rules but there's none that start with +1 (425). I've also tried running
    ABSConfig, yet this tool crashes systematically on multiple machines (the Lync servers have updates dating from less than 2 months ago).
    Also - there's no normalization .txt file created in the ABFiles in the Lync Share, as in
    this article. Taking a look in the local GalContacts.db file shows the regular phone numbers, but not this one - hinting that it's something the Lync client creates on the fly. Additionally, no Lync Address Book Web Query is visible in Fiddler when browsing
    through the users' phone numbers in the Lync client.
    Adding to the problem is that some users see the "Other" entries, while others don't - eg. user X right clicks user Z and sees a wrong "Other" entry, while user Y right clicks user Z and doesn't see any wrong entry containing "Other".
    First question is what could trigger this behavior in the client ? Secondly, has ABSConfig.exe become broken by a recent update ?

    According to the 2nd article - I've created an empty Company_Phone_Number_Normalization_Rules.txt file and placed it in the Lync file share, in order to avoid any suspicion that the built-in file might be used. I've updated the address book but unfortunately
    can't restart the FE services at this time. There's no still no change in the client.
    Yet - the problem here is the numbers shown aren't present in the files making up the Lync address book inside the local user's sip profile folder.

  • Auto generate Invoice Number

    Dear All,
    I want to auto generate inovice number. I did not want to handle this from sequences because I still did not understand/handle this, so kindly suggest an other best way to generate invoce number automatically through programitcally. I have three tables, one master table and two detail tables.
    Thanks and regards,
    Hassan

    christian erlinger wrote:
    what's the trouble with using sequences?!?
    http://docs.oracle.com/cd/B28359_01/server.111/b28318/schema.htm#CNCPT611
    http://docs.oracle.com/cd/B28359_01/server.111/b28310/views002.htm#ADMIN11796
    the max+1 approach is a dangerous one, and will lead to unexplainable random occuring ora-0001...
    http://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:3379873654938
    cheersOf course nothing is wront with sequences, but he/she is generating invoice-numbers, means there should be no gaps between the numbers -> sequences not usable for this problem
    you definetely need a different approach, but have to take care! what happens if two people at the same time press commit in forms? both select e.g. 42 for the invoice-number, it will (hopefully you made unique contraints) crash with a UK-violation, so just put a select max+1 in pre-commit is not good enough.
    I think best way to realize it is to make a table with one record that contains the last invoice-number, before every commit you select the record for update, if its already locked, wait or retry later the commit and increment in the invoice-number table is done when commiting the invoice itself.
    Any flaws in this thought? Other suggestions?

  • How to auto generate SFC Number(using the Old SFC Num) when I split a SFC

    when I split a SFC (SFC Number:A001), I want to auto generate  the new SFC number, and the new SFC number pattern is A001-01 (the prefix is old SFC number). I don't know how to do.
    Please help me if you  know  it.

    Wenjun,
    SFC ID is actually a key field so I would suggest you following [Note 1363812|https://service.sap.com/sap/support/notes/1363812] "SAP ME 5.2: Key Field Character
    Restrictions" to use only legal characters in Next Number patter. If the system does not generate serialized SFCs in accordance with the patter even in this case, then it is definitely a bug.
    Per on-line help: "SFC Number Serialize - the pattern that uniquely identifies the serialized SFC number during serialization, split, or relabel"
    Sergiy

  • Applicant number creation

    Hello, I created action called 'ZO' for applicant in 'SPRO'  transaction which generates applicant number.
    After applicant creation I got IT 4000 but didn't get IT 4003, without it I can not hire an employee.
    So I am not able to find configuration to set up it.

    Hi revathi,
    i guess that,which you have created the applicant number 1.. it is internal number range right...after that some other person might be processed applicant number...(or already processed).some other person might be created 2,3,4..later once you did your applicant number that has taken 5.. nothing to worry..
    hope it gives you clear idea.
    //jcak//

  • Create Custom Applicant Number with Prefix

    Hi all,
    Can anyone help me to write a fast formula?
    I want to create custom applicant number with Agency (hiring agency) code as Prefix.
    for example if agency name is Global Recruitment Agency
    Applicant number should be: GLO0001. How can I concatenate it?

    I always prefer the fast formula to generate custom numbers
    The fast formula has one limitation that it can differentiate between system types (Employee- Applicant- Contingent) so you can create different numbering logic for each, but it can not differentiate between system user types like if you have 2 user types and both of them assigned to system type employee.
    I think you are not facing this limitation in your case, and you can use the fast formula
    Check Oracle Documentation:
    Oracle Human Resources Management Systems
    FastFormula User Guide
    Release 12.1.x
    Part No. E14567-01, 02, 03
    Writing Formulas for Person Number Generation
    page 1-141
    Or this article ID 1305948.1

  • HOW TO GET AUTO GENERATED PRIMARY ID KEY BACK FROM AN INSERT STATEMENT IN .

    Just recently I ran into a problem with what seems to be a deficiency in the Oracle Database. When trying to return an auto-generated key as is done in Microsoft's SQL database, it seems Oracle for whatever reason didn't add this capability, the key couldn't be passed back to the .Net call. After tinkering with the .Net software and talking with the Oracle techs, a decent work around to the problem (presented here) comes fairly close. Two things have to be done first before this will work. A sequence has to be created on the Oracle DB. Also a trigger has to be created against the table the keys are going to be returned from.
    The class works by passing to the function 'update_datasets_return' a DataSet with as many tables as you want. The function spins through the tables and put the keys in each row inserted. It's assumed the first row will either be the primary key or some numeric value. This can be changed by modifying the: dt.Columns(0).ColumnName
    Notice the word Inserted. On Updates and Deletes the key value is ignored because it's already present. The routine just updates the database as usual.
    So in other words you could send a table to the function with rows inserted, deleted, or updated and it will take care of them all. One routine for all.
    ' ======================================================================
    ' Created by SEF and Oracle SR: 5607364.993 This is a complete Redo
    ' of the initial concept. SEF...
    ' Sample of sequence and trigger at bottom.
    ' Uses the ODP.NET data provider.
    ' update_datasets_return: Goes thru each table in the dataset and
    ' updates, deletes, or inserts as needed.
    ' If inserting, a 'sequence counter' and a 'trigger'
    ' using the 'before insert' must be present. The sequence
    ' counter is set to auto increment by 1 starting at 1.
    ' The trigger is specific to the table.
    ' Create the trigger and sequence in the database or run the samples
    ' below in PL/SQL. Be sure the logon with a user that has enough rights.
    ' Routine assumes the first column is going to hold the sequence
    ' number. Actually any column could be used. Just change the
    ' dt.Columns(0).ColumnName to whatever you want or leave as default.
    ' The da_RowUpdated sub is where the 'sequence number' gets returned
    ' on each row that is inserted into a table. Routine is ignored on
    ' deletes and updates. SEF...
    ' =======================================================================
    Imports System
    Imports System.Data
    Imports Oracle.DataAccess.Client
    Imports Oracle.DataAccess.Types
    Public Class OracleUpdate
    Private Shared m_conn As OracleConnection
    Private Shared da As New OracleDataAdapter
    Private Shared dt As DataTable
    Private Shared conn As New OracleConnection
    Private Shared dr As DataRow
    Private Shared astep As Long
    Private Shared rwIndex As Integer = 0
    Private Shared tblIndex As Integer = 0
    Public Shared Function update_datasets_return(ByVal constr As String, ByVal ds As DataSet) As DataSet ''ByRef ds As DataSet)
    Dim selectstmt As String
    m_conn = New OracleConnection(constr)
    Try
    m_conn.Open()
    Catch ex As Exception
    Throw New ArgumentException(" Error: connection lost." & ex.Message)
    End Try
    For Each dt In ds.Tables
    ''Uncomment the code only if auto numbering
    ''is NOT turned on for the table being updated. SEF...
    ''rwIndex = 0
    ''For Each dr In dt.Rows
    '' Try
    '' Select Case dr.RowState
    '' Case DataRowState.Added
    '' astep += 1
    '' ' =======================================================
    '' ' This "Try Catch" section created only if auto numbering
    '' ' is NOT turned on for the table being updated. SEF...
    '' ' It's a crude attempt at creating a unique number.
    '' ' A more serious approach would be to use a GUID.
    '' ' Use only if you decide not to have a sequence and a
    '' ' trigger for the table.
    '' ' =======================================================
    '' Try
    '' 'ds.Tables(tblIndex).Rows(rwIndex).Item(0) = astep
    '' Catch
    '' ' ignore the error corrected integer identity so don't randomize it
    '' End Try
    '' dr.Item("createdDate") = Now
    '' dr.Item("changedDate") = Now
    '' Case DataRowState.Modified
    '' dr.Item("changedDate") = Now
    '' End Select
    '' Catch ex As Exception
    '' conn.Close()
    '' conn.Dispose()
    '' Throw New ArgumentException(" Error: update_datasets " & ex.Message)
    '' End Try
    '' rwIndex += 1
    ''Next
    selectstmt = "SELECT * From " & dt.TableName & " Where " & dt.Columns(0).ColumnName & " = " & 0
    da = New OracleDataAdapter(selectstmt, m_conn)
    Dim bldr As OracleCommandBuilder = New OracleCommandBuilder(da)
    AddHandler da.RowUpdated, New Oracle.DataAccess.Client.OracleRowUpdatedEventHandler(AddressOf da_RowUpdated)
    Dim insCmd As OracleCommand = Nothing
    Try
    insCmd = CType(bldr.GetInsertCommand(), OracleCommand)
    Catch ex As Exception
    Throw New Exception("")
    End Try
    insCmd.CommandText += " returning " + dt.Columns(0).ColumnName + " into :seqno"
    insCmd.Parameters.Add(New OracleParameter("seqno", OracleDbType.Int16, _
    4, ParameterDirection.Output, False, CType(0, System.Byte), CType(0, _
    System.Byte), dt.Columns(0).ColumnName, DataRowVersion.Current, Nothing))
    da.InsertCommand = insCmd
    Try
    ' ===========================
    da.Update(ds, dt.TableName)
    ' ===========================
    Catch ex As Exception
    Throw New ArgumentException(" Error: update_datasets_return " & ex.Message)
    End Try
    Next
    m_conn.Close()
    m_conn.Dispose()
    Return ds
    End Function
    Friend Shared Sub da_RowUpdated(ByVal sender As Object, ByVal e As OracleRowUpdatedEventArgs)
    If e.StatementType = StatementType.Insert Then
    e.Row(0) = Int64.Parse(e.Command.Parameters("seqno").Value.ToString())
    End If
    End Sub
    ' ================================================================================
    ' Notes:
    ' =================== How To -- Sample section for PL/SQL ==================================
    ' myTrigger, myTable, mySequence, and myColumn are values you need to supply.
    ' Note: A trigger needs to be created for each table.
    ' A sequence needs to be created only once and referenced each time
    ' in the trigger(s). Or you could create a new sequence each time you
    ' create a trigger. Sort of a waste of effort.
    ' Explanation:
    ' myTrigger = The name you are giving this trigger.
    ' If a trigger with same name already
    ' exist, it will be overwritten.
    ' myTable = Table you want to add the sequence numbers to.
    ' mySequence = Sequence counter you created. Whatever name you called it.
    ' myColumn = The column to update with the sequence number.
    ' =================================================================================
    ' -- Run in PL/SQL or create at DB. --
    ' create or replace trigger myTrigger
    ' before insert on myTable for each row
    ' begin
    ' select mySequence.nextval into :new.myColumn from dual ;
    ' end;
    ' -- Run in PL/SQL or create at DB. --
    ' create sequence mySequence
    ' MINVALUE 1
    ' START WITH 1
    ' INCREMENT BY 1
    ' NOCACHE; can be set to CACHE but sequence may contain gaps.
    ' Explanation of CACHE from: http://www.techonthenet.com/oracle/sequences.php
    ' With respect to a sequence, the CACHE option specifies how many sequence
    ' values will be stored in memory for faster access. The downside of creating
    ' a sequence with a CACHE is that if a system failure occurs, all cached
    ' sequence values that have not be used, will be "lost". This results in
    ' a "gap" in the assigned sequence values. When the system comes back up,
    ' Oracle will CACHE new numbers from where it left off in the sequence,
    ' ignoring the so called "lost" sequence values.
    ' Note: To recover the lost sequence values, you can always execute an
    ' ALTER SEQUENCE command to reset the counter to the correct value.
    ' NOCACHE means that none of the sequence values are stored in memory.
    ' This option may sacrifice some performance, however, you should not encounter
    ' a gap in the assigned sequence values.
    End Class
    C#:
    using System;
    using System.Data;
    using Oracle.DataAccess.Client;
    using Oracle.DataAccess.Types;
    public class OracleUpdater2
    private static OracleConnection m_conn;
    private static OracleDataAdapter da = new OracleDataAdapter();
    private static OracleConnection conn = new OracleConnection();
    public static DataTable load_it(string constr, string strqry, string tblName)
    // =====================================================================
    // constr = User Id=myUser;Password=myPass";Data Source=myDataSource
    // strqry = Select * from something?
    // tblName = The table name to fill.
    // =====================================================================
    conn = new OracleConnection(constr);
    conn.Open();
    da = new OracleDataAdapter(strqry, conn);
    OracleCommandBuilder bldr = new OracleCommandBuilder(da);
    DataTable dt = new DataTable(tblName);
    da.Fill(dt);
    conn.Dispose();
    return dt;
    public static DataSet update_datasets_return(string constr, DataSet ds)
    //'ByRef ds As DataSet)
    string selectstmt = null;
    m_conn = new OracleConnection(constr);
    try
    m_conn.Open();
    catch (Exception ex)
    throw new ArgumentException(" Error: connection lost." + ex.Message);
    foreach (DataTable dt in ds.Tables)
    selectstmt = "SELECT * From " + dt.TableName + " Where " +
    dt.Columns[0].ColumnName + " = " + 0;
    da = new OracleDataAdapter(selectstmt, m_conn);
    OracleCommandBuilder bldr = new OracleCommandBuilder(da);
    da.RowUpdated += new
    Oracle.DataAccess.Client.OracleRowUpdatedEventHandler(da_RowUpdated);
    OracleCommand insCmd = null;
    try
    insCmd = (OracleCommand)(bldr.GetInsertCommand());
    catch (Exception ex)
    throw new Exception("" + ex.Message);
    insCmd.CommandText += " returning " + dt.Columns[0].ColumnName + " into
    :seqno";
    insCmd.Parameters.Add(new OracleParameter("seqno", OracleDbType.Int16, 4,
    ParameterDirection.Output, false, System.Convert.ToByte(0),
    System.Convert.ToByte(0), dt.Columns[0].ColumnName, DataRowVersion.Current,
    null));
    da.InsertCommand = insCmd;
    try
    // ===========================
    da.Update(ds, dt.TableName);
    // ===========================
    catch (Exception ex)
    throw new ArgumentException(" Error: update_datasets_return " +
    ex.Message);
    m_conn.Close();
    m_conn.Dispose();
    return ds;
    If you need a working program of how this works, let me know.

    Oh my god, it is too long! You definitely check out types, casting and especially ODP.Net (it does everything for you)... etc. They can help you to simplify your code. I do not have enough time to copy paste it to Studio and understand and solve your issue, so I got title of your message as your main question.
    In Oracle, you can create an autonumber field by using sequences object. This is really useful when you need to create a unique number to act as a primary key.
    Basically you can create a sequence simply typing;
    CREATE SEQUENCE MY_SEQUENCE;
    now you have a sequence called "MY_SEQUENCE"... Then, I advice you select a number from sequence;
    select MY_SEQUENCE.nextval from dual;
    I said I advice actually kinda must, although it called sequence, I cannot be sequential. Do not even try to predict the value. You can be sure that it is unique number so you can use it.
    Then insert you record and use that number part of your primary key. I think that's it. Have fun.

  • How to generate new perner number using Abap Code in pa0002. what is the fu

    how to generate new perner number using Abap Code in pa0002. what is the function Module used.

    hi
    define internal number ranges for ur implementation then when u run PA 40  do not input any employee number , system will generate the employee number automatically.
    Regards
    sameer

  • Adobe 7, and opening a pdf file with a auto generated report

    We have upgraded to the latest version of a tool we use to generate reports. The older version, when you exported the report to a PDF file, it would open it in an internet broswer, IE 6/7 in this case, and just display the PDF in the browser.
    With the latest version of the reporting tool, when you export a report to a PDF file, it opens up a blank IE windows, and subsequently opens the autogenerated report in a separate Adobe Reader window, but it does not have the primary focus. It pop's under the blank IE window. This causes a lot of confusion to our employees who are not computer savvy as they are not aware the PDF actually opened since the window did not get primary focus on the screen.
    The company which writes the tool for us says there are no changes to the way it auto generates the pdf file, and insists it has nothing to do with their software.
    We decided to dig a little deeper and only found one difference between the old and the new software.
    Old - Content-Type: application/pdf
    New - Content-Type: application/pdf;charset=UTF-8
    Would that command cause our problems? It almost seems at though Adobe 7 plugin in IE7 doesn't recognize the "charset=UTF-8" and dumps the pdf to the full Adobe reader.
    If anybody has any insight, or would need some more info to help solve the problem just let me know.
    Also, we have to stay with Adobe 7, since all 7000+ computer's this affects have identical images, and upgrading to a new version costs $$$$ and has to go through massive channels.

    Welcome To  Discussions Kathy216!
    If these are files, that are already on the Hard Drive, click once on a pdf document to highlight it.
    Press the Command + I keys, to Get Info.
    Click on the ▼ Disclosure Triangle for Open with:.
    Select Adobe if listed. If it is not listed, select Other..., and navigate to Adobe, and press Add.
    In the Get Info window, click on Change All.
    If these are pdf documents, that you are viewing on the Internet, a handy utility to use is PDF Browser Plugin.
    ali b

  • Need SQL statement to generate a sequence number in the output rows

    Hi folks. I need to create an SQL statement that generates a sequence number column in the output rows (records) such that the first returned row has this column set to 1, second returned row has the column set to 2, etc.
    For example, consider the query:
    SELECT income from employees WHERE income != 20000 ORDER BY income;
    If employees.income contains 60,000, 20,000, 35,000, and 19,000 for respective rows, the output would be this:
    19,000
    35,000
    60,000
    I would like the SQL to also return a sequence number that is computed across the returned rows, resulting in two output columns:
    1 19,000
    2 35,000
    3 60,000
    Is there a simple SQL function that generates the sequence number, in order, and only for the returned rows? Or is there another way?
    I'm stumped. Any help is appreciated! Thanks!
    - Jack Cochrane

    Hi,
    Welcome to the forum!
    Use ROWNUM, like (example):
    Connected to Oracle Database 10g Express Edition Release 10.2.0.1.0
    Connected as hr
    SQL> select rownum, first_name from (select e.first_name from employees e where e.first_name like 'J%' order by e.first_name);
        ROWNUM FIRST_NAME
             1 Jack
             2 James
             3 James
             4 Janette
             5 Jason
             6 Jean
             7 Jennifer
             8 Jennifer
             9 John
            10 John
            11 John
            12 Jonathon
            13 Jose Manuel
            14 Joshua
            15 Julia
            16 Julia
    16 rows selected
    SQL> But rememeber if you want to be sure of unique numbers in certain field is better to use sequences and use seq_name.nextval each time you need.
    Regards,

  • SQL Dev Data Modeller:  Auto-generate Surrogate PKs in the Physical Model ?

    How can I have the logical modeller allow the user to design with logical PKs, but then have surrogate primary keys be auto-generated off sequences by the modeller when it comes to create the physical model - as in conventional application design?
    Without this facility, this tool is useless, IMO.
    I want:
    i). sequences to become the physical PKs by default, and that what were the logical PKs in the logical model, to become a unique key in the physical model.
    ii). I want this set by default when generating the physical model....
    iii). ....with an option to turn this off on a entity-by-entity basis (as not all tables will necessarily require such a surrogate PK; so the logical PK may remain the physical PK).

    It is common practice that physical PKs in Oracle tables are defined from sequences (surrogate PKs), and that the logical PK from the entity becomes a unique key in the table.
    This may not always be the case in every application out there, and some people may disagree, but it is nonetheless a needed feature.
    My new Feature Request is therefore:
    I would like to see the following additions to the product.
    1. In the Preferences -> Data Modeler -> Model -> Logical, a flag that by default indicates whether the designer wishes to opt to enable this feature (ie; have all logical PKs converted to unique keys, and replaced by sequence nos. in the physical model). This flags needs to be there since in real life, albeit erroneously IMO, some people will choose not to opt to use this functionality.
    2. On every entity created in the model, there needs to be a flag that allows to override this default option, as not every table will require a surrogate PK to be generated. Being able to (re)set a flag located on the entity properties (perhaps under 'Engineer To'), will accomplish this.
    3. When Forward Engineering to the physical model from the logical, the following should happen.
    ENTITY  1 ---------->TABLE 1
    ---------------------> P * Surrogate PK
    * Attribute 1 -----> U * Column 1
    * Attribute 2 -----> U * Column 2
    o Attribute 3 ----------> Column 3
    Here you can see,
    - Attributes 1 & 2 (the logical PK) of the entity become a unique key in the table (columns 1 & 2),
    - optional Attribute 3 becomes NULLable column 3,
    - and a physical surrogate PK column is added (type unbounded INTEGER, PRIMARY KEY constraint added).
    From entity DEPT as:   (Examples based on SCOTT schema)
    DEPTNO NUMBER(2) NOT NULL <-- Logical primary key on entity
    DNAME VARCHAR2(14)
    LOC VARCHAR2(13)
    CREATE TABLE DEPT
    (PK_DEPT INTEGER, -- New column becomes surrogate physical PK, driven from sequence defined later
    DEPTNO NUMBER(2) NOT NULL, -- Former logical PK becomes a UK
    DNAME VARCHAR2(14),
    LOC VARCHAR2(13))
    ALTER TABLE DEPT
    ADD CONSTRAINT PK_DEPT PRIMARY KEY (PK_DEPT) USING INDEX PCTFREE 0
    ALTER TABLE DEPT
    ADD CONSTRAINT UKLPK_DEPTNO UNIQUE (DEPTNO) USING INDEX PCTFREE 0 -- Former logical PK becomes a UK (constraint name reflects this)
    CREATE SEQUENCE PK_DEPT_SEQ
    CREATE TRIGGER PK_DEPT_SEQ_TRG
    BEFORE INSERT ON DEPT
    FOR EACH ROW
    WHEN (new.PK_DEPT IS NULL)
    BEGIN
    SELECT PK_DEPT_SEQ.NEXTVAL
    INTO :new.PK_DEPT
    FROM DUAL;
    -- Or from 11g onwards, simply,
    :new.PK_DEPT := PK_DEPT_SEQ.NEXTVAL;
    END;
    From entity EMP as:
    EMPNO NUMBER(4) NOT NULL -- Logical primary key on entity
    ENAME VARCHAR2(10)
    JOB VARCHAR2(9)
    MGR NUMBER(4)
    HIREDATE DATE
    SAL NUMBER(7,2)
    COMM NUMBER(7,2)
    DEPTNO NUMBER(2)
    CREATE TABLE EMP
    (PK_EMP INTEGER, -- New column becomes surrogate physical PK, driven from sequence defined later
    FK_DEPT INTEGER, -- New FK to surrogate PK in DEPT table (maybe NOT NULL depending on relationship with parent)
    EMPNO NUMBER(4) NOT NULL, -- Former logical PK becomes a UK
    ENAME VARCHAR2(10),
    JOB VARCHAR2(9),
    MGR NUMBER(4),
    HIREDATE DATE,
    SAL NUMBER(7,2),
    COMM NUMBER(7,2),
    DEPTNO NUMBER(2))
    ALTER TABLE EMP
    ADD CONSTRAINT PK_EMP PRIMARY KEY (PK_EMP) USING INDEX PCTFREE 0
    ALTER TABLE EMP
    ADD CONSTRAINT FK_DEPT FOREIGN KEY (FK_DEPT) REFERENCES DEPT (PK_DEPT)
    ALTER TABLE EMP
    ADD CONSTRAINT UKLPK_EMPNO UNIQUE (EMPNO) USING INDEX PCTFREE 0 -- Former logical PK becomes a UK (constraint name reflects this)
    CREATE SEQUENCE PK_EMP_SEQ
    CREATE TRIGGER PK_EMP_SEQ_TRG
    BEFORE INSERT ON EMP
    FOR EACH ROW
    WHEN (new.PK_EMP IS NULL)
    BEGIN
    SELECT PK_EMP_SEQ.NEXTVAL
    INTO :new.PK_EMP
    FROM DUAL;
    -- Or from 11g onwards, simply,
    :new.PK_EMP := PK_EMP_SEQ.NEXTVAL;
    END;
    [NOTE:   I use PCTFREE 0 to define the index attributes for the primary & unique keys since the assumption is that they will in general not get updated, thereby allowing for the denser packing of entries in the indexes and the (albeit minor) advantages that go with it.
    This is certainly always true of a sequence-driven primary key (as it is by its very nature immutable), but if the unique key is likely to be frequently updated, then this PCTFREE option could be user-configurable on a per table basis (perhaps under Table Properties -> unique Constraints).
    For non-sequence-driven primary keys, this storage option could also appear under Table Properties -> Primary Key.
    I notice no storage options exist in general for objects, so you may like to consider adding this functionality overall].
    Associated Issues :
    - Preferences, 'Naming Standard: Templates' should be updated to allow for the unique key/constraint to be called something different, thus highlighting that it comes from the logical PK. I've used 'UKLPK' in this example.
    - Mark the physical PK as being generated from a sequence; perhaps a flag under Table Properties -> Primary Key.
    - When Forward Engineering, if an entity exists without a logical PK, the forward engineering process should halt with a fatal error.
    !!! MODERATOR PLEASE DELETE ME !!!

  • Auto Generated No with Date and year

    I m using this method to create a auto generated no.
    in pre-insert trigger
    declare
              v_l varchar2(10);
         begin
              select max(doc_no) into v_l from Table ;
              if v_l is not null or v_l<>0 then
                   :table.doc_no:= v_l+1;
              else
                   :table.doc_no:=1;     
              end if;
         exception
              when no_data_found then
              :table.doc_no:=1;
         end;I want to generate auto generate no|| month||year
    please guide me

    Kame wrote:
    I want to generate auto generate no|| month||year
    please guide meYou can get an auto-generated number using SEQUENCE in Oracle.
    Do you have a specific date column in your table from which you need to get the MONTH and YEAR Data?
    To get MONTH, you can use something like:
    TO_CHAR(your_date_column, 'MONTH')To get YEAR, you can use
    TO_CHAR(your_date_column, 'YYYY')your_date_column should contain data of date datatype.
    Examples:
    SQL> CREATE SEQUENCE SEQ
      2     MINVALUE 1
      3     MAXVALUE 999999999
      4     START WITH 1
      5     INCREMENT BY 1
      6  /
    Sequence created.
    SQL> SELECT SYSDATE FROM Dual
      2  /
    SYSDATE
    10-JUN-09
    SQL> SELECT TO_CHAR(sysdate, 'MONTH') FROM Dual
      2  /
    TO_CHAR(SYSDATE,'MONTH')
    JUNE
    SQL> SELECT TO_CHAR(sysdate, 'YYYY') FROM Dual
      2  /
    TO_C
    2009
    SQL> SELECT      TO_CHAR (SEQ.NEXTVAL)
      2           || TO_CHAR (SYSDATE, 'fmMONTH')
      3           || TO_CHAR (SYSDATE, 'YYYY')
      4              auto_gen
      5    FROM   DUAL
      6  /
    AUTO_GEN
    1JUNE2009
    SQL> /
    AUTO_GEN
    2JUNE2009
    SQL> /
    AUTO_GEN
    3JUNE2009
    SQL> /
    AUTO_GEN
    4JUNE2009
    SQL>Hope this helps.
    Regards,
    Jo
    Edit: Corrected Query

Maybe you are looking for

  • How do I move my Muse file to the Creative Cloud folder without losing all the links to assets?

    I'd like to keep my .muse files in the Creative Cloud folder so they will be accessible from anywhere, and always backed up. But I have many hundreds of links to image assets etc, and am worried that if I move the Muse file to the CC folder the links

  • Mac OS 10.5.6 but have 10.4.6 (Tiger) Disk and Bootcamp 2.0

    Hi, I have a MacBook which is running 10.5.6 I think that means I have Leopard. But I am not sure. We recently got the MacBook working again and when we reinstalled Mac OS with the only disk we had which was a 10.4.6 Tiger Disk it updated it to 10.5.

  • MBP15 Retina: Cant wake from Display Sleep

    I've bought my MBP15 with Retina a week or two ago. You know how your display turns off after a minute of leaving you Mac idle? When I touch the trackpad or any key on the keyboard to log back in, the display turns back on for 1 second, then goes bla

  • Operate small business wsebsite on iWeb?

    Hi. Before I spend too much time exploring iWeb '08, I am curious if it is possible to host a website for my small business effectively, or is it better to buy a domain from godaddy and build my site in the more typical fashion? Thanks....

  • Event Handler Extension Table

    Hi, I created a Filter profile and attached it to a user. For the filter profile I created a condition to filter for a control parameter customer id. I attached the filter profile to a user. Now when I log into the EM Search screen, it shows the rows