title: error signaled in parallel query server P000 ORA-01722: invalid number
body: <p>I am getting the error: </p>
  
  <pre><code>error signaled in parallel query server P000
  ORA-01722: invalid number
  </code></pre>
  
  <p>while executing the code</p>
  
  <p>There is a cursor that fetches the values from the table</p>
  
  <pre><code>   /* VALIDATE MANDATORY CFA FIELDS START */
     CURSOR c_cfa_fields IS
        select storage_col_name,
               view_col_name
          from cfa_attrib
         where group_id    = 150
           and value_req   = 'Y'
         order by display_seq;
     ---
     TYPE cfa_fields_tbl IS TABLE OF c_cfa_fields%ROWTYPE;
     cfa_fields_rec      cfa_fields_tbl;
     /* VALIDATE MANDATORY CFA FIELDS END */
  </code></pre>
  
  <p>I then fetch the cursor:</p>
  
  <pre><code>  OPEN c_cfa_fields;
     FETCH c_cfa_fields BULK COLLECT INTO cfa_fields_rec;
     CLOSE c_cfa_fields;
     ---
     IF cfa_fields_rec.COUNT &gt; 0 THEN -- Skip if no mandatory CFA Field exists for the GROUP_ID
        FOR i IN 1 .. cfa_fields_rec.COUNT
        LOOP
           L_val_query := 'INSERT /*+ APPEND  NOLOGGING PARALLEL */ INTO dmf_val_error_log' || CHR(10) ||
                          'SELECT /*+ PARALLEL (s,50) */ ' || CHR(10) ||
                          '        ''' || I_TABLE_NAME || ''', -- error_table ' || CHR(10) ||
                          '        ''STORE='' || s.store || ''; GROUP_ID='' || s.group_id, -- pk_value' || CHR(10) ||
                          '        ''' || cfa_fields_rec(i).storage_col_name || ''', -- error_column' || CHR(10) ||
                          '        ''' || cfa_fields_rec(i).storage_col_name || '='' || ' ||
                             'NVL(s.'|| cfa_fields_rec(i).storage_col_name || ',''(null)''), -- error_value' || CHR(10) ||
                          '        ''' || cfa_fields_rec(i).view_col_name || ' (' ||
                             cfa_fields_rec(i).storage_col_name || ') cannot be NULL'', -- error_desc' || CHR(10) ||
                          '        SYSDATE  -- error_datetime' || CHR(10) ||
                          '  FROM ' || I_TABLE_NAME || ' s' || CHR(10) ||
                          ' WHERE ' || cfa_fields_rec(i).storage_col_name || ' IS NULL';
           ---
           EXECUTE IMMEDIATE L_val_query;
  </code></pre>
  
  <p>One thing I have noticed: 
  If the Datatype of storage_col_name is NUMBER,
  it gives the error. 
  It works fine for VARCHAR2 data type for storage_col_name</p>
  
  <pre><code>STORAGE_COL_NAME    VIEW_COL_NAME
  VARCHAR2_1  LATITUDE
  VARCHAR2_2  LONGITUDE
  VARCHAR2_3  IS_CROSS_DOCK
  VARCHAR2_4  CLEARANCE_STORE
  VARCHAR2_5  CLIMATE
  VARCHAR2_6  DEMOGRAPHY
  NUMBER_11   DEFAULT_WH
  </code></pre>