[英]Pl/sql function and procedure
We need to INSERT or UPDATE data of table consultant_skill , create needed functions, procedures … that accepts consultant id, skill id, and certification status for the task.我们需要插入或更新表 advisor_skill 的数据,创建所需的函数、过程……接受顾问 ID、技能 ID 和任务的认证状态。 The procedure should be user friendly enough to handle all possible errors such as consultant id, skill id do not exist OR certification status is different than 'Y', 'N'.该程序应该足够用户友好以处理所有可能的错误,例如顾问 ID、技能 ID 不存在或认证状态不同于“Y”、“N”。 Make sure to display: Consultant last, first name, skill description and the confirmation of the DML performed (hint: Do not forget to add COMMIT inside the procedure)确保显示:顾问姓氏、名字、技能描述和执行的 DML 确认(提示:不要忘记在程序中添加 COMMIT)
CREATE OR replace PROCEDURE nw (p_c_id NUMBER,
p_s_id NUMBER,
p_certification VARCHAR2)
AS
v_c_id NUMBER := p_c_id;
v_s_id NUMBER := p_s_id;
v_certification VARCHAR2(20);
flag NUMBER(3);
BEGIN
SELECT count(*)
INTO flag
FROM consultant_skill
WHERE c_id = v_c_id
AND skill_id = v_s_id;
dbms_output.Put_line (flag);
IF flag > 0 THEN
UPDATE consultant_skill
SET skill_id = p_s_id,
certification = p_certification
WHERE c_id = v_c_id;
ELSE
dbms_output.Put_line ('bye bye');
END IF;
END;
/
Stuck on update itself.. yet to try insert in else block.. first trying on update part.. dnt know if it is write or not卡在更新本身.. 还没有尝试插入 else 块.. 首先尝试更新部分.. 不知道它是否是写入
But on compiling the samd it is showing ora 00001: unique constraint violated但是在编译 samd 时,它显示 ora 00001:违反了唯一约束
There is a unique key constraint on a combination of columns in the table.表中的列组合有一个唯一键约束。 The update causes more than 1 record in the table to have the same values for this combination of columns.更新会导致表中超过 1 条记录的列组合具有相同的值。 Make sure to ensure the uniqueness of the combination of columns, not only when inserting rows, but also when updating existing rows...确保确保列组合的唯一性,不仅在插入行时,而且在更新现有行时...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.