title: Use WITH inside a stored procedure
body: <p>I am trying to use a <code>WITH</code> in a stored procedure, but am failing. My assumption was that I could use <code>WITH</code> as part of my <code>SELECT</code> statement; now I am unsure as to if it is possible and I'm doing it wrong, or if it is not possible.</p>
  
  <p>I've tried both of the following, but both throw an error on the <code>AS</code> following the <code>WITH</code></p>
  
  <p>Attempt 1:</p>
  
  <pre><code>SET p_temp = (
      WITH
          temp (id) AS (
              SELECT orgs.id
              FROM orgstruct.tOrgs AS orgs
              WHERE orgs.prnt = p_OrgID
          )
      SELECT 1
      FROM temp
      FETCH FIRST 1 ROWS ONLY);
  </code></pre>
  
  <p>Attempt 2:</p>
  
  <pre><code>IF EXISTS (
          WITH
              temp (id) AS (
                  SELECT orgs.id
                  FROM orgstruct.tOrgs AS orgs
                  WHERE orgs.prnt = p_OrgID
              )
          SELECT 1
          FROM temp) THEN
      SET p_temp = 1;
  END IF;
  </code></pre>
  
  <p>Is the only solution to create a view for each <code>WITH</code> I would normally want to use?</p>