title: Sequence name taken from variable
body: <p><strong>How do I create a new sequence taking its name is from a variable?</strong></p>
  
  <p>Let's take a look at the following example:</p>
  
  <pre><code>CREATE OR REPLACE FUNCTION get_value(_name_part character varying)
    RETURNS INTEGER AS
  $BODY$
  DECLARE
      result bigint;
      sequencename character varying(50);
  BEGIN
      sequencename = CONCAT('constant_part_of_name_', _name_part);
      IF((SELECT CAST(COUNT(*) AS INTEGER) FROM pg_class
          WHERE relname LIKE sequencename) = 0)
      THEN
         CREATE SEQUENCE sequencename --here is the guy this is all about
         MINVALUE 6000000
         INCREMENT BY 1;
      END IF;
      SELECT nextval(sequencename) INTO result;
      RETURN result;
  END;
  $BODY$
    LANGUAGE plpgsql VOLATILE
  </code></pre>
  
  <p>Now, let's say I want a sequence with _name_part = 'Whatever', so I type:</p>
  
  <pre><code>SELECT get_value('Whatever');
  </code></pre>
  
  <p>If sequence <code>constant_part_of_name_Whatever</code> does not exist, my function should create it and take a value; if it exists it should only take a value. However, I created sequence <code>constant_part_of_name_sequencename</code>.</p>
  
  <p>How do I put the value of the variable in sequence definition to make it work?</p>