mysql-stored procedures (a)

2011-10-25  来源:本站原创  分类:Database  人气:68 

The following shows the definition of a simple example of a stored procedure

mysql-stored procedures (a)

delimiter $ $

create procedure delete_user (in uid in)

begin

delete from user where

end

delimiter;

delimiter $ $

Redefine the terminator, before the ";", is now "$$", because we habitually use a semicolon as a terminator, so a lot of experience in the stored procedure used a semi-colon, semicolon, or if the terminator, then it no way to define the stored procedure, so we must change the terminator.

Of course, can not necessarily "$$". other symbols

Note: The definition of the stored procedure to re-re-defined as the terminator ";", otherwise we will execute this statement

call delete_user (2) $ $

A detail not noticed, even if we did not define the terminator ";", the stored procedure is executed successfully, and the result is right. Even if the description, the stored procedure in the implementation process is ";" as a terminator. And are not user-defined terminator effect.

If there is something wrong, please advise masters you. (*^__^*) Hee hee ... ...

相关文章
  • Turn: mysql stored procedures Detailed 2010-11-30

    Detailed MySQL stored procedure Transfer: http://www.owe-love.com/myspace/?action=show&id=187 1. Stored Procedures Introduction We used to manipulate the database language SQL statement executed when the need first compiled and then executed, and sto

  • mysql stored procedures Study Notes - Error Handling Collection 2011-01-06

    mysql stored procedures Study Notes - Error handling collection definition: DECLARE {CONTINUE | EXIT} HANDLER FOR {SQLSTATE sqlstate_code | MySQL error code | condition_name} handler_actions The definition includes: · Handler type (CONTINUE, EXIT) /

  • (R) MySQL stored procedures, and include transactions, parameters, nested calls, cursor, loop, etc. 2011-04-20

    MySQL stored procedures, and include services, parameters, nested calls, cursors, loops, etc., read the MySQL stored procedures, and include services, parameters, nested calls, cursors, loops, etc., view plaincopy to clipboardprint? Drop procedure if

  • MySQL stored procedures and functions of the difference 2011-06-23

    Transfer: http://www.gooseeker.com/cn/node/Fuller/2010061201 MySQL stored procedures and functions of the difference MySQL stored procedure (stored procedure) and functions (stored function) collectively referred to as stored routines, whether stored

  • Question: Navicat for MySQL stored procedures on 2010-08-13

    Navicat for MySQL How to create a stored procedure with parameters? Not use the console to write stored procedures, but through the interface that creates a stored procedure to create! Solution! Thank you!

  • php + mysql stored procedures in the performance of a simple comparison 2011-05-03

    PHP + MYSQL, using MYSQL stored procedure is actually very good, but will make it fast, efficient, Here, the summary of the usage of MYSQL it under review, the use of the PDO 1 / / Do not use stored procedures $ Time = microtime (TRUE); $ Mem = memor

  • Mysql stored procedures first test, record what 2011-07-19

    Today the first trial mysql stored procedure, and eventually found not suitable for my needs, stored procedures can not pass an array as a parameter ... The following snippet of code to record what the learning process: delimiter // drop procedure if

  • mysql stored procedures first test 2011-01-10

    Since 5.0, mysql support stored procedures, nothing small test last weekend, in this preliminary record their own learning process. C:\Users\michael>mysql -uroot Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 2 S

  • Create MySql Stored Procedures 2011-05-10

    Summary: Let me talk about the advantages of database stored procedures. Then MySql, for example, instructions to create a stored procedure method. Body: <1> create a database stored procedure has at least two distinct advantages: 1 SQL statements s

  • First test mysql stored procedures, records about 2011-07-19

    Today the first trial mysql stored procedure, and eventually found not suitable for my needs, stored procedures can not pass an array as a parameter ... The following snippet of code to record what the learning process: delimiter // drop procedure if

  • mysql stored procedures commonly used commands 2011-10-25

    See the wording on the stored procedure: http://trinea.iteye.com/blog/977141 mysql Chinese reference documentation see: http://dl.iteye.com/topics/download/82db8bb1-7c55-3e74-9f56-de5f8e004ded 0, stored procedures need to pay attention to the best an

  • MySQL stored procedures error handling knowledge ☞ Summary 2011-03-29

    MySQL error code: http://dev.mysql.com/doc/refman/5.0/en/error-messages-server.html MySQL stored procedure of Error Handling: http://hideto.iteye.com/blog/194416

  • MYSQL stored procedures examples 2011-04-09

    Stored procedure: Create a stored procedure: CREATE PROCEDURE sp_name ([proc_parameter [,...]]) [Characteristic ...] routine_body CREATE FUNCTION sp_name ([func_parameter [,...]]) RETURNS type [Characteristic ...] routine_body proc_parameter: [IN | O

  • (R) MySQL stored procedures in the use of split strings method 2011-04-20

    Existing section of the string, such as apple, banana, orange, pears, grape, take it in accordance with a comma (,) split into: apple banana orange pears grape and then use the where in () method to check. 1, the specific function: # Function: func_s

  • mysql stored procedures exception handling 2010-07-02

    When the insert fails, I hope that is recorded in a log file, Here need to create a primary key table, and a foreign key table, we are using Innodb, so check the associated foreign key is turned on, when I insert a table outside key Non-primary key t

  • mysql stored procedures, functions, triggers an example 2010-12-02

    1, split a string with "|||" interval stored procedure. create PROCEDURE sp_InsertJoKe (lastindex int) begin declare i int; set i = 1; while (i <lastindex) do begin declare a varchar (4000); declare p int; declare part1 varchar (4000); set a

  • MYSQL stored procedures, use variable names instead of table name 2011-03-31

    In MySQL variable names instead of the surface need to use the prepare. (Note: prepare in mysql 5.0 or later only support.) CREATE DEFINER = `offsee `@`%` PROCEDURE` pro_terminal_report `() BEGIN declare _version int; set _version = 'terminal_log'; s

  • MySQL stored procedures: Delete the table with like conditions 2011-04-14

    delimiter // CREATE PROCEDURE drop_table_like(IN table_prefix varchar(64), IN username varchar(256)) BEGIN DECLARE tname varchar(128) default ''; DECLARE not_found INT DEFAULT 0; DECLARE cur_tnames cursor FOR SELECT table_name FROM INFORMATION_SCHEMA

  • Chinese garbled mysql stored procedures (not the parameters garbled) 2011-09-23

    This is wrong This is part of the sql. Which name is dynamic read, did not issue a specific code to the Internet to find a long time, did not find a solution. show variables like 'char%'; My results are as follows: character_set_client utf8 character

  • mysql stored procedures, implementation of the dynamic sql statement 2010-09-12

    DROP PROCEDURE IF EXISTS sp_name; create procedure sp_name() begin declare _userid,_id,no_rs int; declare sitelist CURSOR for select userid,id from eop_site ; DECLARE CONTINUE HANDLER FOR NOT FOUND SET no_rs=1; open sitelist; repeat fetch sitelist in