Is there a way to pass into a PL function that is called to give a default value and how do I work with it, the rest of the inserted values?
CREATE TABLE tokensStore (
id SERIAL PRIMARY KEY,
users INTEGER REFERENCES users(id),
genDate timestamp with time zone NOT NULL DEFAULT now(),
expDate timestamp with time zone NOT NULL DEFAULT now() + interval '24 hours',
token char(30) NOT NULL DEFAULT tokenGenerator(%%%INSERTED VALUES%%%)
);
and also I'm not sure this is a proper way to do this, I don't know if I should allow the NULL value and make a trigger that generates the value for the token.
The thing is that I don't want to allow null values in that column. And I also want to make Inserts with returning value token something like
INSERT tokensStore(user) VALUES (1) RETURNING token;
If anyone has good references on this It would be Highly appreciated.