Click here to Skip to main content
15,891,184 members
Please Sign up or sign in to vote.
3.50/5 (2 votes)
See more:
I am writing a database program and I would like to generate item codes so that all the item will be identified by this code.
The items are in categories examples (soft-drinks, wines, beers, etc.)

I would like to create a function the will generate this codes for me. For example a category (Array) is wines all the item codes in Wine in the Array Wine should begin with the word 'W', if it is Beers all the items codes in the Array Beer must begin with' B'.

Thank you.
Posted
Updated 6-Nov-11 4:45am
v2
Comments
Manfred Rudolf Bihy 6-Nov-11 9:34am    
And where exactly is your problem?
OriginalGriff 6-Nov-11 9:48am    
And what have you done so far?
Andrew Brock 6-Nov-11 10:12am    
If you are using a proper database solution such as MySQL, Oracle, Microsoft SQL, ... then there is functionality provided for generating unique IDs for a table entry. Depending on the particular database solution, you may or may not be able to add the category code to the front.
Sergey Alexandrovich Kryukov 6-Nov-11 10:36am    
What do you mean by generating code? Why? What's the idea behind?
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900