Hash103
Hash103

Reputation: 1

PostgreSQL syntax error at end of input not sure why

    CREATE OR REPLACE FUNCTION customerGetByLargestSpend()
RETURNS TABLE(
    customerID INTEGER,
        firstName VARCHAR(20),
        Surname VARCHAR(40),
        totalBookings BIGINT,
        totalSpend Numeric
)

ERROR:  syntax error at end of input
LINE 8: )
         ^
SQL state: 42601
Character: 213

Not sure why this is happening.Any help would be very appreciated. thanks

Upvotes: 0

Views: 114

Answers (1)

Bohemian
Bohemian

Reputation: 424983

The function is defined to return a row set, but does not return anything.

The parser expects to find something that returns rows, eg a select statement.

For example:

CREATE OR REPLACE FUNCTION customerGetByLargestSpend()
RETURNS TABLE(
customerID INTEGER,
    firstName VARCHAR(20),
    Surname VARCHAR(40),
    totalBookings BIGINT,
    totalSpend Numeric
)
AS $$ SELECT .... $$
LANGUAGE SQL

Upvotes: 1

Related Questions