在PL / SQL函数中,我试图用以下代码编写一个函数:
CREATE OR REPLACE FUNCTION Lib_func(id number,dateToday date)
RETURN number IS retVal number(1);
myBorrower number;
myBook number;
BEGIN
SELECT P.book_id INTO myBook, P.request_id INTO myBorrower
FROM My_requests P
WHERE P.book_id = book_id AND ROWNUM <=1;
//some if condition which updates value of retVal
RETURN retVal;
END;
/
问题是我编译时会导致错误。如果我删除了第二件事(即P.request_id INTO myBorrower),则删除错误。 我不能在一个查询中选择两个东西吗?
答案 0 :(得分:1)
选择多个变量的语法是:
SELECT P.book_id , P.request_id
INTO myBook,myBorrower
FROM My_requests P
WHERE P.book_id = book_id AND ROWNUM <=1;