gpt4 book ai didi

scala - 如何在 spark/scala 中编写或调用 -SQL 游标?

转载 作者:行者123 更新时间:2023-12-05 07:29:48 25 4
gpt4 key购买 nike

是否可以在 scala/spark 中编写/调用 Cursor?我想从 spark/scala 代码编写或调用(SQL 游标)游标。

下面是游标(用 SQL 编写),我想从 scala 代码中调用它。

declare
cursor c1 is
select DISTINCT earning_id from CN_TP_EARNINGS_ALL where rownum < 10;
cursor c2(p_Assigned in number) is
select SOURCE_EVENT_PERIOD_ID from CN_TP_EARNINGS_ALL where
earning_id = p_Assigned;

begin
for r1 in c1 loop
dbms_output.put_line('------- start --------');
for r2 in c2(r1.earning_id) loop
dbms_output.put_line(r2.SOURCE_EVENT_PERIOD_ID);
end loop;
dbms_output.put_line('------- end -------');
end loop;
end;

最佳答案

只需使用来自 C1 游标的 SELECT 语句,然后在 Scala 的 for 循环中处理结果集,然后在循环内使用准备好的语句来选择 C2 游标值并再次循环。

关于scala - 如何在 spark/scala 中编写或调用 -SQL 游标?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52591580/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com