Advertisement
rfv123

Q23747835 - SQL -retrieve-variable-from-stored-proc

Jan 27th, 2017
514
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 0.96 KB | None | 0 0
  1. DELIMITER $$
  2.  
  3. USE `testmysql_startapp`$$
  4.  
  5. DROP PROCEDURE IF EXISTS `demoSpInOutSqlVars`$$
  6.  
  7. CREATE PROCEDURE `demoSpInOutSqlVars`(IN     pInput_Param  INT, /* PHP Variable will bind to this*/  
  8.                                       /* --- */  
  9.                                       INOUT  pInOut_Param  INT, /* SQL User variable that will be read and set by mysql */
  10.                                       OUT    pOut_Param    INT)
  11.  BEGIN
  12.     /*
  13.      * Pass the full names of SQL User Variable for these parameters. e.g. @varInOutParam
  14.      * These 'SQL user variables names' are the variables that Mysql will use for:
  15.      *    1) finding values
  16.      *    2) storing results
  17.      *
  18.      * It is similar to 'variable variables' in PHP ;-/  
  19.      */
  20.     SET pInOut_Param      := ABS(pInput_Param) + ABS(pInOut_Param); /* always positive sum  */
  21.     SET pOut_Param        := ABS(pInput_Param) * -3;                /* always negative * 3  */
  22. END$$
  23.  
  24. DELIMITER ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement