这个 PL/SQL 脚本有什么问题吗?
VARIABLE StayWorkflow_Id_max number;
BEGIN
SELECT max(StayWorkflow_Id)+1 into :StayWorkflow_Id_max from MVStayWorkflow;
END;
/
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max, 98485, 129844, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max+1, 66311, 114593, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max+2, 83742, 110157, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max+3, 74421, 98685, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
update SYSQLSequence set nextValue = :StayWorkflow_Id_max+4 where name = '_MVStayWorkflow_auto_';
commit;
给我这个错误:
Error report:
SQL Error: Missing IN or OUT parameter at index:: 1
VARIABLE StayWorkflow_Id_max number;
BEGIN
SELECT max(StayWorkflow_Id)+1 into :StayWorkflow_Id_max from MVStayWorkflow;
END;
/
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max, 98485, 129844, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max+1, 66311, 114593, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max+2, 83742, 110157, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
insert into MVStayWorkflow (StayWorkflow_Id, Stay_Id, Passage_Id,
User_Id, RespUnit_Id, Resource_Id, WorkflowAction, CurrentState,
PreviousState, WorkflowTime, UserStamp, TimeStamp)
values (:StayWorkflow_Id_max+3, 74421, 98685, 1, '', '', 11, 7, 7, to_char(sysdate, 'YYYYMMDD HH:MI:SS'), 1, to_char(sysdate, 'YYYYMMDD HH:MI:SS'));
update SYSQLSequence set nextValue = :StayWorkflow_Id_max+4 where name = '_MVStayWorkflow_auto_';
commit;
Gives me this error:
Error report:
SQL Error: Missing IN or OUT parameter at index:: 1
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您的代码并不是真正的 PL/SQL,而主要是 SQL*plus 脚本(特别是 VARIABLE 既不是 PL/SQL 也不是 SQL)。
为什么不把它变成纯 PL/SQL:
Your code is not really PL/SQL, but mainly a SQL*plus script (in particular VARIABLE is neither PL/SQL nor SQL).
Why don't you make it pure PL/SQL:
正如 wallyk 所指出的,生成 ID 的方式很可疑。通常,它是这样的:
每次只需使用 StayWorkflow_Id.nextval 获取一个新的唯一 id,而不用担心竞争条件
As wallyk has pointed out, the way you are generating your IDs is fishy. Usually, it goes like this:
just use StayWorkflow_Id.nextval to get a new unique id each time, WITHOUT BEING AFRAID OF RACE CONDITIONS
我没有看到任何与错误消息相关的明显错误。
但是,如果 SYSQLSequence 是一个序列,那么直接更新它是不常见的(至少),并且在某些 Oracle 版本中可能不允许。我相信你必须做这样的事情:
更新:好吧,这也有缺陷,所以我把它改掉了。
I don't see anything obviously wrong which relates to the error message.
However, if SYSQLSequence is a sequence, then directly updating it is unusual—at least—and maybe not allowed in certain Oracle versions. I believe you have to do something like this instead:
Update: okay, that's flawed too, so I've scratched it out.