我有一发票,但作为唯一标识的单号我有一困难,怎样使RZDBLABEL1(Trzdblabel) 中在每次单击“新单”时,总能产生一个永不重复的单号?
这里要用到SQL 语句吗/能不能不用SQL 语句而用一函数来实现呀?
因我是一水平低的人,请各位写的尽详细一些。
我类似的例子也可以发到[email protected]先谢了。
这里要用到SQL 语句吗/能不能不用SQL 语句而用一函数来实现呀?
因我是一水平低的人,请各位写的尽详细一些。
我类似的例子也可以发到[email protected]先谢了。
或者使用递增啊
怎么能产生此号?(最好举一个例子,用程式,)
多谢了。
另外DELPHI中有没有比毫秒更精确的时间表达方法呀?如有该怎样写?多谢!
我试了多次怎么都不行。
最好代码写下面。
THANKS!
现取出当前的最大号码:select max(表单号) from Trzdblabel
然后取出这个表单号的后几个数字,递增后加上标识符头,就是一个
不重复的表单号了。
但是如果有多个客户端操作的话就不行了。
var
tempstr, year, month, day : string;
sqlstr : string;
newno : string;
begin
tempstr:=datetostr(datetimepicker1.date);
year:=copy(tempstr,1,4);
delete(tempstr,1,5);
month:=copy(tempstr,1,pos('-',tempstr)-1);
if (strtoint(month)<10) then
month:='0'+month;
delete(tempstr,1,pos('-',tempstr));
if (strtoint(tempstr)<10) then
day:='0'+tempstr
else
day:=tempstr;
tempstr:=dbedit1.text+year+month+day; sqlstr:='select no from tablename where no like '+QuotedStr(tempstr+'%')+' order by no desc;
adoquery1.close;
adoquery1.SQL.Clear;
adoquery1.SQL.Add(sqlstr);
adoquery1.Open;
if adoquery1.Fields[0].IsNull then
newno:=tempstr+'001'
else
newno:=inttostr(strtoint(adoquery1.Fields[0].AsString)+1);
end;newno就是将要产生的no
p.s.学校现在强制按mac地址收人头税,真受不了;要是能修改mac地址就好了;function something:int64;
asm
RDTSC
end;
能返回时间(cou内置计数器)到cpu主频级的精度,够你用的;秒级明显不够精确;
检索一下最后的单号,然后对其作相应的处理即可。
如:
create or replace trigger set_no_table1
before insert on Table1
for each row
begin
//对新的单号作处理。
end;