Home > database >  The use of oracle triggers
The use of oracle triggers

Time:10-04

,, there is such a demand:
Two table, A table is the information table, table B is the history table, in addition to the fields in table A in table B, more than A "type" field;
Will the data in table A, I have to update to the table B, at the same time, the "type" field in table B automatically populated by A.a field corresponds to A type;
Don't know clearly stated the no, passing a great god can help me to look at with a trigger to realize ~
(baidu found that triggers a lot of more phyletic, grammar is great, but is basically all seem to check whether the insert/update/delete data format, don't know I can achieve I want, for a great god, thank,,)

CodePudding user response:

Will the data in table A, I have to update to the table B, at the same time, the "type" field in table B automatically populated by A.a field corresponds to A type;


In A field, A wanted to fill two fields to the table B?

CodePudding user response:

reference 1st floor wmxcn2000 response:
I will send the data in table A, update to the table B, at the same time, the "type" field in table B automatically populated by A.a field corresponds to A type;


In A field, A wanted to fill two fields to the table B?


So, A.a are some serial number, the serial number will be grouped; I want to save the serial number in the B at the same time, in another field to save the serial number corresponding to the group categories!! My idea is that the serial number at the same time, kept in a B trigger a trigger, automatic filling group categories!!!!!! Don't know if you could achieve ~

CodePudding user response:

Give some test data, and then give you the desired results;

CodePudding user response:

reference wmxcn2000 reply: 3/f
give some test data, and then give you the desired results;


===============================================
I did the table data but I don't know how to upload files,,,,,,,,

CodePudding user response:

reference wmxcn2000 reply: 3/f
give some test data, and then give you the desired results;


The data source table
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- the DDL for tables DX_SEND_HISTORY
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CREATE TABLE "ZFXX". "DX_SEND_HISTORY
"(" ID "VARCHAR2 (30 BYTE),
"SMSID" VARCHAR2 (30 BYTE),
"MOBILE" VARCHAR2 (12 BYTE),
"SERVICENUM" VARCHAR2 (8 BYTE),
"SMS" VARCHAR2 (400 BYTE),
"REPORT" VARCHAR2 (1 BYTE),
"PRIORITY" VARCHAR2 (1 BYTE),
"BUSIID" VARCHAR2 (50 BYTE),
"SYSTEMID" VARCHAR2 (3 BYTE),
"TYPE" VARCHAR2 (2 BYTE),
"CHANNELID" VARCHAR2 (1 BYTE),
"OPERATORS" VARCHAR2 (1 BYTE),
"SUBSYSID" VARCHAR2 (5 BYTE),
"SENDCOUNT" NUMBER (*, 0),
"PROCNAME" VARCHAR2 (30 BYTE),
"WRITETIME" DATE,
"DELAYEDTIME" DATE,
"SENDTIME" DATE,
"SUCCESSFLAG" VARCHAR2 (8 BYTE),
"MSGID" VARCHAR2 (30 BYTE),
"RECVTIME" DATE,
"REPORTSTAT" VARCHAR2 (2 BYTE),
"REPORTINFO" VARCHAR2 (200 BYTE),
"STEPNOW" VARCHAR2 (1 BYTE),
"MONTHDAY" VARCHAR2 (2 BYTE),
"OPTUSERNAME" VARCHAR2 (20 BYTE),
"SHOWFLAG" VARCHAR2 (1 BYTE)
) the SEGMENT CREATION IMMEDIATE
PCTFREE 10 PCTUSED 40 INITRANS 1 MAXTRANS 255
NOCOMPRESS LOGGING
1 the MAXEXTENTS STORAGE (INITIAL 65536 NEXT 1048576 MINEXTENTS 2147483645
PCTINCREASE 0 FREELISTS 1 FREELIST GROUPS 1
BUFFER_POOL DEFAULT FLASH_CACHE DEFAULT CELL_FLASH_CACHE DEFAULT)
In TABLESPACE "USERS";
REM INSERTING into ZFXX. DX_SEND_HISTORY
The SET DEFINE OFF;
Insert into ZFXX. DX_SEND_HISTORY (ID, SMSID, MOBILE, SERVICENUM, SMS, REPORT, PRIORITY, BUSIID, SYSTEMID, TYPE, CHANNELID, OPERATORS, SUBSYSID, SENDCOUNT, PROCNAME, WRITETIME, DELAYEDTIME, SENDTIME, SUCCESSFLAG, MSGID, RECVTIME, REPORTSTAT, REPORTINFO, STEPNOW, MONTHDAY, OPTUSERNAME, SHOWFLAG) values (' 20161201141451000000195 ', '1234', '18844067333', null, '1111', null, '1', 'D00001', '123', null, null, '1', null, null, null, null, null, null, null, null, null, '2', null, null, null, null, null);
Insert into ZFXX. DX_SEND_HISTORY (ID, SMSID, MOBILE, SERVICENUM, SMS, REPORT, PRIORITY, BUSIID, SYSTEMID, TYPE, CHANNELID, OPERATORS, SUBSYSID, SENDCOUNT, PROCNAME, WRITETIME, DELAYEDTIME, SENDTIME, SUCCESSFLAG, MSGID, RECVTIME, REPORTSTAT, REPORTINFO, STEPNOW, MONTHDAY, OPTUSERNAME, SHOWFLAG) values (' 20161201141451000000196 ', '2345', '18844067333', null, '2222', null, '2', 'D00002', '123', null, null, '1', null, null, null, null, null, null, null, null, null, '3', null, null, null, null, null);
Insert into ZFXX. DX_SEND_HISTORY (ID, SMSID, MOBILE, SERVICENUM, SMS, REPORT, PRIORITY, BUSIID, SYSTEMID, TYPE, CHANNELID, OPERATORS, SUBSYSID, SENDCOUNT, PROCNAME, WRITETIME, DELAYEDTIME, SENDTIME, SUCCESSFLAG, MSGID, RECVTIME, REPORTSTAT, REPORTINFO, STEPNOW, MONTHDAY, OPTUSERNAME, SHOWFLAG) values (' 20161201141451000000197 ', '3456', '18844067333', null, '3333', null, '3', 'D00003', '123', null, null, '1', null, null, null, null, null, null, null, null, null, '3', null, null, null, null, null);

CodePudding user response:

reference wmxcn2000 reply: 3/f
give some test data, and then give you the desired results;



To update the data of target table
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
- the DDL for tables TJ_SEND_HISTORY
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --

CREATE TABLE "ZFXX". "TJ_SEND_HISTORY
"(" MX_ID "VARCHAR2 (20 BYTE),
"REQUEST_ID" VARCHAR2 (30 BYTE),
"DX_ID" VARCHAR2 (30 BYTE),
"SMSID" VARCHAR2 (30 BYTE),
"MOBILE" VARCHAR2 (12 BYTE),
"SERVICENUM" VARCHAR2 (8 BYTE),
"SMS" VARCHAR2 (400 BYTE),
"REPORT" VARCHAR2 (1 BYTE),
"PRIORITY" VARCHAR2 (1 BYTE),
"BUSIID" VARCHAR2 (50 BYTE),
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related