SQL triggers: Automatically update the provinces and cities in the contact page based on the region information in the customer profile

Source: Internet
Author: User

USE [UFDATA_001_2017]GO /****** OBJECT:  TRIGGER [DBO]. [jds_customer_updatecity]    script date: 07/06/2018 16:53:04 ******/ set ansi_nulls ongo set quoted_identifier ongo  create trigger [ DBO]. [Jds_customer_updatecity] on [dbo]. [Customer]  for insert, delete ,update (remove, otherwise will be error nested layer number not exceeding) not for  replicationas         beginset nocount on;    --premise: The city names in the regional archives must be standardized--get the region code from the customer file, get the city  declare  @CUScode  varchar from the regional classification declare @ City varchar (declare  @cProvince  varchar)  select  @CUScode =ccuscode from  inserted select  @city =cdcname from districtclasswhere cdccode = (select  cdccode from customer where [email protected])  --from the provincial table to get the province  select   @cPrOvince=vsimplename from hr_ct007 where ccodeid = (Select distinct cpcodeid  from hr_ct007where  ilevels in (1)   and vdescription like  '% ' [email protected]+ '% ')   --last updated the provinces and cities in the customer profile update customerset [email protected],[ email protected]where [email protected]  set nocount off;         end  go


SQL triggers: Automatically update the provinces and cities in the contact page based on the region information in the customer profile

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.