SELECT setval('sequence',(SELECT max(id) FROM table)) INTO variable; insert into table values(variable, ..., ...); ?
Will this be transactional? Cause, they say that setval is a command that its transactional. Using this way i
don´t will need to use a sequence anymore. Is that correct?