我有一个插入语句,我需要从中返回一个参数以便以后使用。我遇到一个奇怪的错误,似乎无法找到解决方案。任何人都可以阐明它吗?
set define off; variable videoID number; insert into VM_VIDEO (VIDEO_ID, ...) values (SEQ_VMMIGVIDEO_ID.NEXTVAL, ...) returning VIDEO_ID into :videoID; insert into IMAGES (IMAGE_ID, ...) values (SEQ_IMAGE_ID.NEXTVAL, ...); update VM_VIDEO set THUMB_IMAGE_ID = SEQ_IMAGE_ID.CURRVAL where VIDEO_ID = :videoID;
错误:
Error starting at line 4 in command: insert into VM_VIDEO (VIDEO_ID, ...) values (SEQ_VMMIGVIDEO_ID.NEXTVAL, ...) returning VIDEO_ID into :videoID Error report: SQL Error: Not all return parameters registered
您需要将其放入PL / SQL块中:
declare videoID number; begin insert into VM_VIDEO (VIDEO_ID, ...) values (SEQ_VMMIGVIDEO_ID.NEXTVAL, ...) returning VIDEO_ID into videoID; insert into IMAGES (IMAGE_ID, ...) values (SEQ_IMAGE_ID.NEXTVAL, ...); update VM_VIDEO set THUMB_IMAGE_ID = SEQ_IMAGE_ID.CURRVAL where VIDEO_ID = videoID; end;