title: SQL Error: ORA-01422: "exact fetch returns more than requested number of rows"
body: <p>I'm having a hard time understanding what's wrong with my SQL-script.
  I get following error message:</p>
  
  <blockquote>
    <p>Fehlerbericht -
    ORA-01422: Exakter Abruf gibt mehr als die angeforderte Zeilenzahl zurück</p>
    
    <p>ORA-06512: in Zeile 58</p>
    
    <blockquote>
      <ol start="1422">
      <li>00000 - "exact fetch returns more than requested number of rows"</li>
      </ol>
    </blockquote>
    
    <p>*Cause:    The number specified in exact fetch is less than the rows returned.</p>
    
    <p>*Action:   Rewrite the query or change number of rows requested</p>
  </blockquote>
  
  <p>The Script:</p>
  
  <pre><code>DECLARE
      obj_exists           NUMBER (38, 0);
      faqqestion           VARCHAR2 (4000 BYTE);
      targetobjid          NUMBER (38, 0);
      translatedtemplate   BOOLEAN;
  BEGIN                                                         -- prints header
      DBMS_OUTPUT.Put_line (
             '"'
          || 'TemplateID'
          || '";"'
          || 'Templatetext'
          || '";"'
          || 'Sprache'
          || '";');
  
      -- iterates over the latest version of all 'de' templates
      FOR latestgermanobjects
          IN (  SELECT vs.sl_vs_id       vsId,
                       vs.sl_obj_id      vsObjId,
                       TRANSM.sl_obj_id  transmObjId,
                       TRANSM.lang,
                       OBJ.sl_obj_id     objObjId,
                       faq.faq_template_id faqTemplateId
                  FROM sl_versionset vs
                       INNER JOIN sl_pp01_trans_meta transM
                           ON VS.sl_obj_id = TRANSM.sl_obj_id
                       INNER JOIN sl_pp01_obj obj
                           ON TRANSM.sl_obj_id = OBJ.sl_obj_id
                       INNER JOIN sl_pp01_faq01 faq
                           ON OBJ.sl_obj_id = FAQ.sl_obj_id
                 WHERE     VS.sl_vs_next IS NULL
                       AND VS.sl_vs_deleted_flag = 0
                       AND VS.sl_vs_state &lt;&gt; 'Deprecated'
                       AND transm.lang = 'de'
                       AND obj.sl_obj_objtyp_id IN (334)
                       AND obj.sl_obj_deleted_flag = 0
              ORDER BY faq.faq_template_id ASC)
      LOOP
          -- iterate over all languages except 'de' to check translation
          FOR singlelanguagecursor
              IN (SELECT sl_metaval_varchar
                    FROM slma_meta_values
                   WHERE sl_metaval_varchar &lt;&gt; 'de' AND slma_metatype_id = 5)
          LOOP
              translatedtemplate := FALSE;
  
              -- iterate over all versions of versionset of the german template to find old tranlsations
              FOR templates
                  IN (  SELECT sl_obj_id
                          FROM sl_versionset
                         WHERE     sl_vs_id = latestgermanobjects.vsid
                               AND sl_vs_deleted_flag = 0
                      ORDER BY sl_obj_id DESC)
              LOOP
                  SELECT COUNT (1)
                    INTO obj_exists
                    FROM sl_pp01_trans_meta
                   WHERE     source_io = templates.sl_obj_id
                         AND lang = singlelanguagecursor.sl_metaval_varchar;
  
                  -- checks, if a translation of the chosen language exists
                  IF obj_exists &gt;= 1
                  THEN
                      translatedtemplate := TRUE;
  
                      -- if only a tranlsation of a older version of the source object exists
                      IF templates.sl_obj_id &lt;&gt; latestgermanobjects.objobjid
                      THEN
                          SELECT sl_obj_id
                            INTO targetobjid
                            FROM sl_pp01_trans_meta
                           WHERE     source_io = templates.sl_obj_id
                                 AND lang =
                                         singlelanguagecursor.sl_metaval_varchar;
  
                          SELECT faq_question
                            INTO faqqestion
                            FROM sl_pp01_templ01
                           WHERE sl_obj_id = targetobjid;
  
                          -- prints 'Template Id', tranlsation of templatetext, language of translation of a transation of a older source object
                          DBMS_OUTPUT.Put_line (
                                 '"'
                              || latestgermanobjects.faqtemplateid
                              || '";"'
                              || faqqestion
                              || '";"'
                              || singlelanguagecursor.sl_metaval_varchar
                              || '";');
                      END IF;
  
                      -- ends loop, after translation has found
                      EXIT;
                  END IF;
              END LOOP;
  
              -- if no translation is available
              IF NOT translatedtemplate
              THEN
                  DBMS_OUTPUT.Put_line (
                         '"'
                      || latestgermanobjects.faqtemplateid
                      || '";"'
                      || 'translation n/a'
                      || '";"'
                      || singlelanguagecursor.sl_metaval_varchar
                      || '";');
              END IF;
          END LOOP;
      END LOOP;
  END;
  </code></pre>
  
  <p>New to SQL and PL/SQL so I would appreciate any help.</p>