创建无参数过程
Create a parameterless procedure
我正在尝试创建一个无参数过程,用于从 table 中获取列并对其进行一些修改并将其粘贴到另一个 table 中。但我收到以下错误:
程序DEMO编译
LINE/COL ERROR
--------- -------------------------------------------------------------
4/2 PL/SQL: SQL Statement ignored
8/10 PLS-00403: expression 'NET.NETSALARY' cannot be used as an INTO-target of a SELECT/FETCH statement
8/24 PL/SQL: ORA-00904: : invalid identifier
错误:检查编译器日志
我在 sql 中使用的代码是:
create or replace procedure "DEMO"
as
begin
case when comm is null then 0.9*grosssalary
when comm<500 then 0.85*grosssalary
else 0.8*grosssalary end
into net.netsalary from (select salary+comm as grossSalary,comm from
employee) ;
end ;
/
我正在尝试将数据插入 table net 的列 netsalary。
请指出我哪里出错了?
提前致谢。
语法是
CREATE OR REPLACE PROCEDURE demo
AS
BEGIN
INSERT INTO net (netsalary)
SELECT CASE
WHEN comm IS NULL THEN 0.9 * grosssalary
WHEN comm < 500 THEN 0.85 * grosssalary
ELSE 0.8 * grosssalary
END
FROM (SELECT salary + comm AS grossSalary, comm FROM employee);
END;
但这不会有多大用处。您插入的行数与 employee
table 中的行数一样多,但您插入的只是 netsalary
值 - 您甚至不知道它属于谁。
不知道 table 的描述,很难猜出你真正想做什么。
- 插入?可能缺少员工编号(或任何列名)
- 更新?这是完全不同的命令
我正在尝试创建一个无参数过程,用于从 table 中获取列并对其进行一些修改并将其粘贴到另一个 table 中。但我收到以下错误: 程序DEMO编译
LINE/COL ERROR
--------- -------------------------------------------------------------
4/2 PL/SQL: SQL Statement ignored
8/10 PLS-00403: expression 'NET.NETSALARY' cannot be used as an INTO-target of a SELECT/FETCH statement
8/24 PL/SQL: ORA-00904: : invalid identifier
错误:检查编译器日志
我在 sql 中使用的代码是:
create or replace procedure "DEMO"
as
begin
case when comm is null then 0.9*grosssalary
when comm<500 then 0.85*grosssalary
else 0.8*grosssalary end
into net.netsalary from (select salary+comm as grossSalary,comm from
employee) ;
end ;
/
我正在尝试将数据插入 table net 的列 netsalary。 请指出我哪里出错了? 提前致谢。
语法是
CREATE OR REPLACE PROCEDURE demo
AS
BEGIN
INSERT INTO net (netsalary)
SELECT CASE
WHEN comm IS NULL THEN 0.9 * grosssalary
WHEN comm < 500 THEN 0.85 * grosssalary
ELSE 0.8 * grosssalary
END
FROM (SELECT salary + comm AS grossSalary, comm FROM employee);
END;
但这不会有多大用处。您插入的行数与 employee
table 中的行数一样多,但您插入的只是 netsalary
值 - 您甚至不知道它属于谁。
不知道 table 的描述,很难猜出你真正想做什么。
- 插入?可能缺少员工编号(或任何列名)
- 更新?这是完全不同的命令