2011年2月19日 星期六

Insert null value into DB using iBatis

假設是要把Question欄位塞入null值,必須加入 isNull 及 isNotNull 判斷

    set IDENTITY_INSERT AQ OFF
  
    SELECT @@IDENTITY AS AQ_ID
   
    insert into AQ
  
    (aq_Lev1_Id, aq_Lev2_Id, is_Limited_Area, question, answer, creator, created_time, editor, edited_time, seqence)
  
    values
  


    (#aqLev1Id:BIGINT#, #aqLev2Id:BIGINT#, #isLimitedArea:OTHER#, #question:OTHER#, #answer:OTHER#, #creator:OTHER#, #createdTime:TIMESTAMP#, #editor:OTHER#, #editedTime:TIMESTAMP#, #seqence:SMALLINT#)
  
  
    (#aqLev1Id:BIGINT#, #aqLev2Id:BIGINT#, #isLimitedArea:OTHER#, null, #answer:OTHER#, #creator:OTHER#, #createdTime:TIMESTAMP#, #editor:OTHER#, #editedTime:TIMESTAMP#, #seqence:SMALLINT#)
  


  javascript:void(0)


使用起來就像是這樣
sqlMap.insert("AQ.my_insertSelective", insertObj);
//obj.addAQ("1", "2,3", "110000,110102", "2,3", 2L, 3L, null, "AtestA", "norman")
Reference:

沒有留言:

張貼留言