Board logo

標題: Generating Log Code (Surrogate Key) [打印本頁]

作者: luckiejacky    時間: 2013-10-17 10:11     標題: 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
作者: henrywho    時間: 2013-10-17 11:15

Why dun you try 1st?

And some times, for related reasons, we need to use nested ifnull() / nvl()
作者: luckiejacky    時間: 2013-10-17 14:54

Thanks, I have solved it by Java instead





歡迎光臨 電腦領域 HKEPC Hardware (https://h0.hkepc.com/forum/) Powered by Discuz! 7.2