您好我的任务是打印打印客户的一周时间表。我制作了这个程序来打印客户的时间表。我无法弄清楚我所犯的错误,有人可以帮我打印客户的时间表一周。
*Name Null Type
------------- -------- ------------
CUSTOMER_T_ID NOT NULL NUMBER(38)
C_DATE NOT NULL TIMESTAMP(6)
TIMETABLE_ID NOT NULL NUMBER(38)
CUSTOMER_ID NOT NULL NUMBER(38)
Desc Timetable
Name Null Type
----------------- -------- ------------
TIMETABLE_ID NOT NULL NUMBER(38)
CLASS_DAY NOT NULL VARCHAR2(50)
CLASS_LOCATION NOT NULL VARCHAR2(50)
CLASS_START_TIME NOT NULL TIMESTAMP(6)
CLASS_FINISH_TIME NOT NULL TIMESTAMP(6)
WORKOUT_CLASS_ID NOT NULL NUMBER(38)
TRAINER_ID NOT NULL NUMBER(38)
Desc Customers
Name Null Type
---------------- -------- -------------
CUSTOMER_ID NOT NULL NUMBER(38)
FIRST_NAME NOT NULL VARCHAR2(50)
LAST_NAME NOT NULL VARCHAR2(50)
AGE NOT NULL NUMBER(38)
ADDRESS NOT NULL VARCHAR2(100)
CITY NOT NULL VARCHAR2(50)
MOBILE_PHONE NOT NULL NUMBER(10)
EMAIL VARCHAR2(50)
PICTURE BFILE()
CUSTOMER_TYPE_ID NOT NULL NUMBER(5)
*/
Create or Replace Procedure PrintTimeTable_Procedure
(T_Customer_id number Default null)
As
Begin
FOR aRow IN (Select Cu.Customer_id,Cu.First_Name,CT.CUSTOMER_T_ID,
CT.C_DATE,
CT.TIMETABLE_ID,
CT.CUSTOMER_ID,
T.TIMETABLE_ID,
T.CLASS_DAY,
T.CLASS_LOCATION,
T.CLASS_START_TIME,
T.CLASS_FINISH_TIME,
From Customers Cu, customer_timetable CT, TimeTable T
Where C.Customer_id = CT.CUSTOMER_ID
And CT.TIMETABLE_ID = T.TIMETABLE_ID
and CT.Customer_id = T_Customer_id
LOOP
DBMS_OUTPUT.PUT_LINE('Customer ID: ' || aRow.Cu.EMPLOYEE_ID);
DBMS_OUTPUT.PUT_LINE('NAME: ' || aRow.Cu.FIRST_NAME);
DBMS_OUTPUT.PUT_LINE('DATE: ' || aRow.CT.C_DATE);
DBMS_OUTPUT.PUT_LINE('DAY: ' || aRow.T.Class_Day);
DBMS_OUTPUT.PUT_LINE('CLASS LOCATION: ' || aRow.T.CLASS_LOCATION);
DBMS_OUTPUT.PUT_LINE('START TIME: ' || aRow.T.CLASS_START_TIME);
DBMS_OUTPUT.PUT_LINE('FINISH TIME: ' || aRow.T.CLASS_FINISH_TIME);
END LOOP;
PROMPT PrintTimeTable_Procedure Procedure
Execute PrintTimeTable_Procedure;
/*C:\Users\venkatesh\AppData\Roaming\SQL Developer\VENKYPROsql
Error(12,14): PL/SQL: SQL Statement ignored
Error(20,22): PL/SQL: ORA-00936: missing expression
Error(27,66): PLS-00103: Encountered the symbol ";" when expecting one of the following: loop
Error(34,12): PLS-00103: Encountered the symbol "end-of-file" when expecting one of the following: end not pragma final instantiable order overriding static member constructor map */
答案 0 :(得分:0)
您错过了程序声明的结尾
END PrintTimeTable_Procedure:
并且您不能在pl / sql过程中使用PROMPT。它需要更像
Create or replace your procedure.... as
Begin
....
End;
/
BEGIN
PrintTimeTable_Procedure;
END;
从SQLPlus或IDE中运行它是不是很清楚?
答案 1 :(得分:0)
您错过了程序的END,并且您没有为记录字段使用正确的名称。您不需要在字段名称中包含表别名(即aRow.Cu.FIRST_NAME错误,该字段名为FIRST_NAME,aRow.FIRST_NAME)。此外,我无法看到任何名为EMPLOYEE_ID
的字段CREATE OR REPLACE PROCEDURE PrintTimeTable_Procedure (T_Customer_id NUMBER DEFAULT NULL) AS
BEGIN
FOR aRow IN (SELECT Cu.Customer_id,
Cu.First_Name,
CT.CUSTOMER_T_ID,
CT.C_DATE,
CT.TIMETABLE_ID,
CT.CUSTOMER_ID,
T.TIMETABLE_ID,
T.CLASS_DAY,
T.CLASS_LOCATION,
T.CLASS_START_TIME,
T.CLASS_FINISH_TIME,
FROM Customers Cu, customer_timetable CT, TimeTable T
WHERE C.Customer_id = CT.CUSTOMER_ID
AND CT.TIMETABLE_ID = T.TIMETABLE_ID
AND CT.Customer_id = T_Customer_id) LOOP
DBMS_OUTPUT.PUT_LINE('Customer ID: ' || aRow.CUSTOMER_ID);
DBMS_OUTPUT.PUT_LINE('NAME: ' || aRow.FIRST_NAME);
DBMS_OUTPUT.PUT_LINE('DATE: ' || aRow.C_DATE);
DBMS_OUTPUT.PUT_LINE('DAY: ' || aRow.Class_Day);
DBMS_OUTPUT.PUT_LINE('CLASS LOCATION: ' || aRow.CLASS_LOCATION);
DBMS_OUTPUT.PUT_LINE('START TIME: ' || aRow.CLASS_START_TIME);
DBMS_OUTPUT.PUT_LINE('FINISH TIME: ' || aRow.CLASS_FINISH_TIME);
END LOOP;
END;
/
PROMPT PrintTimeTable_Procedure Procedure
BEGIN
PrintTimeTable_Procedure;
END;
/