Created
          June 5, 2018 17:09 
        
      - 
      
- 
        Save dmidlo/bb0c278e835e31f17f59f727182ad761 to your computer and use it in GitHub Desktop. 
    PLSQL - Function - Increment an Integer
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | -- Solution 1 | |
| CREATE OR REPLACE FUNCTION increment(i integer) RETURNS integer as $$ | |
| BEGIN | |
| return i + 1; | |
| END; | |
| $$ LANGUAGE plpgsql; | |
| -- Soluution 2 | |
| CREATE FUNCTION increment(i integer) RETURNS integer | |
| AS 'select $1 + 1;' | |
| LANGUAGE sql; | |
| -- Solution 3 | |
| CREATE FUNCTION increment (IN age integer, OUT integer) | |
| AS 'SELECT age + 1' | |
| LANGUAGE SQL; | |
| -- Solution 4 | |
| CREATE FUNCTION increment(@age INT) { | |
| returns INT as | |
| Begin | |
| return @age + 1; | |
| end; | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment