关于PL/SQL的有关loop循环的问题

本人是学习PL/SQL的小菜鸟,最近遇到一个问题解决不了,还希望各位高手指点一二、
下面是一个关于cursor的语句,但是其中的cursor c3怎么都不进去,而且确定cursor c3是有值的,是应该要用into替换as吗?可是cursorc1 c2都可以进,该声明和定义的都已经做了
CURSOR c1

IS

SELECT RPAD ('LCM_CELL', 20, ' ') format_id,

RPAD (' ', 20, ' ') trx_name,

RPAD (p.pallet_id, 10, ' ') Pallet_id,

RPAD (p.slip_nbr, 11, ' ') cell_rtn_no,

RPAD (p.source_fab, 4, ' ') source_fab,

RPAD (p.DESTINATION, 4, ' ') DESTINATION_fab,

RPAD (q.PALLET_owner, 4, ' ') PALLET_OWNER,

RPAD (q.PALLET_TYPE, 1, ' ') PALLET_TYPE,

RPAD (q.PALLET_ZONE_CODE, 4, ' ') PALLET_ZONE_CODE,
RPAD (q.PALLET_set_CODE, 4, ' ') PALLET_set_CODE,

RPAD (' ', 12, ' ') LCD_SALES_ORDER_NO,

RPAD (COUNT (p.pp_box_id), 4, ' ') cst_count,

RPAD ('N', 1, ' ') FOR_SALE

FROM wp_ppbox p

LEFT OUTER JOIN

wp_paltque q

ON p.pallet_id = q.pallet_id

AND p.fac_id = q.fac_id

AND p.fac_id = i_fac_id

WHERE p.pallet_id = i_pallet_id AND P.STATUS IN (i_status)

GROUP BY p.pallet_id,

p.slip_nbr,

p.source_fab,

p.DESTINATION,

q.PALLET_type,

q.PALLET_owner,

q.pallet_zone_code,

q.pallet_set_code;

CURSOR c2

IS

SELECT RPAD (c.cst_id, 12, ' ') CST_ID,

RPAD (c.CST_ZONE_CODE, 4, ' ') CST_ZONE_CODE,

RPAD (c.cst_SET_CD, 4, ' ') CST_SETTING_CODE,

RPAD (p.PP_BOX_ID, 20, ' ') PP_BOX_ID,

RPAD (p.PP_BOX_ZONE_CODE, 4, ' ') PP_BOX_ZONE_CODE,

RPAD (p.PP_BOX_SET_CD, 4, ' ') PP_BOX_SETTING_CODE,

RPAD (c.LCD_PROD_NBR, 15, ' ') LCD_PRODUCT_ID,

RPAD (c.LCD_GRADE_GRP, 2, ' ') LCD_GRADE_GROUP,

RPAD (c.LCD_OWNER, 4, ' ') LCD_OWNER,

RPAD (c.cst_id, 30, ' ') CARTON_ID,

RPAD (c.ERP_LCD_PROD_ID, 15, ' ') ERP_LCD_PRODUCT_ID,
RPAD (c.LCD_SHIP_DATE, 8, ' ') LCD_SHIPPING_DATE,

RPAD (c.LCD_SHIP_DATE, 8, ' ') IN_WAREHOUSE_DATE,

RPAD (c.LCD_ABN_tft, 4, ' ') cst_ABNORMAL_tft,

RPAD (c.LCD_ABN_cf, 4, ' ') cst_ABNORMAL_cf,

RPAD (c.LCD_ABN_lcd, 4, ' ') cst_ABNORMAL_lcd,

RPAD (c.FORCE_EMPTY, 1, ' ') FORCE_EMPTY,

RPAD (c.cst_qty, 4, ' ') Panel_Count,

RPAD (p.ret_defc, 20, ' ') reserved_5,

RPAD (p.RTN_CMT, 128, ' ') RTN_CMT

FROM WP_PPBOX p

JOIN

wp_cststat c

ON c.cst_id = p.pp_box_id

AND c.fac_id = i_fac_id

