如何自动生成一个订单号,且动生成的订单号是连续的,不重复的,订单号的格式是 BB+11位数字+WL
例如 BB00000000001WL
    BB00000000002WL
请问该如何编写 

解决方案 »

  1.   


    var
      max:integer;
      str:string;
    begin
      ADOQuery1.Close;
      ADOQuery1.SQL.Text := 'select max(right(left(code,13),11)) as num from a';
      ADOQuery1.Open;
      max := ADOQuery1.FieldByName('num').AsInteger + 1;
      str := Format('%.11d',[max]);
      str := 'BB'+str+'WL';
      ShowMessage(str);
    end;
      

  2.   

    var
      iNo:string;
      idx:Integer;
    begin
      idx := (以前的订单号取中间部分值比较产生的最大值) + 1
      iNo := 'BB'+ Format('%.11d', [12]) + 'WL';
      ShowMessage(iNo );
    end;
      

  3.   

    var
      iNo:string;
      idx:Integer;
    begin
      idx := (以前的订单号取中间部分值比较产生的最大值) + 1
      iNo := 'BB'+ Format('%.11d', [idx]) + 'WL';
      ShowMessage(iNo );
    end;不过1楼已经给出完整的了
      

  4.   

    'select max(right(left(code,13),11)) as num from a'
    right在oracle数据库里无效
      

  5.   

    那你就找个orcal里支持的,方法就是这样,或许orcal还有更好的函数,至少substr(好像是这么写,就是取中间一段文字)类的应该有吧