Home > database >  Oracle triggers
Oracle triggers

Time:09-20

A table, A has listed A: primary key, VARCHAR2 (10), b: VARCHAR2 (50), and c: VARCHAR2 (50), d: VARCHAR2 (50); To the table to import Execl table data article 5, article 3 b column data, q: use Oracle triggers, let the b column not repeat, repeat data have the same time, in the back automatically add 1, 2, 3,..., for example: b: 4, 123123111123122 after the trigger to: 123-1123-4, 2111123-3122, several duplicate data, behind the "-" is automatically added to the few

CodePudding user response:

 if inserting then 
Select count (*) into the I from table_a where A substr (a., 0, length: new. B))=: new. B;
If I=0 then
Insert into...
The value...
The else
i=i+1;
B: new. B:=: new. | | '-' | | I;
Insert into...
The value...
end if;

CodePudding user response:

"Insert into... The value... "This write an additional statement? Insert into A (b, c, d) values (', ', ')?

CodePudding user response:

refer to the second floor was a sad rain outside Moscow response:
"insert into... The value... "This write an additional statement? Insert into A (b, c, d) values (', ', ')?

Don't write, is that I am writing to you to understand, you put the Insert into... Delete is still behind the Value

CodePudding user response:

If inserting then
Select count (*) into the I from table_a where A substr (a., 0, length: new. B))=: new. B;
If I=0 then

The else
i=i+1;
B: new. B:=: new. | | '-' | | I;

End the if
End

This is ok

CodePudding user response:

refer to 4th floor was a sad rain outside Moscow response:
if inserting then
Select count (*) into the I from table_a where A substr (a., 0, length: new. B))=: new. B;
If I=0 then
The else
i=i+1;
B: new. B:=: new. | | '-' | | I;
End the if
End the if

So you can yao
that's it

CodePudding user response:

I generation refers to what

CodePudding user response:

refer to 6th floor response:
I generation refers to what is
: new. B:=: new. B | | '-' | | I; Can't you see I this sentence is what
  • Related