如何将程序放入包装中

时间:2018-11-20 22:41:25

标签: plsql

我有一个包裹:

   Length  Distance  sig1Max  sig2Max  sig3Max  sig1Min  sig2Min  sig3Min
0     1.0       0.0      0.2      0.2      0.2      0.2      0.2      0.2
1     2.0    1000.0      0.6      0.7      0.5      0.1      0.3      0.1
2     1.0       0.0      0.4      0.4      0.4      0.4      0.4      0.4
3     1.0       0.0      0.5      0.5      0.5      0.5      0.5      0.5
4     3.0   14000.0      0.8      0.8      0.8      0.6      0.6      0.6

但是我收到错误消息

CREATE OR REPLACE PACKAGE pack1
AS
PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
    CREATE OR REPLACE PROCEDURE details
    IS
    BEGIN
    select *
    FROM table1;
    END details;
END;
/

我是pl / sql的新手,正在尝试学习如何使用包和过程。我知道我的代码可能不正确。告诉我我可以在代码中进行哪些更改以使其正常工作

1 个答案:

答案 0 :(得分:0)

使用

PROCEDURE details

代替

CREATE OR REPLACE PROCEDURE details

https://docs.oracle.com/cd/E11882_01/appdev.112/e25519/packages.htm#LNPLS00905

另一方面, SELECT 语句需要一个 INTO 语句。因此代码可能是:

CREATE OR REPLACE PACKAGE pack1
AS
  PROCEDURE details;
END pack1;
/
CREATE OR REPLACE PACKAGE BODY pack1
AS
  PROCEDURE details
  IS
    l_rec  table1%ROWTYPE;
  BEGIN
    SELECT *
      INTO l_rec
      FROM table1;
  END details;
END pack1;