AND p.fac_id = c.fac_id

AND p.PALLET_ID = i_pallet_id

AND p.status IN (i_status);

CURSOR c3

IS

-- SELECT 1 A FROM DUAL;

SELECT LPAD (ROWNUM, 4, '0') SLOT_NO,

RPAD (Pnl_id, 12, ' ') PANEL_ID,

RPAD (' ', 1, ' ') PANEL_MODE,

RPAD (lcd_grade, 2, ' ') GRADE,

RPAD (LCD_ABN_TFT, 4, ' ') pnl_ABNORMAL_TFT,

RPAD (LCD_ABN_CF, 4, ' ') pnl_ABNORMAL_CF,

RPAD (LCD_ABN_LCD, 4, ' ') pnl_ABNORMAL_LCD,

RPAD (' ', 12, ' ') LCD_WORK_ORDER,

RPAD (' ', 4, ' ') LCD_SHIPPING_OPERATION,

RPAD (' ', 4, ' ') LCD_REVISION,

RPAD (reserved_1, 20, ' ') reserved_1,

RPAD (reserved_2, 20, ' ') reserved_2,

RPAD (reserved_3, 20, ' ') reserved_3,

RPAD (reserved_4, 20, ' ') reserved_4,

RPAD (reserved_5, 20, ' ') reserved_5,

RPAD (reserved_6, 20, ' ') reserved_6,

RPAD (reserved_7, 20, ' ') reserved_7,

RPAD (reserved_8, 20, ' ') reserved_8,

RPAD (reserved_9, 20, ' ') reserved_9,

RPAD (reserved_10, 20, ' ') reserved_10,

RPAD (tft_polarizer, 16, ' ') tft_polarizer,

RPAD (cf_polarizer, 16, ' ') cf_polarizer,

RPAD (reserved_11, 20, ' ') reserved_11,

RPAD (reserved_12, 20, ' ') reserved_12,

RPAD (reserved_13, 20, ' ') reserved_13,

RPAD (reserved_14, 20, ' ') reserved_14,

RPAD (reserved_15, 20, ' ') reserved_15,

RPAD (reserved_16, 20, ' ') reserved_16,

RPAD (reserved_17, 20, ' ') reserved_17,

RPAD (reserved_18, 20, ' ') reserved_18,

RPAD (reserved_19, 20, ' ') reserved_19,

RPAD (reserved_20, 20, ' ') reserved_20,

RPAD (NVL (reserved_21, ' '), 20, ' ') reserved_21,

RPAD (NVL (reserved_22, ' '), 20, ' ') reserved_22,

RPAD (NVL (reserved_23, ' '), 20, ' ') reserved_23,

RPAD (NVL (reserved_24, ' '), 20, ' ') reserved_24,

RPAD (NVL (reserved_25, ' '), 20, ' ') reserved_25,

RPAD (NVL (reserved_26, ' '), 20, ' ') reserved_26,

RPAD (NVL (reserved_27, ' '), 20, ' ') reserved_27,

RPAD (NVL (reserved_28, ' '), 20, ' ') reserved_28,

RPAD (NVL (reserved_29, ' '), 20, ' ') reserved_29,

RPAD (NVL (reserved_30, ' '), 20, ' ') reserved_30

FROM wp_pnlstat

WHERE cst_id = p_CST_ID AND fac_id = i_fac_id;

BEGIN
FOR r1 IN c1
LOOP
FOR r2 IN c2
LOOP
FOR r3 IN c3
LOOP
INSERT INTO MES_PANEL_send_iwms (FORMAT_ID,
.
.
.
.
.

sql

3个回答

转载自网易博客http://blog.163.com/xuejelly1985@126/blog/static/362103402008823101415479/

1、for--loop循环

declare
 s_no student.sno%type;
cursor c1 is
 select sno from student where sno>'10001';
beg......
答案就在这里:PL/SQL的loop循环
----------------------你好,人类,我是来自CSDN星球的问答机器人小C,以上是依据我对问题的理解给出的答案,如果解决了你的问题,望采纳。

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问