This is a discussion on Help with Store procedure within the MySQL Database forums, part of the Database Forums category; Hi gurus, here is a snippet of the procedure, don't know if mysql support labels as SQL Server and ...
|
|||||||
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
|
|||
|
Hi gurus,
here is a snippet of the procedure, don't know if mysql support labels as SQL Server and Oracle and i can't find more doc about error control in mysql. So if anyone can tell me more hints about this topic i would really appreciate DECLARE error_check INT DEFAULT 0; DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET error_check = 1; START TRANSACTION INSERT INTO child_table (child_id,parent_id) VALUES (1,1); <--- Constraint Error Parent Id does not exits IF error_check = 1 THEN GOTO ERROR_LABEL END IF; <-- not sure about this COMMIT; ERROR_LABEL: IF error_check = 1 THEN ROLLBACK; END IF; |
|
|||
|
On 31 Jan, 12:53, "lala4life" <rafael.ava...@gmail.com> wrote:
> Hi gurus, > here is a snippet of the procedure, don't know if mysql support > labels as SQL Server and Oracle and i can't find more doc about error > control in mysql. So if anyone can tell me more hints about this topic > i would really appreciate > > DECLARE error_check INT DEFAULT 0; > DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET error_check = 1; > > START TRANSACTION > > INSERT INTO child_table (child_id,parent_id) VALUES (1,1); <--- > Constraint Error Parent Id does not exits > IF error_check = 1 THEN GOTO ERROR_LABEL END IF; <-- not sure about > this > > COMMIT; > > ERROR_LABEL: > IF error_check = 1 THEN > ROLLBACK; > END IF; The stuff that you couldn't find in the docs wouldn't be this would it? http://dev.mysql.com/doc/refman/5.1/...-handlers.html |
|
|||
|
On Jan 31, 10:15 am, "Captain Paralytic" <paul_laut...@yahoo.com>
wrote: > On 31 Jan, 12:53, "lala4life" <rafael.ava...@gmail.com> wrote: > > > > > Hi gurus, > > here is a snippet of the procedure, don't know if mysql support > > labels as SQL Server and Oracle and i can't find more doc about error > > control in mysql. So if anyone can tell me more hints about this topic > > i would really appreciate > > > DECLARE error_check INT DEFAULT 0; > > DECLARE CONTINUE HANDLER FOR SQLEXCEPTION SET error_check = 1; > > > START TRANSACTION > > > INSERT INTO child_table (child_id,parent_id) VALUES (1,1); <--- > > Constraint Error Parent Id does not exits > > IF error_check = 1 THEN GOTO ERROR_LABEL END IF; <-- not sure about > > this > > > COMMIT; > > > ERROR_LABEL: > > IF error_check = 1 THEN > > ROLLBACK; > > END IF; > > The stuff that you couldn't find in the docs wouldn't be this would > it?http://dev.mysql.com/doc/refman/5.1/...-handlers.html Is the same that i read. don't say anything about labels. |