Triggers and stored procedures

Source: Internet
Author: User

Trigger

Existing dictionary table (Dict)

Field Description
Mark
ItemKey Key
ItemValue Value
UpperId Upper Layer ID
Requirement 1: when a new record is added, if the same key already exists, insertion is rejected.

  ANSI_NULLS  QUOTED_IDENTIFIER   .     .    ( ()  , inserted inobj  .ItemKey  inobj.ItemKey  .Id  inobj.Id)      (,, 
Requirement 2: When a record is deleted, it is rejected if a lower-level record exists.
  ANSI_NULLS  QUOTED_IDENTIFIER   .     .    ( ()  , deleted delbj  .UpperId  delbj.Id)      (,, 
Requirement 3: When a record is deleted, if a lower-level record exists, the lower-level record is also deleted.
  ANSI_NULLS  QUOTED_IDENTIFIER   .     .( ()    UpperId    UpperId   ( Id  ))              UpperId    UpperId   ( Id  

 

Stored Procedure

Existing User table)

Field Description
Id Mark
Name Name
Age
DeptId Department ID

Department table (Dept)

Field
Id Mark
Name Name
Requirement 1: use stored procedures to query information of all users (ID, name, age, and department name)

 ANSI_NULLS  QUOTED_IDENTIFIER   .         .Id ,.Name , .Age , .Name        .DeptId  
 GetUsers
Requirement 2: Use the stored procedure to query the user information (ID, name, age, and department name) of a specified department)
 ANSI_NULLS  QUOTED_IDENTIFIER   .           .Id ,.Name , .Age , .Name           .DeptId   .Id  
 GetUsersByDept 
Requirement 3: Call the Stored Procedure 'getusersbydept' using ADO in the project'

1. Environment: VS2010 + sql2008

2. Create an edmx file and reference two tables and stored procedures.

3. Switch to 'model browser' and 'add function import'

 

4. On the 'Add function import' panel, click 'retrieve column information'. After obtaining column information, click 'create complex type ', after confirmation, you can call the stored procedure through Func.

5. Call the code Demo

             ( context =  result = context.GetUsersByDept( 
2013

Why is mixing so bad?

Why is it so uncomfortable?

But why is it so calm?

I chose to keep the status quo instead of having never thought about changes, but cannot be imprison-free.

We hope 2014 will change somewhat.

At present, I can only comfort myself with the phrase "I am myself, I am a fireworks of different colors ".

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.