Stored Procedure things

Source: Internet
Author: User
Create proc sp_submit_topic
2
3 @ topicid int,
4 @ content varchar (1000 ),
5 @ uid varchar (20 ),
6 @ datetime
7
8
9
10 begin tran -- Development
11
12 insert into tb_re_topic
13 values
14 (
15 @ topicid, @ uid, @ content, @ datetime
16)
17
18 if @ error <> 0 -- indicates an error has occurred.
19 begin
20 rollback tran -- rollback
21 End
22
23 -- if no error occurs, continue to execute
24
25 declare @ value int
26
27 select @ value = to_num from tb_topic where _ id = @ topicid
28
29 update tb_topic set to_num = @ value + 1 where _ id = @ topicid
30
31 if @ error <> 0 -- judge again whether an error has occurred
32 begin
33 rollback tran
34 end
35
36 commit tran -- submit a transaction

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.