在oracle中选择一个计数到变量中

发布于 2024-11-30 00:50:38 字数 251 浏览 1 评论 0原文

嗨,我今天一直在尝试这个,但没有任何运气。这个存储过程不起作用:(

CREATE OR REPLACE PROCEDURE LEAD_PURGE(closed IN DATE,
oprtr IN INTEGER,
leadscount OUT INTEGER)

is
BEGIN

SELECT COUNT(*) FROM LEADS_DELETED INTO leadscount;

COMMIT;
END LEAD_PURGE;

Hi I have been trying this today and haven't had any luck. this stored procedure does not work :(

CREATE OR REPLACE PROCEDURE LEAD_PURGE(closed IN DATE,
oprtr IN INTEGER,
leadscount OUT INTEGER)

is
BEGIN

SELECT COUNT(*) FROM LEADS_DELETED INTO leadscount;

COMMIT;
END LEAD_PURGE;

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

葬シ愛 2024-12-07 00:50:38

INTO 子句放错了位置。应该是:

SELECT COUNT(*) INTO leadscount FROM LEADS_DELETED

The INTO clause is misplaced. It should be:

SELECT COUNT(*) INTO leadscount FROM LEADS_DELETED
像极了他 2024-12-07 00:50:38

您将 into 放在了错误的位置。

尝试这样的事情,然后从那里继续:

declare
  cnt number;
begin
  select count(*) 
  into cnt
  from leads_delete;
end;

you have the into at the wrong place.

Try something like this instead and proceed from there:

declare
  cnt number;
begin
  select count(*) 
  into cnt
  from leads_delete;
end;
愁以何悠 2024-12-07 00:50:38

另一种方式:

declare
  cnt number;
  cmd varchar2(100);
begin
  cmd := 'select count(*) from leads_delete';
  execute immediate cmd into cnt;
end;

Another way :

declare
  cnt number;
  cmd varchar2(100);
begin
  cmd := 'select count(*) from leads_delete';
  execute immediate cmd into cnt;
end;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文