I've searched on stackoverflow and other sources, but haven't found anything useful.
I have to implement a procedure that receives a row (hence "%rowtype") from Reservation table as a parameter.
The table's name is Reservation (as attributes: id_Reservation, id_Room, price, etc).
I created an anonymous block to create the var_reservation variable, which will serve as the parameter to the procedure:
CREATE OR REPLACE PROCEDURE priceCheckout(var_reservation reservation%ROWTYPE) IS
l_idReservation NUMBER;
l_idRoom NUMBER;
prie INT;
date1 DATE;
date2 DATE;
ex exception;
BEGIN
l_idReservation := var_reservation.id_reservation;
(...)
END;
But this is wrong. How can I correct this?
If you do it correctly , it works. Have a look at the following example based on Scott's DEPT
table:
SQL> select * from dept;
DEPTNO DNAME LOC
---------- -------------------- --------------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
SQL> set serveroutput on
Procedure:
SQL> create or replace procedure p_test (var_row dept%rowtype)
2 is
3 l_dname dept.dname%type;
4 begin
5 l_dname := var_row.dname;
6
7 dbms_output.put_line('Department name = ' || l_dname);
8 end;
9 /
Procedure created.
Testing:
SQL> declare
2 l_row dept%rowtype;
3 begin
4 select *
5 into l_row
6 from dept
7 where deptno = 10;
8
9 p_test(l_row);
10 end;
11 /
Department name = ACCOUNTING
PL/SQL procedure successfully completed.
SQL>
Saying that "this is wrong" is difficult to debug. It is not an Oracle error message so... unless you specify what is "this" and, possibly, edit the question and post copy/paste of your own SQL*Plus session (like I did) so that we'd see what you did and how Oracle responded, YOYO.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.