title: Simple teradata stored procedure
body: <p>The web seems a bit short on working examples for something that should be quite common. A plain Jane example of "Get me some records". This is my first ever Stored proc and all I want is to see some records. Why is that so flipping hard? ;-) I figure that if I can get one example that works, I can tune it from there into something I can really use. This is taken from another example I found on the web. Doesn't compile because CURSOR declaration is a syntax error of some sort. </p>
  
  <pre><code>CREATE PROCEDURE "SCHEMA"."GETRESULTSET (
      IN "p1" VARCHAR(30))
  DYNAMIC RESULT SETS 1
  BEGIN       
  DECLARE CURSOR cur1 WITH RETURN ONLY TO CLIENT FOR 
   SELECT partitioninfo FROM SCHEMA.SessionInfo where username = p1;    
    OPEN cur1;    
  END;
  </code></pre>
  
  <p>Anyway, sure could use a clue. I saw an example where the CURSOR was declared separately from the SQL but then there wasn't an example that showed how to get the variable into the SQL when it was declared as a VARCHAR. The example I am working off of was pretty old but it's the best I could find. </p>