alphanumeric number generation
-
I am developing a project ASSET MANAGEMENT SYSTEM in which i am giving the asset Id to every asset . I have my office at different places in INDIA. Every now and then new asset is purchased so I want a perfect record in a database. My question is that i want a asset number consists of company name then 3 words of city and then number . for eg: let company name is XYZ it is purchased in city MUMBAI so i want asset id like----> XYZ/MUM/001. on every new entry of a record. AMRITESH ASTHANA
-
I am developing a project ASSET MANAGEMENT SYSTEM in which i am giving the asset Id to every asset . I have my office at different places in INDIA. Every now and then new asset is purchased so I want a perfect record in a database. My question is that i want a asset number consists of company name then 3 words of city and then number . for eg: let company name is XYZ it is purchased in city MUMBAI so i want asset id like----> XYZ/MUM/001. on every new entry of a record. AMRITESH ASTHANA
You are talking about a real-life identifier. That's not the same as a primary key in a database. A primary key does NEVER, EVER have a constant text in there. You create a field for you numeric; don't use the PK. Next, add in a FK to the place where it is bought. Then create a calculated field to get the name of the place, and format it as your real-life identifier.
Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]
-
I am developing a project ASSET MANAGEMENT SYSTEM in which i am giving the asset Id to every asset . I have my office at different places in INDIA. Every now and then new asset is purchased so I want a perfect record in a database. My question is that i want a asset number consists of company name then 3 words of city and then number . for eg: let company name is XYZ it is purchased in city MUMBAI so i want asset id like----> XYZ/MUM/001. on every new entry of a record. AMRITESH ASTHANA
You could have three columns in your table called company_name of type varchar(5) (or whatever length you desire) purchase_city of type varchar(5) (or whatever length you desire) asset_sn of type int Make these columns unique so you can't add the same number twice. Index name could be ix_asset_number When you add a new inventory item you first get the last registered row for the company and city. SELECT LAST(asset_sn) AS AssetNumber FROM assets WHERE company_name = 'XYZ' AND purchase_city = 'MUM'; Then increment the AssetNumber with 1 and insert the new record.
-
You could have three columns in your table called company_name of type varchar(5) (or whatever length you desire) purchase_city of type varchar(5) (or whatever length you desire) asset_sn of type int Make these columns unique so you can't add the same number twice. Index name could be ix_asset_number When you add a new inventory item you first get the last registered row for the company and city. SELECT LAST(asset_sn) AS AssetNumber FROM assets WHERE company_name = 'XYZ' AND purchase_city = 'MUM'; Then increment the AssetNumber with 1 and insert the new record.
Thanks George it works :)
-
Thanks George it works :)
You are welcome.