2

I have tried to create view type_of_the_house_view but it doesn't work. What could be the matter?

// the code is written on PostgreSQL

  create view real_property_and_seller_view
    as select (real_property.seller_id,
                     house_id,
                     cost,
                     floor,
                     square,
           surname,
           name,
           phone_number)
     from real_property left join seller
 on (real_property.seller_id = seller.seller_id);
2
  • 1
    but it doesn't work ... I can speculate about what looks wrong, but if you tell us the exact error message it would be helpful. Commented May 13, 2018 at 13:21
  • ERROR: column "row" has pseudo-type record Commented May 13, 2018 at 13:22

1 Answer 1

1

You are over-using parentheses:

create view real_property_and_seller_view as
    select rp.seller_id, house_id, cost, floor, square,
           surname, name, phone_number
    from real_property rp left join
         seller s
         on rp.seller_id = s.seller_id;

You should also qualify all column names in the referenced in the query. I might guess:

create view real_property_and_seller_view as
    select rp.seller_id, rp.house_id, rp.cost, rp.floor, rp.square,
           s.surname, s.name, s.phone_number
    from real_property rp left join
         seller s
         on rp.seller_id = s.seller_id;

The error is a little hard to explain. When you use parentheses, the columns create a tuple, which is also called a record in Postgres. This is not allowed for a view.

Sign up to request clarification or add additional context in comments.

Comments

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.