【问题标题】:Using savepoint, commit and rollback in oracle apex在 oracle apex 中使用保存点、提交和回滚
【发布时间】:2022-01-19 19:53:12
【问题描述】:

我曾经使用 SQL*Plus 工具,并且在我的工作中使用了保存点和回滚。现在我正在使用 oracle apex,当我尝试使用保存点时,系统会向我显示此错误:

难道我做错了什么?还是系统不再支持这些命令?如果有,有没有相同功能的替代品?

【问题讨论】:

  • 这能回答你的问题吗? stackoverflow.com/questions/68069245/…
  • 谢谢,但我可以从哪里访问“功能配置”?可以给我发图片吗?
  • 这是在实例级别配置的,而不是在工作区级别。在那个引用的问题中解释了如何设置它。可能是您没有执行此操作的权限。这是在您自己的本地安装上还是在像 apex.oracle.com 这样的托管实例上?
  • 我没有使用任何本地安装的软件,我使用的是 apex.oracle.com 网站,那是托管实例吗?我是 Apex 新手,所以我没有太多信息。
  • 是托管的 - 实例管理由 oracle 完成。对于像这样的大规模实例,自动提交是打开的

标签: sql oracle oracle-apex apex


【解决方案1】:

如何在匿名 pl/sql 块中使用 COMMIT/ROLLBACK/SAVEPOINT 的示例。这可以在 apex 的 SQL Workshop 中完成。

  1. 创建帮助表
create table commits_test (col1 VARCHAR2(10));
  1. 创建帮助函数以返回帮助表的行数
create or replace function commits_test_rows RETURN NUMBER
AS
  l_rows NUMBER;
BEGIN
  SELECT COUNT(*) INTO l_rows FROM commits_test;
  RETURN l_rows;
END commits_test_rows;
/
  1. 显示 COMMIT/ROLLBACK 和 SAVEPOINT 的代码。
DECLARE
BEGIN
  DELETE FROM commits_test;
  INSERT INTO commits_test (col1) VALUES ('FIRST');
  COMMIT;
  dbms_output.put_line('after first: '||commits_test_rows());
  INSERT INTO commits_test (col1) VALUES ('SECOND');
  ROLLBACK;
  dbms_output.put_line('after second: '||commits_test_rows());
  INSERT INTO commits_test (col1) VALUES ('THIRD');
  SAVEPOINT third;
  dbms_output.put_line('after third: '||commits_test_rows());
  INSERT INTO commits_test (col1) VALUES ('FOURTH');
  dbms_output.put_line('after fourth: '||commits_test_rows());
  ROLLBACK TO SAVEPOINT third;
  dbms_output.put_line('after ROLLBACK TO SAVEPOINT third: '||commits_test_rows());
END;
/

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-07-23
    • 2018-04-30
    • 1970-01-01
    • 2020-02-24
    • 2011-04-23
    • 2021-09-05
    • 2016-12-05
    • 2022-11-10
    相关资源
    最近更新 更多