0
Greetings to everyone, I am learning SQL recently and I found myself with this problem inside a database that brought from the internet to do some exercises, but I’m encountering an expression error when trying to create the table below:
**CREATE TABLE Actors(
ActorID BIGSERIAL NOT NULL PRIMARY KEY,
FirstName nvarchar(100) NOT NULL,
FamilyName nvarchar(100) NULL,
FullName AS (FirstName+isnull(' '+FamilyName,'')),
DoB datetime NULL,
DoD datetime NULL,
Gender nvarchar(20) NULL)**
The error is being specifically in the expression "Fullname AS ...", what is wrong with this sentence?
See the documentation "To create a generated column, use the GENERATED ALWAYS AS clause in CREATE TABLE" https://www.postgresql.org/docs/12/ddl-generated-columns.html
– Motta
Fullname GENERATED ALWAYS AS (Firstname|' '||COALESCE(Familyname, '')), try like this
– Motta
Thank you @Motta, I made the modifications and it worked perfectly. I realized that the error was due to the difference of operators between the code I obtained and the one used in postgres, you know if there is any tool that facilitates these integrations between the different SQL Dbs found on the internet today?
– Gláwber Carneiro
No, I don’t know but there must be.
– Motta
I understand, anyway thank you very much!
– Gláwber Carneiro