【发布时间】:2011-01-26 16:36:24
【问题描述】:
谁能告诉我如何将数据从引用游标批量插入到 PL/SQL 中的临时表中?我有一个过程,它的一个参数存储一个结果集,这个结果集将被插入到另一个存储过程中的临时表中。
这是我的示例代码。
CREATE OR REPLACE PROCEDURE get_account_list
(
type_id in account_type.account_type_id%type,
acc_list out sys_refcursor
)
is
begin
open acc_list for
select account_id, account_name, balance
from account
where account_type_id = type_id;
end get_account_list;
CREATE OR REPLACE PROCEDURE proc1
(
...
)
is
accounts sys_refcursor;
begin
get_account_list(1, accounts);
--How to bulk insert data in accounts to a temporary table?
end proc1;
在 SQL Server 中,我可以编写如下代码
CREATE PROCEDURE get_account_list
type_id int
as
select account_id, account_name, balance
from account
where account_type_id = type_id;
CREATE PROCEDURE proc1
(
...
)
as
...
insert into #tmp_data(account_id, account_name, balance)
exec get_account_list 1
如何编写类似于 SQL Server 中的代码?谢谢。
【问题讨论】:
标签: sql sql-server oracle tsql plsql