在 oracle sql 开发人员中使用 Pl/sql

Using Pl/sql In oracle sql developer

我正在尝试使用 PL/SQL Oracle 开发人员从 table 检索信息,我发现我的编码没有任何问题,任何人都可以帮助这个错误如下:

Error starting at line : 88 in command -
DECLARE 
        ArtId VARCHAR(50);
        BookingDate DATE;
BEGIN
        SELECT T.ArtistName, B.BookingDate COUNT(t.ArtistId) AS Perfomance_Date
        INTO ArtId, BookingDate
        FROM Artists T, Bookings B, Event E
        WHERE T.ArtistId = B.ArtistId 
        AND E.EventId = B.EventId
        AND E.EventId = 1001;

        DBMS_OUTPUT.PUT_LINE ('ARTIST NAME : ' || ArtName);
        DBMS_OUTPUT.PUT_LINE ('BOOKING DATE : ' || BookingDate);

END;
Error report -
ORA-06550: line 5, column 49:
PL/SQL: ORA-00923: FROM keyword not found where expected
ORA-06550: line 5, column 9:
PL/SQL: SQL Statement ignored
06550. 00000 -  "line %s, column %s:\n%s"
*Cause:    Usually a PL/SQL compilation error.

下面是我用来从 :

检索信息的 tables
CREATE TABLE Event
(
EventId INT NOT NULL PRIMARY KEY, 
EventName VARCHAR (50),
EventRate DECIMAL
);

INSERT INTO Event (EventId, EventName, EventRate)
VALUES (1001, 'Open Air Comedy Festrival', 300.00)
      INSERT INTO Event (EventId, EventName, EventRate)
VALUES (1002, 'Mountain Side Music Festival', 280.00);
       INSERT INTO Event (EventId, EventName, EventRate)
VALUES(1003, 'Beach Music Festival', 195.00);

CREATE TABLE Artists
(
ArtistId INT NOT NULL PRIMARY KEY,
ArtistName VARCHAR (50),
ArtistEmail VARCHAR (80)
);

INSERT INTO Artists(ArtistId, ArtistName, ArtistEmail)
VALUES ( 101, 'Max Trillion', 'maxt@isat.com');
       INSERT INTO Artists(ArtistId, ArtistName, ArtistEmail)
VALUES( 102, 'Music Mayhem', 'mayhem@ymail.com');
       INSERT INTO Artists(ArtistId, ArtistName, ArtistEmail)
VALUES( 103, 'LOL Man', 'lol@isat.com');

CREATE TABLE Bookings
(
BookingId INT NOT NULL PRIMARY KEY,
BookingDate DATE,
EventId INT NOT NULL,
ArtistId INT NOT NULL,
CONSTRAINT FK_EventId FOREIGN KEY (EventId) REFERENCES Event(EventId),
CONSTRAINT FK_ArtistId FOREIGN KEY (ArtistId) REFERENCES Artists(ArtistId)
);

INSERT INTO Bookings (BookingId, BookingDate, EventId, ArtistId) 
VALUES(1, '15 July 2017', 1002, 101);
INSERT INTO Bookings (BookingId, BookingDate, EventId, ArtistId) 
VALUES(2, '15 July 2017', 1002, 102);
INSERT INTO Bookings (BookingId, BookingDate, EventId, ArtistId) 
VALUES(3, '27 August 2017', 1001, 103);
INSERT INTO Bookings (BookingId, BookingDate, EventId, ArtistId) 
VALUES(4, '30 August 2017', 1003, 101);
INSERT INTO Bookings (BookingId, BookingDate, EventId, ArtistId) 
VALUES(5, '30 August 2017', 1003, 102);

问题从这里开始:

SELECT T.ArtistName, B.BookingDate COUNT(t.ArtistId) AS Perfomance_Date

您可能希望将结果存储在 3 个不同的变量中 -

   T.ArtistName,
   B.BookingDate,
   COUNT(T.ArtistId) as Performace_Date

但是您在 B.BookingDate 之后缺少逗号 (,),在 INTO 子句中也缺少 3rd 变量。

如果我的假设是正确的,完整的代码应该如下所示:

DECLARE 
        ArtId VARCHAR(50);
        BookingDate DATE;
        Performace_Date_Count NUMBER;
BEGIN
        SELECT T.ArtistName, B.BookingDate, COUNT(t.ArtistId) AS Perfomance_Date
        INTO ArtId, BookingDate, Performace_Date_Count
        FROM Artists T, Bookings B, Event E
        WHERE T.ArtistId = B.ArtistId 
        AND E.EventId = B.EventId
        AND E.EventId = 1001;

        DBMS_OUTPUT.PUT_LINE ('ARTIST NAME : ' || ArtName);
        DBMS_OUTPUT.PUT_LINE ('BOOKING DATE : ' || BookingDate);

END;