I am using PostgreSQL for my Codeigniter website. I am using grocery crud for add, edit and delete operations. While doing an edit or add, I want to rename an uploaded file
The previously obtained value of a sequence is accessed with the currval() function.
But that will only return a value if nextval() has been called before that.
There is absolutely no way of "peeking" at the next value of a sequence without actually obtaining it.
But your question is unclear. If you call nextval() before doing the insert, you can use that value in the insert. Or even better, use currval() in your insert statement:
select nextval('my_sequence') ...
... do some stuff with the obtained value
insert into my_table(id, filename)
values (currval('my_sequence'), 'some_valid_filename');