Stored Procedure Specification

Source: Internet
Author: User
The stored procedure is easy to use, but it is difficult to read. It is not as easy to read as C # code.
The following describes the encoding rules of stored procedures.

Name of a stored procedure:
Module name_stored procedure name_proc
Example: job_addjob_proc
Pinyin cannot be used in the name of a stored procedure.

Note:
/*
Function: Function Description
Author: xumr
Created on:
Modified on: xumr added a restriction on name uniqueness.
Return Value:
--- 1: specific meaning
--- 2: specific meaning
...
--- Others: specific meaning

[If other stored procedures are called in this stored procedure]
Stored Procedure:
--- 1: job_isexist_proc
...

[If it is referenced by another stored procedure]
The stored procedure that applies the stored procedure:
--- 1: job_managejob_proc

Ideas:
--- 1: first determine whether the name is null
--- 2: second...

*/

Create proc job_addjob_prc

-- Parameter description
@ Parm1 as varchar (100 ),

-- Parameter description
@ Parm2 as varchar (50 ),

-- Parameter description
@ Parm3 as varchar (50 ),

-- Parameter description
@ Parm4 as int
As

2. Create procedure DBO. p_my_documentadd
(
@ Entid as char (10) Out,
@ Title as varchar (100 ),
@ Comment as text,
@ Hits as int,
@ Type as varchar (20 ),
@ Gender as tinyint
)
As
Begin
Begin tran -- start transaction
-- Generate a primary key
Exec p_my_gettablenextid 'document', 'D', 10, @ entid output // generate a primary key if no primary key is defined
Insert into document (
Entid,
Title,
Comment,
Hits,
Type,
Gender)
Values (
@ Entid,
@ Title,
@ Comment,
@ Hits,
@ Type,
@ Gender)
-- Error handling
If (@ error! = 0)
Begin
Raiserror 20000 'P _ my_documentadd: cannot insert data into p_my_documentadd' -- throws an error to the application
Rollback tran -- roll back the transaction
Return (1) -- set the return value
End
Commit tran -- commit a transaction if no error occurs
End

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.