С无法执行Oracle过程

siv3szwd  于 2023-06-29  发布在  Oracle
关注(0)|答案(1)|浏览(144)

我成功创建了程序:

CREATE OR REPLACE PROCEDURE MY_schema.SDRG (
     ID IN NUMBER,
     COUNTER IN NUMBER
)    IS
   BEGIN
    INSERT INTO newtable_test (ID, COUNTER)
    SELECT doc.ID, doc.TPID
     FROM A.doc;
   END SDRG;

但我得到一个错误
ORA-06550
在Debeaver中调用它时:
开始SDRG; end;
尝试了不同的选项-不起作用

hujrc8aj

hujrc8aj1#

如果你有table:

CREATE TABLE MY_SCHEMA.newtable_test (
  id      VARCHAR2(20),
  counter NUMBER
);

CREATE TABLE A.doc (id, tpid) AS
  SELECT 'abc', 1 FROM DUAL UNION ALL
  SELECT 'abc', 2 FROM DUAL UNION ALL
  SELECT 'def', 1 FROM DUAL;

然后创建程序:

CREATE OR REPLACE PROCEDURE MY_SCHEMA.SDRG (
  ID      IN VARCHAR2,
  COUNTER IN NUMBER
)
IS
BEGIN
    INSERT INTO MY_SCHEMA.newtable_test (ID, COUNTER)
    SELECT doc.ID, doc.TPID FROM A.doc;
END SDRG;
/

然后你可以调用它使用:

BEGIN
  -- The parameters don't do anything and can be random values.
  MY_SCHEMA.SDRG('anything', -42);
END;
/

然后,在调用过程之后,newtable_test将包含:
| 计数器| COUNTER |
| - -----| ------------ |
| 一个| 1 |
| 2| 2 |
| 一个| 1 |
fiddle

相关问题