Home » SQL & PL/SQL » SQL & PL/SQL » Trigger Prob.
icon10.gif  Trigger Prob. [message #189161] Wed, 23 August 2006 08:09 Go to next message
loginol
Messages: 2
Registered: August 2006
Junior Member
Hi i am so new pl/sql,
i have a problem ,
first Mytable : ID(integer),
K_ID(varchar2(4)),
K_NAME(varchar2(20)),

i am using aspx and c#;
ı want to when i insert one record(K_ID and K_NAME) in aspx page ,my trigger must update ID auto increment; like SQL Servers auto increment property ,

how can ı do ,

Re: Trigger Prob. [message #189163 is a reply to message #189161] Wed, 23 August 2006 08:18 Go to previous messageGo to next message
gbarbisan
Messages: 67
Registered: August 2006
Location: Treviso - Italy
Member
Very simply, you can:

CREATE SEQUENCE SEQ_K_ID;


and then:

CREATE OR REPLACE TRIGGER MY_TABLE_BI0
  BEFORE INSERT ON MY_TABLE
  FOR EACH ROW
BEGIN
  IF :NEW.K_ID IS NULL THEN
    SELECT SEQ_K_ID.NEXTVAL INTO :NEW.ID FROM DUAL;
  END IF;
END MY_TABLE_BI0;


This solution only applies if you don't have any special processing on new ID's inserted.

G.
icon10.gif  Re: Trigger Prob. [message #189166 is a reply to message #189163] Wed, 23 August 2006 08:30 Go to previous message
loginol
Messages: 2
Registered: August 2006
Junior Member
thanksssssss
Previous Topic: Strange query...
Next Topic: Identifying access privileges
Goto Forum:
  


Current Time: Mon Dec 05 09:07:55 CST 2016

Total time taken to generate the page: 0.15603 seconds