我想编写pl/sql将多个值存储到一个变量中,并代表该变量插入在variable中返回的值。但它不起作用-我能做什么?请帮帮我。我的第一个select语句总是返回12-13行,我想存储到其中 vtm
变量。
DECLARE
vtm NUMBER (38);
-- vtm student.gr_number%TYPE;
tab apex_application_global.vc_arr2;
BEGIN
tab := APEX_UTIL.string_to_table (vtm);
SELECT s.gr_number
INTO vtm
FROM student s
LEFT JOIN class_time ct
ON ct.class_id = s.class_id
AND INSTR (s.class_time, ct.class_time) > 0
WHERE UPPER (TRIM (ct.class_id)) = UPPER (TRIM ( :APP_USER))
AND s.gr_number IS NOT NULL
AND is_active_flg = 'Y';
DBMS_OUTPUT.put_line (vtm);
FOR i IN vtm .. tab.COUNT
LOOP
BEGIN
INSERT INTO student_class_attend (gr_number,
student_id,
period_next_day_flg,
attend_date,
period_start_dt,
period_end_dt,
period_duration,
course_name,
class_time,
branch_id,
shift_id,
teacher_id,
class_id,
marked_by,
course_id,
class_uid)
VALUES ( :P7_GR_NUMBER,
:P7_STUDENT_ID,
:P7_PERIOD_NEXT_DAY_FLG,
TO_DATE (UPPER ( :P7_ATTEND_DATE), 'DD-MON-YYYY'),
:P7_PERIOD_START_DT,
:P7_PERIOD_END_DT,
:P7_PERIOD_DURATION,
:P7_COURSE_NAME,
:P7_CLASS_TIME,
:P7_BRANCH_ID,
:P7_SHIFT_ID,
:P7_TEACHER_ID,
:P7_CLASS_ID,
:v_employee_id,
:P7_COURSE_ID,
:P7_CLASS_UID);
EXCEPTION
WHEN NO_DATA_FOUND
THEN
DBMS_OUTPUT.put_line ('there is no data..');
END;
END LOOP;
COMMIT;
END;
请参阅gr images列表,我想将其存储到vtm中,并在这里输入图像描述
1条答案
按热度按时间8zzbczxx1#
长话短说,你做这件事的方式不对,太复杂了。一切都可以在一个sql语句中完成;不需要数组,循环。。。没有什么。