java调用oracle函数 5
写一个java程序,该程序调用了oracle中一个函数,该函数完成的功能是根据雇员的姓名,返回该雇员的上级领导人的姓名。请完成该java程序和函数程序,在java中输出该...
写一个java程序,该程序调用了oracle中一个函数,该函数完成的功能是根据雇员的姓名,返回该雇员的上级领导人的姓名。请完成该java程序和函数程序,在java中输出该领导人。
展开
3个回答
展开全部
CREATE OR REPLACE FUNCTION COPY_PAPER (input_paper_id in number)
RETURN INTEGER -- return value type (0: error,1:)
IS
copy_paper_name VARCHAR(512);
copy_paper_id NUMBER(7) := 0;
BEGIN
BEGIN
SELECT PAPER_NAME INTO copy_paper_name
FROM test_paper
WHERE paper_id = input_paper_id;
select seq_paper.nextval into copy_paper_id from dual;
INSERT INTO test_paper (paper_id, paper_name) values (copy_paper_id, copy_paper_name);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RETURN(0);
END;
DECLARE CURSOR copy_question_cur IS
SELECT content
FROM question
WHERE PAPER_ID = input_paper_id;
BEGIN
FOR RC_RECORD IN copy_question_cur LOOP
IF RC_RECORD.content IS NULL THEN
BEGIN
ROLLBACK;
RETURN(1);
END;
ELSE
INSERT INTO question (q_id, paper_id, content) VALUES (seq_question.nextval, copy_paper_id , RC_RECORD.content);
END IF;
END LOOP;
commit;
return(1);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RETURN(0);
END;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RETURN(0);
END;
RETURN INTEGER -- return value type (0: error,1:)
IS
copy_paper_name VARCHAR(512);
copy_paper_id NUMBER(7) := 0;
BEGIN
BEGIN
SELECT PAPER_NAME INTO copy_paper_name
FROM test_paper
WHERE paper_id = input_paper_id;
select seq_paper.nextval into copy_paper_id from dual;
INSERT INTO test_paper (paper_id, paper_name) values (copy_paper_id, copy_paper_name);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RETURN(0);
END;
DECLARE CURSOR copy_question_cur IS
SELECT content
FROM question
WHERE PAPER_ID = input_paper_id;
BEGIN
FOR RC_RECORD IN copy_question_cur LOOP
IF RC_RECORD.content IS NULL THEN
BEGIN
ROLLBACK;
RETURN(1);
END;
ELSE
INSERT INTO question (q_id, paper_id, content) VALUES (seq_question.nextval, copy_paper_id , RC_RECORD.content);
END IF;
END LOOP;
commit;
return(1);
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RETURN(0);
END;
EXCEPTION
WHEN OTHERS THEN
ROLLBACK;
RETURN(0);
END;
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
老老实实写存储过程 输入输出参数
追问
我要是会写还问什么啊……
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询