My question is i want generete a auto increment number for my purchase order for every creation of a PO such as,
PO_000001 , PO_000002 ... etc
Please let me how to generate above way my auto increment number ,
Thank you
My question is i want generete a auto increment number for my purchase order for every creation of a PO such as,
PO_000001 , PO_000002 ... etc
Please let me how to generate above way my auto increment number ,
Thank you
You can store the latest value in ur db. Ex: 1
When u are creating a new Purchase order just do it as 'PO_0000 + (db_value + 1)'
I think what you can do is first of all make a auto increment field on your table. So when we need to add your purchase_ID
you can get the maximum value of that auto increment fields. like
SELECT field_name FROM table ORDER BY id DESC LIMIT 1;
using above you can get the latest value of the table. then using that you can make your purchase_ID
depend on that.
let latest_auto_increment_value = "" + db_value; // make integer to string
let def_val = "0000";
let purchase_ID = 'PO_' + def_val.substring(0, def_val.length - latest_auto_increment_value.length) + latest_auto_increment_value;
Generally, This kind of operation is sensitive and secure for any domain, this should be stored in the backend like API or in table whenever you manage. from the frontend Angular, you have to manage a new purchase order every success order that will increment by its number should manage from backend like we know the primary key concept and auto-increment concept. For Ref.
CREATE TABLE contacts
( contact_id INT(11) NOT NULL AUTO_INCREMENT,
last_name VARCHAR(30) NOT NULL,
first_name VARCHAR(25),
birthday DATE,
CONSTRAINT contacts_pk PRIMARY KEY (contact_id)
);