Stored Procedure in Oracle giving error PLS-00428

user3112130

I am trying to create the following procedure in oracle:

CREATE OR REPLACE PROCEDURE SPBILL (SPCLIENT_ID VARCHAR2) 
AS
BEGIN
   SELECT C.CLIENT_NAME, B.ROOM_ID, R.ROOM_COST, T.TREAT_NAME, T.TREAT_COST, (ROOM_COST*(B_END_DATE-B_START_DATE)+TREAT_COST) AS INVOICE
   FROM CLIENTS C, ROOMS R, TREATMENTS T, BOOKING B, PRESCRIPTION P
   WHERE C.CLIENT_ID=B.CLIENT_ID
   AND R.ROOM_ID=B.ROOM_ID
   AND B.CLIENT_ID=P.CLIENT_ID
   AND P.TREAT_ID=T.TREAT_ID
   AND C.CLIENT_ID=SPCLIENT_ID;
END SPBILL;

I am getting a "Procedure created with compilation errors" and the errors is PLS-00428, which required an INTO satement, but i do not understand why and where do i need it as my sql statement works just the way i want it without the procedure. But i need to create a procedure so i can call a specific client id and only recieve their data as an output.

Rajesh Chamarthi

When you are running the SQL directly using a client (SQL Plus or SQL Developer or Toad) , data is returned to the client. When you run the same query inside PL/SQL, you need to tell oracle what to do with that data. Usually programs store the output in Pl/SQL variables for further processing.

https://docs.oracle.com/cd/B19306_01/appdev.102/b14261/selectinto_statement.htm

So, in your case, you might need something along these lines..

CREATE OR REPLACE PROCEDURE SPBILL (SPCLIENT_ID VARCHAR2) 
AS
  l_client_name clients.client_name%type;
  l_room_id rooms.room_id%type;
  ...
  l_invoice number(5,2);
BEGIN
   SELECT C.CLIENT_NAME, B.ROOM_ID, R.ROOM_COST, T.TREAT_NAME, T.TREAT_COST, (ROOM_COST*(B_END_DATE-B_START_DATE)+TREAT_COST)
   into l_client_name, l_room_id...l_invoice
   FROM CLIENTS C, ROOMS R, TREATMENTS T, BOOKING B, PRESCRIPTION P
   WHERE C.CLIENT_ID=B.CLIENT_ID
   AND R.ROOM_ID=B.ROOM_ID
   AND B.CLIENT_ID=P.CLIENT_ID
   AND P.TREAT_ID=T.TREAT_ID
   AND C.CLIENT_ID=SPCLIENT_ID;

   --further processing here based on variables above.
   dbms_output.put_line(l_invoice);
END SPBILL;

Once you compile without errors, you can run the procedure..

set serveroutput on; 
SPBILL(100); 

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Stored procedure in Oracle using Select Command and Variables giving error

From Dev

Oracle Stored Procedure PLS-00306: wrong number or types of arguments

From Dev

Error in stored procedure execution in oracle

From Dev

Error compiling Oracle stored procedure

From Dev

No data found error in oracle stored procedure

From Dev

Error when calling Oracle stored procedure

From Dev

error when execution an Oracle stored procedure

From Dev

Call MySQL Stored Procedure in a C application giving an error

From Dev

Call MySQL Stored Procedure in a C application giving an error

From Dev

Stored procedure terminating without giving error when executing from program

From Dev

Call Oracle Stored Procedure with Char Out Parameter errors with PLS-00306: wrong number or types of arguments in call

From Dev

Stored procedure error PLS-00201: identifier 'UTL_HTTP' must be declared

From Dev

PHP and oracle Stored procedure

From Dev

Oracle stored delete procedure

From Dev

Oracle Stored Procedure problems

From Dev

Oracle Stored Procedure and Cursor

From Dev

Oracle : PLS-00103 occur on procedure with condition

From Dev

JPA and ORACLE function: error when call a stored procedure using NamedNativeQuery

From Dev

ORA-06502, ORA-06512 Oracle stored procedure error

From Dev

Error in executing Oracle Stored Procedure using C#

From Dev

ORACLE PL/SQL Stored Procedure Insert and execute error

From Dev

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

From Dev

stored procedure for select query not giving output

From Dev

PLS-00103 error with anonymous procedure

From Dev

procedure declaration error (PLS-00488)

From Dev

error PLS-00103 while running a procedure

From Dev

Stored Procedure Error

From Dev

Aginity Stored Procedure Error

From Dev

Mysql Stored Procedure Error

Related Related

  1. 1

    Stored procedure in Oracle using Select Command and Variables giving error

  2. 2

    Oracle Stored Procedure PLS-00306: wrong number or types of arguments

  3. 3

    Error in stored procedure execution in oracle

  4. 4

    Error compiling Oracle stored procedure

  5. 5

    No data found error in oracle stored procedure

  6. 6

    Error when calling Oracle stored procedure

  7. 7

    error when execution an Oracle stored procedure

  8. 8

    Call MySQL Stored Procedure in a C application giving an error

  9. 9

    Call MySQL Stored Procedure in a C application giving an error

  10. 10

    Stored procedure terminating without giving error when executing from program

  11. 11

    Call Oracle Stored Procedure with Char Out Parameter errors with PLS-00306: wrong number or types of arguments in call

  12. 12

    Stored procedure error PLS-00201: identifier 'UTL_HTTP' must be declared

  13. 13

    PHP and oracle Stored procedure

  14. 14

    Oracle stored delete procedure

  15. 15

    Oracle Stored Procedure problems

  16. 16

    Oracle Stored Procedure and Cursor

  17. 17

    Oracle : PLS-00103 occur on procedure with condition

  18. 18

    JPA and ORACLE function: error when call a stored procedure using NamedNativeQuery

  19. 19

    ORA-06502, ORA-06512 Oracle stored procedure error

  20. 20

    Error in executing Oracle Stored Procedure using C#

  21. 21

    ORACLE PL/SQL Stored Procedure Insert and execute error

  22. 22

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

  23. 23

    stored procedure for select query not giving output

  24. 24

    PLS-00103 error with anonymous procedure

  25. 25

    procedure declaration error (PLS-00488)

  26. 26

    error PLS-00103 while running a procedure

  27. 27

    Stored Procedure Error

  28. 28

    Aginity Stored Procedure Error

  29. 29

    Mysql Stored Procedure Error

HotTag

Archive