oracle-databasedynamiccursorora-00936

Oracle Dynamic Cursor - ORA-00936 missing expression


I need to use a dynamic cursor in my procedure which receive values from another cursor. When I run this procedure I got ORA-00936 missing expression. I put this select from cursor into dbms_output to see it is correct and it was.

This is the code :

BEGIN
    OPEN dsa_tables;
    LOOP
        FETCH dsa_tables INTO
            v_owner,
            v_table_name,
            v_column_name,
            v_comments,
            v_tech_date;
        EXIT WHEN dsa_tables%notfound;
        v_table_all := dbms_assert.sql_object_name(v_owner
                                                   || '.'
                                                   || v_table_name);
     -- with this cursor is the problem    
        OPEN count_date FOR ' SELECT '
                            || v_column_name
                               || ','
                                  || ' COUNT('
                                     || v_column_name
                                        || ') FROM '
                                           ||v_table_all
                                           || ' GROUP BY '
                                           || v_column_name;
    LOOP
        FETCH count_date INTO
            v_date,
            v_count;
     EXIT WHEN count_date%notfound;      
            
    END LOOP;        
        CLOSE count_date; 
        
        
    END LOOP;

    CLOSE dsa_tables;
END;
/

Solution

  • I've already checked it and there is no NULL im this column.