尝试创建此存储过程时,我收到错误:
PLS-00428:此SELECT语句中需要INTO子句
代码:
CREATE OR REPLACE PROCEDURE FindDb(
P_BookId IN BOOKMASTER.BookId%TYPE,
p_PublisherCode OUT BOOKMASTER.PUBLISHERCODE%TYPE,
p_ISBNCode OUT BOOKMASTER.ISBNCODE%TYPE,
p_BookName OUT BOOKMASTER.BOOKNAME%TYPE,
p_BookType OUT BOOKMASTER.BOOKTYPE%TYPE,
p_BookLevel OUT BOOKMASTER.BOOKLEVEL%TYPE,
p_BookCategory OUT BOOKMASTER.BOOKCATEGORY%TYPE,
p_AuthorNames OUT BOOKMASTER.AUTHORNAMES%TYPE,
p_PublishedYear OUT BOOKMASTER.PUBLISHEDYEAR%TYPE,
p_CostPrice OUT BOOKMASTER.COSTPRICE%TYPE,
p_MRP OUT BOOKMASTER.MRP%TYPE,
p_BookImage OUT BOOKMASTER.BOOKIMAGE%TYPE)
AS
BEGIN
SELECT PUBLISHERCODE, ISBNCODE, BOOKNAME,BOOKTYPE,BOOKLEVEL,BOOKCATEGORY
,AUTHORNAMES,PUBLISHEDYEAR,COSTPRICE,MRP,BOOKIMAGE
FROM BOOKMASTER WHERE BOOKID = p_BookId;
END FindDb;
/
答案 0 :(得分:3)
在Oracle存储过程中,我们必须将SELECT值转换为变量或输出参数。请read the docs。
尝试按以下方式创建存储过程。
CREATE OR REPLACE PROCEDURE finddb (
p_bookid IN bookmaster.bookid%TYPE,
p_publishercode OUT bookmaster.publishercode%TYPE,
p_isbncode OUT bookmaster.isbncode%TYPE,
p_bookname OUT bookmaster.bookname%TYPE,
p_booktype OUT bookmaster.booktype%TYPE,
p_booklevel OUT bookmaster.booklevel%TYPE,
p_bookcategory OUT bookmaster.bookcategory%TYPE,
p_authornames OUT bookmaster.authornames%TYPE,
p_publishedyear OUT bookmaster.publishedyear%TYPE,
p_costprice OUT bookmaster.costprice%TYPE,
p_mrp OUT bookmaster.mrp%TYPE,
p_bookimage OUT bookmaster.bookimage%TYPE
)
AS
BEGIN
SELECT publishercode,
isbncode,
bookname,
booktype,
booklevel,
bookcategory,
authornames,
publishedyear,
costprice,
mrp,
bookimage
INTO p_publishercode,
p_isbncode,
p_bookname,
p_booktype,
p_booklevel,
p_bookcategory,
p_authornames,
p_publishedyear,
p_costprice,
p_mrp,
p_bookimage
FROM bookmaster
WHERE bookid = p_bookid;
END finddb;
/
答案 1 :(得分:1)
看起来您期望Oracle存储过程的工作方式与SQL Server SP相同 - 它们是不同的 - 在Oracle中,您需要选择INTO变量或游标然后对值执行某些操作。如果您只是尝试在SQL Server中选择值,则它不会像那样工作。