【发布时间】:2021-01-27 09:36:05
【问题描述】:
请您帮我在 dBEAVER 中运行/执行 oracle 程序吗? 这是您可以查看输入参数的块 enter image description here
【问题讨论】:
标签: oracle procedure execute dbeaver
请您帮我在 dBEAVER 中运行/执行 oracle 程序吗? 这是您可以查看输入参数的块 enter image description here
【问题讨论】:
标签: oracle procedure execute dbeaver
我发现无法使用光标输出参数执行过程并将其显示在结果网格中。所以我认为除了在匿名块中绑定游标之外别无他法(然后用游标做你需要的)。
CREATE PROCEDURE test_proc(
datemin DATE,
datemax DATE,
RES OUT sys_refcursor
)
AS
BEGIN
OPEN res
FOR SELECT datemin + LEVEL
FROM dual
CONNECT BY LEVEL < datemax - datemin;
END;
DECLARE
l_cur sys_refcursor;
l_datemin DATE;
l_datemax DATE;
l_date date;
BEGIN
l_datemin := to_date(:dmin, 'YYYY-MM-DD');
l_datemax := to_date(:dmax, 'YYYY-MM-DD');
-- execute the procedure
test_proc(l_datemin, l_datemax, l_cur);
-- do something with the cursor, here just print to output
loop
fetch l_cur into l_date;
exit when l_cur%notfound;
dbms_output.put_line(to_char(l_date, 'YYYY-MM-DD'));
end loop;
END;
这种情况看起来更好,返回的光标可以显示在查询网格中并检查它的值(您可能会被问到在执行查询时阻止关闭光标的设置,选择保持光标向上的选项)。
create or replace function test_fun(
datemin DATE,
datemax DATE
) return sys_refcursor
AS
l_res sys_refcursor;
BEGIN
OPEN l_res
FOR SELECT datemin + LEVEL
FROM dual
CONNECT BY LEVEL < datemax - datemin;
RETURN l_res;
END;
SELECT
1 a,
'xyz' b,
test_fun(to_date(:dmin, 'YYYY-MM-DD'), to_date(:dmax, 'YYYY-MM-DD')) c
FROM dual;
【讨论】: