Click here to Skip to main content
15,921,577 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
table name : purchase

or_name ord_yr ord_numer

sal 2011 0004



after insert the table the value is

table name: purchase_order

order

sal-2011-0004



and again increment the ord_number replace 0004 to 005 and update the purchase table ,
Posted
Comments
CPallini 22-Apr-14 5:11am    
Why do you need another table for that? Cannot you just create a view with the concatenated values?

Create a column ord_counter in your database. Then get the last value of the counter per ord_year.
Increment the last value of the counter.
 
Share this answer
 
if you are using SQL then....

SQL
INSERT INTO purchase_order
(order)
SELECT or_name+'-'+ ord_yr+'-'+  ord_numer as order
FROM purchase;


set purchase_order id as auto increment


in oracle use ||
insted of +
 
Share this answer
 

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