Oracle stored procedure stuck
<p>I'm having a problem with a stored procedure on oracle 11g.</p>

<p>I create this procedure and when I run it on sql developer it gets stuck.
The execution never ends and nothing is printed out.</p>

<p><strong>Procedure:</strong></p>

<pre><code>create or replace PROCEDURE "GET_RECORDS_SP" (CURSOR_ OUT sys_refcursor, PARAM_0 VARCHAR2,PARAM_1 VARCHAR2)
AS
myquery varchar2(255);
  BEGIN  
    DBMS_OUTPUT.enable();
    DBMS_OUTPUT.PUT_LINE(PARAM_0);
    DBMS_OUTPUT.PUT_LINE('-- 1 --');
    CASE
      WHEN PARAM_0 = 'A' THEN 
        DBMS_OUTPUT.PUT_LINE('-- 2 --');
        myquery := 'SELECT * FROM table
               WHERE char_field = ''N'' and date_field is not null';
      WHEN PARAM_0 = 'B' THEN 
        DBMS_OUTPUT.PUT_LINE('-- 3 --');
        myquery:= 'SELECT * FROM table
              WHERE char_field = ''N'' and 
              date_field is not null and
              char_field2 = '''||PARAM_1||'''';
      WHEN PARAM_0 = 'C' THEN 
        DBMS_OUTPUT.PUT_LINE('-- 4 --');
        myquery:= 'SELECT * FROM table 
              WHERE char_field = ''N'' and
              date_field is not null 
              and char_field3 = ''S''';
    END CASE;

  DBMS_OUTPUT.PUT_LINE(myquery);
  OPEN CURSOR_ FOR myquery;
END;
</code></pre>

<p>If I comment the line <code>OPEN CURSOR_ FOR myquery;</code> it prints <code>A</code>, <code>-- 1 --</code>, <code>-- 2 --</code> and the query <code>SELECT * FROM table WHERE char_field = ''N'' and date_field is not null</code> (passing <code>A</code> in <code>PARAM_0</code>).</p>

<p>If I try to run the query <code>SELECT * FROM table WHERE char_field = ''N'' and date_field is not null</code> alone, it executes and give me the results.</p>

<p>Can anyone tell me what is wrong in my procedure?
Thanks!</p>