Oracle Trigger plus conditional judgment, Dblink

Source: Internet
Author: User

--new base station synchronization to battery pack informationCreate or Replace TriggerA_b_test AfterInsert or Update or Delete   onBJLT. Basestation--referencing new as New_val old as Old_val--Set the name here, and then you can reference the value   forEach row when(New.isnode=0)begin   ifInserting Then      Insert  intoBsms.bs_info@TOBSMS_BETTERY_LOCAL. Regress. Rdbms. DEV. US. Oracle.com (Infoid, InfoName, GROUPID, ADDRESS, Builddate, Maintenancer, TEL, temperature, rectifiercur, OU  Tvol, Createtime, SORTID, Oneoffvol, Twooffvol, Isnode, Nodenum, Onoffpower, Onoffpowermodel, Powera, POWERB, POWERC, Powerout, Poweracur, Powerbcur, Powerccur, Poweravol, Powerbvol, Powercvol, Dooropen, HS, Yangan, SHUIJIN, HONGWAI, Kongtiao, Verid)--values (Bid,bname,groupsid,      Values(: New.id,:new.name,:new. Groupsid,'1', Sysdate,'1',      '1',0,'1',      1, Sysdate,1,      1,1,1,      1,'1','1',      -1,-1,-1,-1,-1,-1,-1,-1,-1,-1,-1,0,-1,-1,-1,-1,      1); End if;EndA_b_test;

Dblink case, add local table, synchronize remote server another table

Reference from: http://www.blogjava.net/hhhaaawwwkkk/archive/2009/05/06/269251.html

Reference content:

---Create Dblink,dblink_test name, (A_test of synchronized database) ST10766 user name, ep password, ass100 connection stringCreate  Public Databaselink dblink_test Connect toST10766 identified byEP using'ass100';---delete Dblink----drop Public database link dblink_test;----Create a tableCreate TableA_test (IDint, namevarchar( -), passvarchar( -))Select *  froma_test;Insert  intoA_test (Id,name,pass)Values(1,'ZZN','Shanshan')Insert  intoB_test (Id,username,password)Values('1','ZXL','Xiaolan')----On the destination database, test Dblink, query the source database tableSelect *  fromA_test@dblink_orc10; Select *  froma_test;----Create a triggerCreate or Replace TriggerA_b_test AfterInsert or Update or Delete   ona_test forEach rowbegin  ifdeleting Then      Delete  fromB_testwhereId=: old.id; End if; ifInserting Then      Insert  intoB_test (Id,username,password)//fields for B_test tablesValues(: New.id,:new.name,:new.pass);//fields for A_test tablesEnd if; ifUpdating Then     UpdateB_testSetUsername=: New.name,password=: New.passwhereId=: old.id; End if;EndA_b_test;

Oracle Trigger plus conditional judgment, Dblink

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.