I ve created function and trigger as follows:
CREATE OR REPLACE FUNCTION New_Ticket()
RETURNS TRIGGER AS
$$BEGIN
SELECT * FROM Ticket WHERE productID=(SELECT MAX(ticketID) FROM Ticket);
RETURN NEW;
END$$
LANGUAGE PLPGSQL;
CREATE TRIGGER New_TicketTr
AFTER INSERT ON Ticket
FOR EACH ROW execute procedure New_Ticket();
After I do insertion as follows:
INSERT INTO Ticket (ticketID, Problem, Status, Priority,LoggedTime,CustomerID,ProductID) VALUES
(1, 'Cannot play games.', 'open', 1,'2005-05-13 07:15:31.123456789',1,1);
I get ERROR message:ERROR: query has no destination for result data
HINT: If you want to discard the results of a SELECT, use PERFORM instead.
CONTEXT: PL/pgSQL function “new_ticket” line 2 at SQL statement.
Can anyone help me? What is the problem there?
I think the problem is that you are not doing anything with that query. Neither a DML nor returning the result into a variable or record.