MySQL database, involving things, looping add data

Source: Internet
Author: User

1Create PROCEDURE Usp_addboradcast
2(
3inchSubjects VARCHAR ( $),
4inchDetail text,
5 inchUseidint,
6inchIsdeleteint,
7inchConfirm INT,
8inchTime DateTime,
9inchAcceptuserid VARCHAR ( -),
TeninchIsread INT
One
A)
-BEGIN
-DECLARE CNTintdefault0;
theDECLARE Iintdefault0;
-DECLARE GrowthidintDEFAULT0;
-DECLARE T_error INTEGER DEFAULT0;
-DECLARE CONTINUE HANDLER for SQLEXCEPTION SET t_error=1;
+START TRANSACTION;
-
+INSERT into Wc_broadcast (ID, ' subject ', content,userid,isdelete,isconfirm,adddate) VALUES (Subjects,detail,useid, Isdelete,confirm,time);
ASelectLAST_INSERT_ID () into Growthid;
at/*total number of string cuts*/
- //& for Separators
-//Func_get_split_string_tota is a function
-SetCNT = Func_get_split_string_total (Acceptuserid,'&');
-While i<cnt
-Do
inInsert into Wc_broadcastinfo (id,broadcastid,userid,isread) VALUES (growthid,func_get_split_string (Acceptuserid,'&', i), isread);
-Seti = i +1;
toEnd while;
+
-IF T_error =0Then
theCommit
*ELSE
$ROLLBACK;
Panax NotoginsengEND IF;
-
theENDView Code1. Specific functions

View Code

View Code

2. Set the split string

View Code

MySQL database, involving things, looping add data

Related Article

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.