在ASP.NET+ORACLE添加資料記錄並讓ID自動增量

來源:互聯網
上載者:User

  在ASP.NET+ORACLE添加資料記錄並讓ID自動增量需要在ORACLE中設序列和觸發器即可,切記不是索引,ASP.NET中不管ID,具體如下:


  1、建立序列:


CREATE SEQUENCE seq_emergency_id
NOCYCLE
MAXVALUE 9999999999
START WITH 2;

 
  2、建立觸發器:

 
CREATE OR REPLACE TRIGGER set_emergency_id
BEFORE INSERT ON "EMERGENCY"
FOR EACH ROW
DECLARE
next_emergency_id NUMBER;
BEGIN
--Get the next emergency id from the sequence
SELECT seq_emergency_id.NEXTVAL
INTO next_emergency_id
FROM dual;


--use the sequence number as the primary key
--for the record being inserted
:new.id := next_emergency_id;
END;

 
  如果在企業管理器中建立,在觸發器說明中填:


DECLARE
next_emergencycb_id NUMBER;
BEGIN
--Get the next id number from the sequence
SELECT seq_emergencycb_id.NEXTVAL
INTO next_emergencycb_id
FROM dual;


--use the sequence number as the primary key
--for the record being inserted
:new.id := next_emergencycb_id;
END;


  自己總結的常用ORACLE Text 文本檢索

 
  ORACLE Text 文本檢索:(先要建立CONTEXT或CTXCAT索引,然後如下)(還可以在from前加,SCORE(10)來觀察檢索到的項目的得分)

 
  1.單詞的精確匹配檢索


  select cbid,title(列名) from emergency(表名) where contains(title,'關於')>0; 是從title中檢索含詞“關於”的cbid和title欄位。

 
  2.多個單詞精確匹配


  select cbid,title form emergency where contains(title,'關於 AND 請示')>0;是從title中檢索含詞“關於”和“請示”的上述欄位。


  也可select cbid,title form emergency where contains(title,'關於 AND 請示',NULL)>0;意思同上,不是檢索短語而是兩個單詞,注意!

 
  3.短語精確匹配

  select cbid,title(列名) from emergency(表名) where contains(title,'doctor visits',NULL)>0;將精確匹配doctor visits短語


  如果要用AND,OR,MINUS等保留字,應該使用轉義符{},如doctor {and} visits 


  4.搜尋互相接近的詞語


select cbid,title(列名) from emergency(表名) where contains(title,'關於 NEAR 請示')>0;
select cbid,title(列名) from emergency(表名) where contains(title,'NEAR((關於,請示),10)')>0;  是指指定的兩個詞在10個詞之內

 
  5.在搜尋中使用萬用字元(多字元萬用字元是%,單字元萬用字元是-)


select cbid,title(列名) from emergency(表名) where contains(title,'worker%')>0;是檢索worker開頭的單詞,單字通配最多擴充3字元


  6.模糊比對搜尋


select cbid,title(列名) from emergency(表名) where contains(title,'?關於')>0;  (前面得加一個問號)


  7.使用ABOUT運算子來搜尋文檔的主題


select cbid,title form emergency where contains(title,'ABOUT(房屋)',NULL)>0;


  注意以上如果是用CONTEXT索引時,基表更新時文本索引並不更新,為了使索引同步,應該執行CTX_DLL程式包的SYNC_INDEX過程如下:


EXECUTE CTX_DLL.SYNC_INDEX('REVIEW_INDEX');



聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.