主頁(yè) > 知識(shí)庫(kù) > oralce和db2兼容開(kāi)發(fā)注意事項(xiàng)

oralce和db2兼容開(kāi)發(fā)注意事項(xiàng)

熱門(mén)標(biāo)簽:慧營(yíng)銷(xiāo)crm外呼系統(tǒng)丹丹 百度地圖標(biāo)注途經(jīng)點(diǎn) 哈爾濱電話機(jī)器人銷(xiāo)售招聘 地圖標(biāo)注養(yǎng)老院 圖吧網(wǎng)站地圖標(biāo)注 愛(ài)客外呼系統(tǒng)怎么樣 哪個(gè)400外呼系統(tǒng)好 山東crm外呼系統(tǒng)軟件 開(kāi)發(fā)外呼系統(tǒng)

數(shù)據(jù)庫(kù)兼容,在開(kāi)發(fā)項(xiàng)目過(guò)程中,難免會(huì)遇到 更改數(shù)據(jù)庫(kù),或者后期 項(xiàng)目升級(jí),也可能會(huì)遇到這種情況,這里就說(shuō)明下oralce和db2兼容開(kāi)發(fā)注意事項(xiàng)。

兼容oralce、db2開(kāi)發(fā)注意事項(xiàng)(前提是db2版本是9.7,且是開(kāi)啟PLSQL編譯選項(xiàng)之后創(chuàng)建的數(shù)據(jù)庫(kù)):

 1. 在like 之后若使用了表字段,應(yīng)統(tǒng)一改成使用locate函數(shù)

   如:
  oralce寫(xiě)法:
   select * from fw_right a where '03' like a.rightid||'%';
  兼容寫(xiě)法:
   select * from fw_right a where locate('03',a.rightid) = 1;
  oralce寫(xiě)法:
   select * from fw_right a where '03' like '%'||a.rightid||'%';
  兼容寫(xiě)法:
   select * from fw_right a where locate('03',a.rightid) > 0;

 2. 視圖中使用的別名不應(yīng)該與當(dāng)前表字段同名

    如以下語(yǔ)句,在Oracle中不會(huì)有問(wèn)題,但在db2中會(huì)報(bào)"SQL0153N"錯(cuò)誤:

 e.g: 
  CREATE OR REPLACE VIEW V_WF_TODOLIST AS
     select c.process_def_id, c.process_def_name, a.action_def_id,
       a.work_item_id,  a.bae007,      a.action_def_name,
       a.state,     a.pre_wi_id,    a.work_type,
       a.operid,     a.x_oprator_ids,  b.process_key_info,
       to_char(to_date(a.start_time,  'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss') as start_time,
       to_char(to_date(a.complete_time,'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss') as complete_time,
       a.filter_opr, a.memo,a.bae002,a.bae003, a.bae006,c.x_action_def_ids
 from wf_work_item a, wf_process_instance b, wf_action_def c
  where a.action_def_id = c.action_def_id
  and b.process_def_id = c.process_def_id
  and a.bae007 = b.bae007
  and a.state in('0','2')

        兼容寫(xiě)法:

CREATE OR REPLACE VIEW V_WF_TODOLIST AS
  select c.process_def_id, c.process_def_name, a.action_def_id,
   a.work_item_id,  a.bae007,      a.action_def_name,
   a.state,     a.pre_wi_id,    a.work_type,
   a.operid,     a.x_oprator_ids,  b.process_key_info,
   to_char(to_date(a.start_time,  'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss') as start_time_0,
   to_char(to_date(a.complete_time,'yyyymmddhh24miss'),'yyyy-mm-dd hh24:mi:ss') as complete_time_0,
   a.filter_opr, a.memo,a.bae002,a.bae003, a.bae006,c.x_action_def_ids
   from wf_work_item a, wf_process_instance b, wf_action_def c
   where a.action_def_id = c.action_def_id
   and b.process_def_id = c.process_def_id
   and a.bae007 = b.bae007
   and a.state in('0','2')
   

   3.在下列情況下不允許 ORDER BY 或 FETCH FIRST n ROWS ONLY: 

*  外層全查詢(xún)視圖
  *  "SQL 表函數(shù)"的 RETURN 語(yǔ)句中的外層全查詢(xún)
  *  具體化查詢(xún)表定義
  *  未用圓括號(hào)括起來(lái)的子查詢(xún)

  否則會(huì)報(bào)"SQL20211N  規(guī)范 ORDER BY 或 FETCH FIRST n ROWS ONLY 無(wú)效。"錯(cuò)誤.  

  e.g:
  oralce寫(xiě)法:

  CREATE OR REPLACE VIEW V_FW_BLANK_BULLETIN as
  select id,   bae001, operunitid, operunittype, unitsubtype, ifergency,
    title, content, digest,  duetime,   validto,   aae100,
    bae006, bae002, bae003,  id as colid,
    substr(digest,1,20) as digest2
   from fw_bulletin
  where duetime = to_char(sysdate,'yyyymmddhh24miss')
   and (to_char(validto) >= to_char(sysdate,'yyyymmddhh24miss') or validto is null)
   and aae100 ='1'
  order by ifergency desc, id desc, duetime desc

      兼容寫(xiě)法:

  CREATE OR REPLACE VIEW V_FW_BLANK_BULLETIN as
  select * from (select id,   bae001, operunitid, operunittype, unitsubtype, ifergency,
   title, content, digest,  duetime,   validto,   aae100,
   bae006, bae002, bae003,  id as colid,
   substr(digest,1,20) as digest2
  from fw_bulletin
  where duetime = to_char(sysdate,'yyyymmddhh24miss')
  and (to_char(validto) >= to_char(sysdate,'yyyymmddhh24miss') or validto is null)
  and aae100 ='1'
  order by ifergency desc, id desc, duetime desc)

 

感謝閱讀,希望能幫助到大家,謝謝大家對(duì)本站的支持!

您可能感興趣的文章:
  • Oralce中VARCHAR2()與NVARCHAR2()的區(qū)別介紹
  • Oralce 歸檔日志開(kāi)啟與關(guān)閉示例
  • 提取oralce當(dāng)天的alert log的shell腳本代碼
  • oralce 計(jì)算時(shí)間差的實(shí)現(xiàn)

標(biāo)簽:和田 青島 武漢 承德 周口 固原 甘肅 開(kāi)封

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《oralce和db2兼容開(kāi)發(fā)注意事項(xiàng)》,本文關(guān)鍵詞  oralce,和,db2,兼容,開(kāi)發(fā),注意事項(xiàng),;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《oralce和db2兼容開(kāi)發(fā)注意事項(xiàng)》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于oralce和db2兼容開(kāi)發(fā)注意事項(xiàng)的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章