【发布时间】:2021-09-09 22:37:52
【问题描述】:
我想创建一个 oracle 函数,将 user_id 作为参数并返回 varchar2,其中包含用户从图书馆拿走但没有返回的书籍的电子邮件文本,我想要的电子邮件文本是:
“你好 ”
你应该归还这本书:
1
这是我到目前为止写的内容
create or replace function get_un_recived_books(param_client_id in number) return varchar2 is
Result varchar2(2000);
cursor cur_book is
select * from hashala natural join client natural join all_books natural join book
where
recived =0
and recived_date is null
and clientid= param_client_id
and taken_date < add_months(trunc(sysdate, 'month'), -3);
begin
FOR b IN cur_book LOOP
Result:= 'book ' || b.book_name;
END LOOP;
return(Result);
end;
我有 3 个问题
-
我怎样才能退回所有的书,而不是最后一本书(比如 c 中的 +=)
-
对于客户端名称,我需要添加另一个光标,可以吗?
-
如何从原始查询中传递值
select get_un_recived_books(!!!ADD HERE THE CLIENID!!!), clientid from hashala natural join client natural join all_books natural join书 在哪里 收到=0 并且 recived_date 为空
and taken_date < add_months(trunc(sysdate, 'month'), -3);
【问题讨论】:
标签: oracle cursor dbfunctions