Oracle uses triggers to update values for a column when inserted

Source: Internet
Author: User

Create a table First Brzl

Where Pym is the first letter of BRXM Pinyin

Trigger creation method Under simple remarks before creating a new trigger

create [or replace] Tigger Trigger Name trigger event on table name [for each row]begin PL/SQL statement end where: Trigger name: The name of the trigger object. Because the trigger is automatically executed by the database, the name is just a name and has no real purpose. Trigger time: Indicates when the trigger executes, which is preferable: Before: Represents the trigger execution before the database action; After: Indicates that the trigger executes after the database action. Trigger event: Indicates which database actions trigger this trigger: Insert: Database insert triggers this trigger; UPDATE: Database modification triggers this trigger; Delete: Database delete triggers this trigger. Table name: The table where the database trigger resides. For each row: executes once on each row of the table trigger. If you do not have this option, only one time is executed for the entire table.

Start operation

1 CREATE OR REPLACE TRIGGERbrzl_pym_up2BeforeInsert  onBrzl3    forEach row4 Declare5Lipymvarchar2(Ten);--declaring Variables6 BEGIN7 8   SelectFgetpy (: NEW.BRXM) intoLipym fromDual--: New is the record that will be inserted9 Ten: New.pym:=Lipym; One  A ENDBrzl_pym;

The effect is as good as the description is poor. Direct view operation;

Oracle uses triggers to update values for a column when inserted

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.