0
    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

1
  • You need a body for the function . . . you might start with begin/end. Commented Aug 24, 2020 at 0:54

1 Answer 1

1

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
Sign up to request clarification or add additional context in comments.

1 Comment

Doesn't seem to matter what table i put there it still doesn't return anything

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.