Advertisement
sathyashrayan

Untitled

Jan 30th, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
MySQL 0.56 KB | None | 0 0
  1. CREATE PROCEDURE  function_example()
  2. BEGIN
  3.  
  4.   DECLARE TwentyYearsAgoToday DATE;
  5.   DECLARE mystring VARCHAR(250);
  6.  
  7.   SET TwentyYearsAgoToday=DATE_SUB(curdate(), interval 20 year);
  8.  
  9.   SET mystring=CONCAT('It was ',TwentyYearsAgoToday,
  10.       ' Sgt Pepper taught the band to play...');
  11.  
  12.   SELECT mystring;
  13.    
  14.   IF (CAST(SUBSTR(version(),1,3) AS DECIMAL(2,1)) <5.0) THEN
  15.     SELECT 'MySQL versions earlier than 5.0 cannot run stored programs - you must be halucinating';
  16.   ELSE
  17.     SELECT 'Thank goodness you are running 5.0 or higher!';  
  18.   END IF;
  19.  
  20. END
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement