Generating Log Code (Surrogate Key)

  1.   String str1 = "select 'LOG' || replace(substr(quote(zeroblob((9 + 1) / 2)), 3, (9 - length('LOG') - length(max(IFNULL(e.LogID,0)+1)))), ''', '') || "
  2.                  +" max(IFNULL(e.LogID,0)+1) || '-' || strftime('%Y-%m-%d', date('now'))"
  3.                   +" from elog e ";
複製代碼
What happens when there are no rows in the
database initially.
Thanks

Why dun you try 1st?

And some times, for related reasons, we need to use nested ifnull() / nvl()

TOP

Thanks, I have solved it by Java instead

TOP