如何创建将更新 table 的存储过程
How to create a stored procedure that will update a table
我正在尝试创建将项目状态从 'D' 更新为 'C' 的存储过程。正如您在下面看到的,我不知道自己在做什么。
请不要建议使用触发器,因为这与问题无关。
create or replace procedure selectallprojects is
begin
update projects
set project_status = 'C'
where project_status = 'D';
select *
from projects
where project_status = 'D'
end;
begin
selectallproject
end;
这些是我在 运行 此代码块时遇到的错误:
Errors: PROCEDURE SELECTALLPROJECTS
Line/Col: 7/5 PL/SQL: SQL Statement ignored
Line/Col: 9/33 PL/SQL: ORA-00933: SQL command not properly ended
Line/Col: 14/1 PLS-00103: Encountered the symbol "END" when expecting one of the following:
:= . ( @ % ;
我做错了什么,我该如何解决?
你可以找到我正在使用的脚本文件here。
UPDATE
没问题,SELECT
错了。以下代码应该有效:
create or replace procedure selectallprojects is
begin
update projects
set project_status = 'C'
where project_status = 'D';
end;
/
begin
selectallprojects;
end;
/
select *
from projects
where project_status = 'D';
我正在尝试创建将项目状态从 'D' 更新为 'C' 的存储过程。正如您在下面看到的,我不知道自己在做什么。
请不要建议使用触发器,因为这与问题无关。
create or replace procedure selectallprojects is
begin
update projects
set project_status = 'C'
where project_status = 'D';
select *
from projects
where project_status = 'D'
end;
begin
selectallproject
end;
这些是我在 运行 此代码块时遇到的错误:
Errors: PROCEDURE SELECTALLPROJECTS
Line/Col: 7/5 PL/SQL: SQL Statement ignored
Line/Col: 9/33 PL/SQL: ORA-00933: SQL command not properly ended
Line/Col: 14/1 PLS-00103: Encountered the symbol "END" when expecting one of the following::= . ( @ % ;
我做错了什么,我该如何解决?
你可以找到我正在使用的脚本文件here。
UPDATE
没问题,SELECT
错了。以下代码应该有效:
create or replace procedure selectallprojects is
begin
update projects
set project_status = 'C'
where project_status = 'D';
end;
/
begin
selectallprojects;
end;
/
select *
from projects
where project_status = 'D';