Search
Search titles only
By:
Search titles only
By:
Log in
Register
Search
Search titles only
By:
Search titles only
By:
Menu
Install the app
Install
Forums
New posts
All threads
Latest threads
New posts
Trending threads
Trending
Search forums
What's new
New posts
New ads
New profile posts
Latest activity
Free Ads
Latest reviews
Search ads
Members
Current visitors
New profile posts
Search profile posts
Contact us
Latest ads
එක පැකේජ් එකයි මාසෙටම Unlimited Internet. තාමත් DATA CARD දාන්න සල්ලි වියදම් කරනවද? අඩුම මිලට අපෙන්.
sayuru bandara
Updated:
Tuesday at 12:30 PM
Ad icon
ඉන්ටර්නෙට් එකෙන් හරියටම සල්ලි හොයන්න සහ Success වෙන්න කැමතිද? 🚀 (E-Money & Success Stories)
siri sumana
Updated:
Saturday at 11:44 PM
Gemini AI PRO 18 months Offer
Hawaka
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Ad icon
koko account
DasunEranga
Updated:
May 27, 2026
Electronics
Vehicles
Property
Search
Reply to thread
Forums
General
ElaKiri Talk!
JAVA
Get the App
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Message
<blockquote data-quote="pradeep0079" data-source="post: 10853568" data-attributes="member: 302518"><p>machen uba kiyanne invoice number eka auto generate karanne kohomada kiyalada like 1,2,3 or 00001,0002,0003 </p><p>is that i will mention some method but this is for enterprise db ,i don't remember mysql so you get the concept and impliment on mysql</p><p></p><p>method 1:</p><p>get the count in invoice table and increment it by one </p><p>select count(*)+1 as serial from yourtable </p><p>this is one method but it has some draw backs</p><p></p><p>second method: </p><p>create a index or sequence </p><p>CREATE SEQUENCE your_seq</p><p> INCREMENT 1</p><p> MINVALUE 1</p><p> MAXVALUE 9223372036854775807</p><p> START 1</p><p> CACHE 1;</p><p>ALTER TABLE your_seq OWNER TO enterprisedb;</p><p></p><p>using sequence you can do it two ways </p><p>1.use it in your insert query </p><p>like insert into your_table(column names) values (,,,,,your_seq.nextval)</p><p>2. use a stored procedure to generate patterned serial</p><p> function fc_get_orderno</p><p>return varchar is </p><p>begin </p><p></p><p>return lpad(seq_your.nextval,4,0);</p><p>end;</p><p>this will return a number like 0001,0002</p><p></p><p>3.use a sepearte table for sequence </p><p>create a tabe with columns srial_name,serial_vale with varchar ,number</p><p>then </p><p>in your code get the serial_vale +1 from your table </p><p>after you have to update it </p><p></p><p>let say you have 30 in your serial_value </p><p>then you get 31 </p><p>then you have to update 31 as your serial value </p><p>but remenber you have to handle concurrency in your code and db </p><p>otherwise this will be a mess</p><p></p><p>i recommend 2 method since db handle the concurrency and i most used it</p></blockquote><p></p>
[QUOTE="pradeep0079, post: 10853568, member: 302518"] machen uba kiyanne invoice number eka auto generate karanne kohomada kiyalada like 1,2,3 or 00001,0002,0003 is that i will mention some method but this is for enterprise db ,i don't remember mysql so you get the concept and impliment on mysql method 1: get the count in invoice table and increment it by one select count(*)+1 as serial from yourtable this is one method but it has some draw backs second method: create a index or sequence CREATE SEQUENCE your_seq INCREMENT 1 MINVALUE 1 MAXVALUE 9223372036854775807 START 1 CACHE 1; ALTER TABLE your_seq OWNER TO enterprisedb; using sequence you can do it two ways 1.use it in your insert query like insert into your_table(column names) values (,,,,,your_seq.nextval) 2. use a stored procedure to generate patterned serial function fc_get_orderno return varchar is begin return lpad(seq_your.nextval,4,0); end; this will return a number like 0001,0002 3.use a sepearte table for sequence create a tabe with columns srial_name,serial_vale with varchar ,number then in your code get the serial_vale +1 from your table after you have to update it let say you have 30 in your serial_value then you get 31 then you have to update 31 as your serial value but remenber you have to handle concurrency in your code and db otherwise this will be a mess i recommend 2 method since db handle the concurrency and i most used it [/QUOTE]
Insert quotes…
Verification
Hathara warak wissa keeyada? (Hathara wadi karanna 20)
Post reply
Top
Bottom