-1

尝试创建此存储过程时,出现错误:

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;
/
4

2 回答 2

3

在 Oracle 存储过程中,我们必须将值选择到变量或输出参数中。请阅读文档

尝试以下列方式创建您的存储过程。

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;
/
于 2012-08-26T11:47:40.533 回答
1

It looks like you're expecting an Oracle stored procedure to work the same way as a SQL Server SP - they are different - in Oracle you need to select INTO variables or a cursor then do something with the values. If you're just trying to select the values as in SQL server, it doesn't work like that.

于 2012-08-26T11:31:11.953 回答