title: Postgresql return text variable value
body: <p>I created a function. Firstly I declared a variable When a result return I want to return variable result but I get an error. How can I solve?</p>
  
  <p>Error</p>
  
  <blockquote>
    <p>ERROR:  column "exist-user" does not exist</p>
  </blockquote>
  
  <pre><code>CREATE OR REPLACE FUNCTION savepromotionadmin(
       IN p_first_name character varying,
       IN p_last_name character varying,
       IN p_gsm character varying,
       IN p_email character varying,
       IN p_password character varying,
       IN p_level smallint)
    RETURNS text AS
  $BODY$      
      DECLARE 
          result text;
          p_user_id bigint=(select id from user where email=p_email and gsm=p_gsm);
          p_check_user bigint=(select id from promotion_admin where email=p_email and gsm=p_gsm);
      BEGIN                   
          IF p_user_id is not null THEN
              IF p_check_user is null THEN            
                  insert into promotion_admin(user_id, first_name, last_name, gsm, email, level, password)
                      values(p_user_id, p_first_name, p_last_name, p_gsm, p_email, p_level, md5(p_password));
                  IF found THEN 
                      result:="added";                    
                      return result;
                  ELSE 
                      result:="error";
                      return result;
                  END IF;             
              ELSE 
                  result:="exist-user";
                  return result;
              END IF; 
          ELSE 
              result:="error";
              return result;
          END IF; 
      END;
  $BODY$
    LANGUAGE plpgsql VOLATILE
    COST 1000;
  </code></pre>