我创建了一个过程来获取多个out参数。但是编译错误来了。我找不到问题。请,我需要一些支持来找到这个问题。。。。。。。。。。。。。
我的密码是,
基本数据库客户、预订和服务表如下所示,
CREATE TABLE CUSTOMER
(CUSTOMER_ID NUMBER(4) NOT NULL,
CUSTOMER_NAME VARCHAR2(10),
GENDER VARCHAR(10),
ADDRESS VARCHAR(50),
EMAIL VARCHAR(50),
DISCOUNT FLOAT(10),
PRIMARY KEY(CUSTOMER_ID)
);
CREATE TABLE SERVICE
(SERVICE_ID NUMBER(4) NOT NULL,
SERVICE_NAME VARCHAR(100),
CHARGE FLOAT(10),
PRIMARY KEY(SERVICE_ID)
);
CREATE TABLE RESERVATION
(RESERVATION_ID NUMBER(4) NOT NULL,
RESERVATION_DATE DATE,
CUSTOMER_ID NUMBER(4),
SERVICE_ID NUMBER(4),
EMPLOYEE_ID NUMBER(4),
PRIMARY KEY(RESERVATION_ID),
FOREIGN KEY (CUSTOMER_ID) REFERENCES CUSTOMER(CUSTOMER_ID),
FOREIGN KEY (SERVICE_ID) REFERENCES SERVICE(SERVICE_ID),
FOREIGN KEY (EMPLOYEE_ID) REFERENCES EMPLOYEE(EMPLOYEE_ID)
);
我需要从预订台、服务台和顾客台取些淡水。我的程序如下,
SET SERVEROUTPUT ON
CREATE OR REPLACE PROCEDURE GET_RECEIPT(
RES_ID IN RESERVATION.RESERVATION_ID%TYPE,
C_NAME OUT CUSTOMER.CUSTOMER_NAME%TYPE,
S_NAME OUT SERVICE.SERVICE_NAME%TYPE,
CHARGE_VAL OUT FLOAT(10),
DISCOUNT_VAL OUT FLOAT(10),
TOTAL_VAL OUT FLOAT(10)
)
AS
BEGIN
SELECT
c.CUSTOMER_NAME AS CUS_NAME INTO C_NAME,
s.SERVICE_NAME AS SER_NAME INTO S_NAME,
s.CHARGE AS CHAR_VAL INTO CHARGE_VAL,
c.DISCOUNT INTO DISCOUNT_VAL,
(s.CHARGE-c.DISCOUNT)AS TOTAL INTO TOTAL_VAL
FROM RESERVATION r LEFT OUTER JOIN CUSTOMER c ON r.CUSTOMER_ID=c.CUSTOMER_ID LEFT OUTER JOIN SERVICE s ON r.SERVICE_ID=s.SERVICE_ID
WHERE r.RESERVATION_ID=RES_ID;
END;
/
但是这个过程无法编译。它说编译失败了。我怎样才能解决这个问题?
1条答案
按热度按时间yvt65v4c1#
修正了,看起来是这样的:
你做错什么了?
参数没有大小(不是
float(10)
但只是float
)在pl/sql中,
select
必须有into
条款-这是你所做的,但在一个错误的方式。应该和我的例子一样。