Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/oracle/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
plsql代码中的错误-ORA 06550_Sql_Oracle_Cursor - Fatal编程技术网

plsql代码中的错误-ORA 06550

plsql代码中的错误-ORA 06550,sql,oracle,cursor,Sql,Oracle,Cursor,这可能是件容易的事。但我找不到原因 当我运行上述查询时,我得到一个错误,指出必须声明组件“WEIGHT”(value字段rec_c1.WEIGHT中的字段WEIGHT) Targ表包含以下列-单位、分组、起始、重量、长度、高度您的光标循环中有一个排字错误,该错误会使光标中的列符合条件。您已将循环标识符指定为rec_in,但已为groupin、startin和weight键入rec_c1: DECLARE CURSOR cur IS SELECT dm.fa

这可能是件容易的事。但我找不到原因

当我运行上述查询时,我得到一个错误,指出必须声明组件“WEIGHT”(value字段rec_c1.WEIGHT中的字段WEIGHT)
Targ表包含以下列-单位、分组、起始、重量、长度、高度

您的光标循环中有一个排字错误,该错误会使光标中的列符合条件。您已将循环标识符指定为rec_in,但已为groupin、startin和weight键入rec_c1:

DECLARE  
   CURSOR cur  
   IS  
      SELECT   dm.fash unit, h1.groupin, '01' startin, SUM (h1.weight)  
          FROM tab1 t1 INNER JOIN tab2 h1 ON t1.ALTER = h1.unit  
               INNER JOIN unit dm ON t1.col1 = dm.unit  
         WHERE t1.col1 IN (SELECT col1  
                             FROM tab1  
                            WHERE sw = 1)  
           AND h1.eve = 'Al'  
           AND NOT EXISTS (SELECT 1  
                             FROM tab2  
                            WHERE unit = t1.col1)  
      GROUP BY dm.fash, h1.groupin;  


BEGIN  
   FOR rec_in IN cur  
   LOOP  
      INSERT      /*+append*/INTO targ  
                  (unit, groupin, startin,  
                   weight, length, height  
                  )  
           VALUES (rec_in.unit, rec_c1.groupin, rec_c1.startin,  
                   rec_c1.weight, 4, 5  
                  );  
   END LOOP;  

   COMMIT;  
END;  
/
/

这必须与装置一样进行记录:

BEGIN  
FOR rec_in IN cur  
LOOP  
   INSERT      /*+append*/INTO targ  
               (unit, groupin, startin,  
                weight, length, height  
               )  
        VALUES (rec_in.unit, rec_c1.groupin, rec_c1.startin,  
                rec_c1.weight, 4, 5  
               );  
END LOOP;  

COMMIT;  
END;  

/

我不知道Oracle,但我想您需要命名SUM列,即。
SUM(h1.权重)权重

但是你真的需要光标吗?不能用select进行插入吗

BEGIN  
FOR rec_in IN cur  
LOOP  
   INSERT      /*+append*/INTO targ  
               (unit, groupin, startin,  
                weight, length, height  
               )  
        VALUES (rec_in.unit, rec_in.groupin, rec_in.startin,  
                rec_in.weight, 4, 5  
               );  
END LOOP;  

COMMIT;  
END;  

对不起的。我纠正了这个错误并尝试了,但它给出了相同的错误。非常感谢@jarlh。是,这解决了问题-命名总和列。
INSERT INTO targ  
                  (unit, groupin, startin,  
                   weight, length, height  
                  )
SELECT   dm.fash unit, h1.groupin, '01' startin, SUM (h1.weight)  
          FROM tab1 t1 INNER JOIN tab2 h1 ON t1.ALTER = h1.unit  
               INNER JOIN unit dm ON t1.col1 = dm.unit  
         WHERE t1.col1 IN (SELECT col1  
                             FROM tab1  
                            WHERE sw = 1)  
           AND h1.eve = 'Al'  
           AND NOT EXISTS (SELECT 1  
                             FROM tab2  
                            WHERE unit = t1.col1)  
      GROUP BY dm.fash, h1.groupin;