C
C#7mo ago
IRON MAN

i have some doubt ..in here this is the sequence number generatingeg:SGC24DOC000001

i have some doubt .. in here this is the sequence number generating eg:SGC24DOC000001 it should be increment one after one..after saving it ..i set in sequences that increment one once..but..its making twice while iam saving the code is in beloow
public async Task<Service> GetDocnumber(Service service)
{
try
{
using (var db = new Hr_Entities())
{
var nextValQuery = "SELECT SAFARIHR.HR_DOC_NO.NEXTVAL FROM DUAL";
var nextVal = await db.Database.SqlQuery<decimal>(nextValQuery).FirstOrDefaultAsync();
var today = DateTime.Now;
var lastTwoDigitsOfYear = today.Year % 100;
var seqNumber = nextVal.ToString().PadLeft(6, '0');
var DocumentNumber = $"SGC{lastTwoDigitsOfYear:00}DOC{seqNumber}";

service.Response = DocumentNumber;
}
}
catch (Exception ex)
{
throw ex;
}
return service;
}
public async Task<Service> GetDocnumber(Service service)
{
try
{
using (var db = new Hr_Entities())
{
var nextValQuery = "SELECT SAFARIHR.HR_DOC_NO.NEXTVAL FROM DUAL";
var nextVal = await db.Database.SqlQuery<decimal>(nextValQuery).FirstOrDefaultAsync();
var today = DateTime.Now;
var lastTwoDigitsOfYear = today.Year % 100;
var seqNumber = nextVal.ToString().PadLeft(6, '0');
var DocumentNumber = $"SGC{lastTwoDigitsOfYear:00}DOC{seqNumber}";

service.Response = DocumentNumber;
}
}
catch (Exception ex)
{
throw ex;
}
return service;
}
we create sequnce in table..
CREATE SEQUENCE SAF.HR_DOC_NO
START WITH 16
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;
CREATE SEQUENCE SAF.HR_DOC_NO
START WITH 16
MAXVALUE 999999999999999999999999999
MINVALUE 1
NOCYCLE
NOCACHE
NOORDER;
No description
No description
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server