Hello,
It appears you have other problems than the original question.
First the original question.
Is there a possibility to obtain the next sequence number from the server after inserting a line ?
This SQL:
SELECT nextval('YOUR_SEQUENCE');
but that may cause problems as it will increment the sequence number.
SELECT currval('YOUR_SEQUENCE');
will retrieve the current value.
Now as for the problems stated in the comments, there is not enough information to help there. As earlier stated, don’t know what the trigger
you have is doing. You typically do not need a trigger just to use a sequence.
Do not know what connection type is being used (PostgreSQL/localhost is not a type) - JDBC, ODBC, Native? Going to guess Native since comment mentions "PostgreSQL’.
Don’t know how the forms are set up. Asked for a sample there.
Stated earlier, tested using sequence with form & subform with both Native and JDBC connections and had none of the problems stated. There must be more undisclosed information than what has already been presented.
Edit:
Carried one step further and added a trigger to update the ID vs just a sequence. This did create a problem but nothing of which you have stated. Rather, in the sub form, the linked ‘id’ was always 0
until the master was refreshed and went back to the newly entered record. Then all was OK.
Could overcome this without code. Used two push buttons: one to refresh & one to go to last record.
Again not the problems you have described and didn’t need this with just a serial sequence. No need for trigger in this case.