Error detected. PDF file generation aborted: pg_query(): Query failed: ERROR: lastval is not yet defined in this session