Autoincrement Sequence with String and number

Hi,
I have a db for a small company where there are different kinds of employees.
As a primary key of each table (for each type of employee), I would like to have a combination of a string and integer.
e.g. if the employee is a car mechanic then the primary key should be something like: CM001, CM002, ....
if the employee is from the it department then the primary key should be like: IT001, IT002, ....
I have found a few script for sequences and triggers to use the auto-increment, but I could not find anything about concatenating a string in front of the integer.
any help appreciated.
thanks

user5205421 wrote:
As a primary key of each table (for each type of employee), I would like to have a combination of a string and integer.You really don't want to have a combined column in your tables, and certainly not as a primary key.
If you use a combined column you'll find your are uncombining the column all over your application using substr's, index usage will not be trivial anymore, people can't change from departments anymore since primary keys can never change. You are just asking for trouble. When your customer says that that's the number/code they want to see and with which they identify themselves, that doesn't mean you need to implement it as a primary key.
My advice:
- create an ID column with a primary key constraint and fill it using a sequence.
- have a department code column, optionally a foreign key to a table with departments
- use: department_code || to_char(id,'fm000') or department_code || row_number() over (partition by department_code order by id), only for display reasons in your applications, possibly in a view.
Regards,
Rob.

Similar Messages

  • Can we use sequences with strings?

    In Sql can we use sequence with strings? ......please tel me

    Hi,
    Sorry, sequences only generate numbers.
    You could write a function in PL/SQL which generates a string, based on the value it gets from a sequence.
    Edited by: Frank Kulash on Jan 22, 2009 2:31 PM
    Of course, you can convert the number to a string, like Salim demonstrated. I assume you're talking about something that generates, for example, 'A', 'B', ..., 'Z', 'AA', 'BB', ..., 'ZZ', 'AAA', ...

  • Creating value expression​s dynamicall​y with strings and numbers?

    Hello everybody!
    I'm having a problem regarding passing arguments (DLL-Adapter) from different locations to a function in TestStand 3.5.
    Here is what I have:
    FileGlobals.Data.MyArray
    and
    StationGlobals.Data.MyArray
    Which means there are 2 arrays of the same type, one stored in the sequence and one globally. "Data" is just a container.
    The type of MyArray is a custom one each element containing a string and a number: Array[n].Name and Array[n].Nr
    Now I want to pass (string) arguments of the array to a function using a value expression of: FileGlobals.Data.MyArray[Step.index].Name
    Whereas Step.index is a local property (number) of a custom step. It's working well!
    Here is the actual problem:
    Since I have to sources, FileGlobals OR StationGlobals, I want to specify dynamically which string to pass.
    Therefore I introduced a property Step.ThisIsMyScope . It's a string containing either "FileGlobals" or "StationGlobals".
    I have been experimenting in expressions like
    Step.ThisIsMyScope + ".Data.MyArray[" + Step.index + "].Name"
    or Evaluate(...) , etc.
    Nothing worked.
    I do not want to use the API, though I managed to do things with getValString and temporary saving the Value in the step, but that's not nice nor transparent enough.
    May anyone help me?
    Thank you very much,
    Stefan

    Hi,
    have you tried Evaluate(Step.ThisIsMyScope + ".Data.MyArray[" + Step.index + "].Name")
    or
    (Step.ThisIsMyScope == "FileGlobals"  )  ?  (FileGlobals.Data.MyArray[ Step.index].Name)  :  (StationsGlobals.Data.MyArray[ Step.index].Name)
    Regards
    Ray Farmer
    Message Edited by Ray Farmer on 04-05-2007 10:09 AM
    Regards
    Ray Farmer

  • Working with strings and cell references

    Hi all,
    I'm a fairly new user to the Mac world but I'm a power user of Excel trying to moving into the number environment. I'm currently experiencing some very inconsistent behaviour working with text strings in Numbers.
    I've used both '&' and CONCATENATE to try to concatenate strings and cell references and regualarly I'm getting the situation where the formula initially works and then when I save and reopen the file the cells containing the error return a syntax error.
    Upon examining the formula it appears that the cell references are converted from cell references to simple text so & (b2) & becomes &b2&.
    Any ideas what is causing this?

    I apoligise for this tardy response. Firstly, the issue occurred not when I first create the formula but when I save, close and reopen the document.
    Upon examining the formula, the cell reference is not being recognised and so instead of A2 referencing a cell it's simple A2 which causes an error.
    And this is happening in more than one cell (whole rows of cells actually as I've often created a formula and copied it down 10 or 200 rows).
    It is also happening on more than one file Badunit so I don't think it's a corrupt file.
    It's more than a little annoying though as it means every few days when I go back in to a file I need to spend a few minutes recreating the formulas.
    Any other suggestions?
    Oh and I've tried both methods of formula creation of typing the reference and clicking, but the result is the same.
    Message was edited by: Un-decided

  • Adding caller with name and number from call list to the contact list only inserts the number and not the name

    I recently bought a BlackBerry Z10 and moved my cell service to Rogers to take advantage of the name display service offered by Rogers (Fido also offers this service).
    Due to the number of calls that I receive from first time clients, I wanted the name display service to help me know who was calling. Evidently it is impossible to add clients to my contact list before they call me so I'm constantly seeing numbers that have no name to help me decide if I want to answer the call.
    When I try to add a caller from my call list to my contact list, only the number gets inserted in the new contact. The name needs to be entered manually.
    I understand and realize that not all call display formats are the same and that it's virtually impossible to parse the first and last names from the name portion of the caller id.
    However, I would like to see BlackBerry add the functionality to insert the name portion of the call entry from the caller list to a "Nickname" entry in the contact list just like it adds the number to a "Home", "Mobile", or "Work" entry in the contact list.
    If a user doesn't have a name display service, there would be no change to how their contacts are added because there is no name variable to copy over.
    Can someone from BlackBerry please let me know if this feature can be added to BB10 and when it can be added? For me it's an obvious feature that should just work.
    I am really enjoying my Z10 but I'm feeling let down that something so logical and helpful is not supported out of the box.
    Regards,
    Marc

    Hey ViciousFerret,
    It appears that you are not aware of the fact that both Rogers and Fido offer name AND number display service (although the name display feature is an add-on service) and have been offering it for many years (since 2006). Here is a link to the name display service description of each provider...
    http://www.fido.ca/web/content/manageyourcalls/calldisplay&lang=en
    http://www.rogers.com/business/on/en/smallbusiness/products/wireless/addons/valuepacks/
    As you can see from the link below, Rogers and Fido have been offering this service since 2006.
    http://www.businesswire.com/news/home/20060914005951/en/Teams-HP-Rogers-Wireless-Fido-Succeed-North
    My BlackBerry Z10 shows both the name and number when someone calls (and the caller is not in my contact list).
    All I would like is for the Z10 (and Q10) to support the addition of the name and number from the caller list to my contact list without me having to type the name. As I mentioned in my original post, to avoid the OS having to parse the first name and last name from the name portion of the caller list entry the name could simply be added to the contact list as a "Nickname". If your provider only has number display, nothing would have to be copied from the name variable in the caller list to the contact list.
    I find it difficult to believe that BlackBerry would not be aware of this name display service since it's been around since 2006 with both Rogers and Fido.
    I hope I have clarified the reasons why I would like to have this feature added to BB10 and how it's surprising that this simple feature is not already a part of the BB10 OS.
    Either way, I don't think this is a difficult feature for the BlackBerry team to add. They're just copying a 2nd variable from the caller list to the contact list.
    I'm surprised that Rogers hasn't asked BlackBerry to add this feature to their phones. I think it would be a popular feature for those who receive a high number of calls from first time callers.
    How can I get this feature request to BlackBerry for their consideration?
    Cheers,
    Marc

  • How to read a C structure with string and int with a java server using sock

    I ve made a C agent returning some information and I want to get them with my java server. I ve settled communication with connected socket but I m only able to read strings.
    I want to know how can I read strings and int with the same stream because they are sent at the same time:
    C pgm sent structure :
    char* chaine1;
    char* chaine2;
    int nb1;
    int nb2;
    I want to read this with my java stream I know readline methode to get the first two string but after two readline how should I do to get the two int values ?
    Any idea would be a good help...
    thanks.
    Nicolas (France)

    Does the server sent the ints in little endian or big endian format?
    The class java.io.DataInputStream (with the method readInt()) can be used to read ints as binary from the stream - see if you can use it.

  • How to export image sequence with a specific number

    Hello
    I'm looking how, like in after, I can export an image sequence with a starting specific number. I spend hours to rename images with Renamer, boring, stupid!
    Thank you for helping
    Alex

    Use Bridge.  You can do them all at once with Batch Rename.

  • Help with String/ and or Array loading and comparing

    Hi all,
    I'm having some problems with trying to find the best way to achieve the following on a Poker Dealing program. I randomly shuffle a 52 card deck of playing cards and deal out 5 cards. Cool...
    Now I have to go back thru the String and determine if my hand of cards contains
    a pair
    2 pair
    3 of a kind
    Full House
    etc etc
    I am trying to do String comparisons (there is an empty compareCards method in my code right now, but I'm getting a bit frustrated as to find the best way to do it... Would an array load in a separate method be a better way???? What I need to do is after I load my hand , is to display a message stating a pair, 3 of a kind , etc etc.....
    Thanks in advance
    Mike
    Here is my code (please don't laugh too hard - I'm an old COBOL/Oracle guy):
    // Card shuffling and dealing program
    // Java core packages
    import java.awt.*;
    import java.awt.event.*;
    // Java extension packages
    import javax.swing.*;
    public class DeckOfCards extends JFrame {
    private Card deck[];
    private Card hand[];
    private int currentCard;
    private JButton dealButton, shuffleButton;
    private JTextArea outputArea ;
    private JTextField displayField;
    private JLabel statusLabel;
    // set up deck of cards and GUI
    public DeckOfCards()
    super( "Poker Game" );
    String faces[] = { "A", "2", "3", "4", "5", "6", "7", "8", "9", "10", "J", "Q", "K" };
    String suits[] = { "Hearts", "Diamonds", "Clubs", "Spades" };
    String display = "" ;
    deck = new Card[ 52 ];
    currentCard = -1;
    // populate deck with Card objects
    for ( int count = 0; count < deck.length; count++ )
    deck[ count ] = new Card( faces[ count % 13 ],
    suits[ count / 13 ] );
    // set up GUI and event handling
    Container container = getContentPane();
    container.setLayout( new FlowLayout() );
    // shuffle button
    shuffleButton = new JButton( "Shuffle cards" );
    shuffleButton.addActionListener(
    // anonymous inner class
    new ActionListener() {
    // shuffle deck
    public void actionPerformed( ActionEvent actionEvent )
    displayField.setText( "" );
    shuffle();
    displayField.setText( "The Deck is Shuffled" );
    statusLabel.setText( "" );
    } // end anonymous inner class
    ); // end call to addActionListener
    container.add( shuffleButton );
    // Deal button
    dealButton = new JButton( "Deal Hand" );
    dealButton.addActionListener (
    // anonymous inner class
    new ActionListener() {
    // deal 5 cards
    public void actionPerformed( ActionEvent actionEvent )
    outputArea.setText( "" ) ;
    displayField.setText( "" );
    for ( int cctr = 1 ; cctr <= 5; cctr++ ){     
    Card dealt = dealCard();
    if ( dealt != null ) {
    outputArea.append( dealt.toString()+"\n" );
    else {
    displayField.setText( "No more cards left" );
    statusLabel.setText( "Shuffle cards to continue" );}
    } // end for structure
    compareCards() ;
    } // end action
    } // end anonymous inner class
    ); // end call to addActionListener
    container.add( dealButton );
    outputArea = new JTextArea (10, 20) ;
    outputArea.setEditable( false ) ;
    container.add( outputArea ) ;
    displayField = new JTextField( 20 );
    displayField.setEditable( false );
    container.add( displayField );
    statusLabel = new JLabel();
    container.add( statusLabel );
    setSize( 275, 275 ); // set window size
    show(); // show window
    // shuffle deck of cards with one-pass algorithm
    public void shuffle()
    currentCard = -1;
    // for each card, pick another random card and swap them
    for ( int first = 0; first < deck.length; first++ ) {
    int second = ( int ) ( Math.random() * 52 );
    Card temp = deck[ first ];
    deck[ first ] = deck[ second ];
    deck[ second ] = temp;
    dealButton.setEnabled( true );
    public void compareCards()
    public Card dealCard()
    if ( ++currentCard < deck.length )
    return deck[ currentCard ];
    else {       
    dealButton.setEnabled( false );
    return null;
    // execute application
    public static void main( String args[] )
    DeckOfCards app = new DeckOfCards();
    app.addWindowListener(
    // anonymous inner class
    new WindowAdapter() {
    // terminate application when user closes window
    public void windowClosing( WindowEvent windowEvent )
    System.exit( 0 );
    } // end anonymous inner class
    ); // end call to addWindowListener
    } // end method main
    } // end class DeckOfCards
    // class to represent a card
    class Card {
    private String face;
    private String suit;
    // constructor to initialize a card
    public Card( String cardFace, String cardSuit )
    face = cardFace;
    suit = cardSuit;
    // return String represenation of Card
    public String toString()
    return face + " of " + suit;
    } // end class Card

    You could have the original face values as integers, thus Ace = 1, Jack = 11 (it'll be easy enough to display the proper values AJQK if you keep your string array and just display whatever corresponds to the value held in your int array).
    Each player gets an array of five cards. You could the loop through each hand and increment values held in another array by one according to the value of the card. Haven't coded the following up but it should work I think.
    // hand [ ] represents the cards held by that player
    int handChecker [ ] = new int [14]
    for (int counter = 0; counter < 5; ++ counter)
    // 1st card is an Ace. handChecker [1] will be incrementd by one and so on
    // 2nd card is a 9. handChecker[9] will be incremented by one.
    handChecker[hand[counter]] += 1;
    // Loop through the array handChecker to find pairs etc.
    boolean pair = false;
    bollean tofk = false;
    for (int counter = 1; counter < 14; ++ counter)
    if (handChecker[counter] == 2)
    pair = true;
    if (handChecker[counter] == 3)
    tofk = true;
    if (pair)
    // player has a pair
    if(tofk)
    // player has three of a kind
    if(pair && tofk)
    // player has a full house

  • Formatting a string and number?

    I have a to use the method toString() which calls getPay(). getPay() gives a double value of the employee pay. This is what I have for the toString() method:
    abstract class Employee{
    private String name;
    private double pay;
    Employee(String n)
    name=n;
    public double getPay()
    return pay;
    public String toString()
    double amount = getPay();
    return format("Employee Name: %s\n Employee Pay: %.2f",name,amount);
    }I have looked all over google and the syntax that I am using seems to be right. I have even tried putting name and amount in an object and eclipse still throws a fit with the format method. Any ideas?

    Should I create an object array with the values of
    name and amount? And then use that as the argument
    for format?I believe the API docs for String, the varargs intro I linked, and trying it for yourself will answer the question.
    I'm not trying to be an asshole, really. I'm trying to get you to realize that you can find these kinds of answers on your own. Once you get used to that idea, you'll thank me for it. :-)
    Seriously: Read the docs, figure out what you think they mean, write some code based on the assumption that you're right, and see what happens. Repeat. Once you hit a brick wall that way and run out of ideas, post again.

  • Image Sequence with vertical and horizontal photos

    I'm trying to use a particle emitter with image sequence to make photos appear and move one at a time. I have collected about 20 JPEGs that I numbered sequentially so Motion would read them as an image sequence. No problem there. Most of the photos have a horizontal orientation (3000x2000) but several are vertical (2000x3000), and Motion is cropping the vertical images to fit within a horizontal frame (like this). When I apply the particle emitter, that cropping is retained.
    I know I have seen examples of a similar process and the emitter treats the photos are individual pieces, retaining their original size and orientation. What am I doing wrong?

    Technically, in a proper Image Sequence, all images are the same size/aspect ratio.
    What you'll need to do is make on set (vertical or horizontal) a new size, to fit inside the other. The Particle Emitter will matte it's images to one or the other, which ever comes first.

  • Read only number from string and number

    I have "COM4" from my I/O.  how could to read number 4 only?
      Thank you
    Solved!
    Go to Solution.

    Hello, i might need your help regarding this matter.
    I'm current taking a reading from Arduino from 2 accerolmeter to Labview. X=0.02 Y=-0.03 Z=0.99 A=0.33 B=0.42 C=0.84 (Example) 
    But when i display them using Waveform Chart in labview, I need to use the array to count the position of the String from buffer which sometimes might be inaccurate due to the the value extracted.
    I was told that i can use Search string from the beginning to allow the waveform to take in only the numeric. 
    Are you able to assist me regarding this issue?
    Below attached are the pictures..
    Attachments:
    LabviewBlockDiagram.png ‏64 KB
    LabviewFrontPanel.png ‏196 KB

  • BI Publisher -RTF Template issue: Output report not maintaining text with bullets and numberings.

    Hi All,
    I am currently working with generating reports using BI Publisher. My issue is that when I will preview the output(in PDF and RTF) format's  of the newly created template, then, if the data coming from DB have some bullets or numbering, then the BI publisher output will ignore the same and will show the complete data as one single line.
    For example if the data in the DB Field is like below:
    The XYZ has the below sub-parts:
    ABC : This again has two parts:
    abc1
    abc2
    CDE
    FGH
    Then  this data will appear as below in the BI Publisher output report's:
    The XYZ has the below sub-parts: •   ABC : This again has two parts:  o     abc1  o   abc2   •    CDE    •   FGH
    I want the format of the data (with bullets and number's) should be maintained in the BI Publisher Report as well, but I am unable to find any solution for the same.
    Any help on the same is much appreciated.
    Deep Bhoj

    in your query will u get all the columns always null when column1 is null
    in your template for each group u can write like below
    think G_1 as group in your xml
    <?for-each:G_1[COLUMN1!='']?><?COLUMN1?><?COMMENTS?><?end for each?>
    or if u are not sure u get null in both places every time u can write like below
    <?for-each:G_1[COLUMN1!='' and COMMENTS!='']?><?COLUMN1?><?COMMENTS?><?end for each?>

  • Storing strings and numbers in a spreadsheet

    in this file i understand that the data types are incorrect. but what i dont know is how to fix it so i can write arrays filled with strings and arrays filled with numbers to seperate columns in an excel spreadsheet.
    Solved!
    Go to Solution.

    sorty here it is.  thanks.
    Attachments:
    learning with kevin 17.vi ‏119 KB

  • Currency and Number Formats

    Hi Guys
    Is anybody aware of an equivalent of ISO 8601 that deals with Currency and Number formats?
    Thanks

    Thanks John
    My original question was a little ambiguous. What I'm really asking is whether, as with 8601, there is an agreed standard way of expressing numbers, (including currency). For instance, is there an 'approved' sign for indicating the start of the decimal portion, ('.' or ',')?
    The application already makes use of the various formatting utilities and ResourceBundles but I've been asked to investigate if there is an ISO specification that we should default to, (rather than just UK English). As I'm sure anybody who has used their site will appreciate, it is not overly simple to establish the existence and contents of a standard ;->
    Thanks in advance
    J

  • Creating BITC DVD with FCP and DVD Studio Pro

    Ok so here's my question:
    I've created a sequence with BITC, and now I want to export it to DVD studio pro so I can burn it to a dvd. I've been exporting as a quicktime movie, at DV PAL Anamorphic res. When I bring it into DVD Studio as an asset, it has to re-encode.
    Can I drop one of these steps - ie. how do I export from FCP so that the resulting file does not need to be re-encoded in DVD studio.
    I'm sure this is really very simple, but it's going to help me a lot - I have several (10-15) hours of footage to do this with. Thanks in advance...

    export the file as a QT not self-contained use current settings
    luanch Compressor, drag and drop the QT file on to the window then encode to get
    M2V video and AC3 sound file
    import those into DVDSP

Maybe you are looking for

  • How to pass jv for ED missing in excise invoice

    Hi Experts Could you pls tell me how to pass ED( Excise Duty ) entry through JV ( J1ih). Case: When the outgoing Excise Invoice was created one of the excise Duty was missing. Now i want to pass the ED against that invoice through JV . N pls also sug

  • Is it possible to use escalation/deadline in WS12300111?

    Hi all, We are in ECC 6.0 and I would like to know if there is any technical limitation that prevents one to implement the 'text book' deadline/escalation (modelled)?. I have copied standard workflow WS12300111 as well as task TS12300097. Is it possi

  • How I get the SYSTEM Entities in a dtd

    Hello, i have some xml Files with the following content: <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="style/webstyle.xsl"?> <!DOCTYPE contentobject PUBLIC "-//Test//DTD Content v1.1 20021018//EN" "dtd/content.dtd

  • How to import Console Add-in programmatically in VMM?

    Hello All, In my C# application, I want to import Console Add-in. To do this currently I am creating a folder structure with similar permissions as it was created during the import of Console Add-in from VMM UI. But when I start the VMM, it shows the

  • NAC @ Remote Sites

    I have a deployment of NAC Solution where CAM located @ HQ, Users at HQ has a dedicated CAS, while other sites has a seperate CAS/NAC Modular  located at thier sites the deployment is L3 OOB, in case the CAS at Remote site has failed, is there a way