我正在编写一个过程,我需要检查我的select查询是否返回了空记录。(在此示例中是否没有x,y工具架)
我该怎么做呢?
我试过这个:
temp shelves.loadability%TYPE := NULL;
BEGIN
select loadability into temp from shelves where rownumber = x and columnnumber = y;
IF temp IS NOT NULL THEN
/* do something when it's not empty */
ELSE
/* do the other thing when it's empty */
END IF;
但是if的第二个分支永远不会起作用...
编辑:
哦,太简单了.
temp shelves.loadability%TYPE;
BEGIN
select count(*) into temp from shelves where rownumber = x and columnnumber = y;
IF temp != 0 THEN
/* do something when it's not empty */
ELSE
/* do the other thing when it's empty */
END IF;
END;
https://stackoverflow.com/questions/5955025
复制相似问题