title: Session based global variable in Postgresql stored procedure?
body: <p>In Oracle's PL/SQL I can create a session based global variable with the package definition.  With Postgresql's PLpg/SQL, it doesn't seem possible since there are no packages, only independent procedures and functions.</p>
  
  <p>Here is the syntax for PL/SQL to declare g_spool_key as a global...</p>
  
  <pre><code>CREATE OR REPLACE PACKAGE tox IS
          g_spool_key spool.key%TYPE := NULL;
          TYPE t_spool IS REF CURSOR RETURN spool%ROWTYPE;
          PROCEDURE begin_spool;
          PROCEDURE into_spool
              (
              in_txt IN spool.txt%TYPE
              );
          PROCEDURE reset_spool;
          FUNCTION end_spool
              RETURN t_spool;
          FUNCTION timestamp
              RETURN VARCHAR2;
      END tox;
  </code></pre>
  
  <p>How would I implement a session based global variable with PLpg/SQL?</p>