Error in Oracle stored procedure

前端 未结 2 733
借酒劲吻你
借酒劲吻你 2021-01-29 07:55

When trying to create this stored procedure, I\'m getting an error:

PLS-00428: an INTO clause is expected in this SELECT statement

相关标签:
2条回答
  • 2021-01-29 08:33

    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.

    0 讨论(0)
  • 2021-01-29 08:47

    In Oracle stored procedure we have to SELECT values into either variables or out parameters. Please read the docs.

    Try to create your stored procedure in the following manner.

    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;
    /
    
    0 讨论(0)
提交回复
热议问题