I am newbie here. I have a little problem while developing Oracle Application.
I am using Oracle Forms 6i Release 2 with Oracle Database 10g (10.2) on Windows XP Professinal.
I am calculating ID for the Bank using following queries
Select (max(nvl(Bank_ID, 0)+1) into :Bank_ID from Bank;
It is working fine but it does not displays it or displays it wrongly
in the Oracle Form field named "Bank_ID" type "Number",
when I used it in the "WHEN NEW Record Instance" at Block Level.
At Form Level, I have used "When New Form instance" trigger
where I have used "Execute Query;" and "Last_Record;".
When I have used the above conditions then it displays the New Record No e.g. 4 at the beginning of record e.g. 1 instead of displaying 1.
All I want is to display this record no when I press the next record buton from the default menu bar, at this point it must populate the bank_id field with this new record no and go to next text field of form.
"MAX + 1" might cause problems in multi-user environment, because two (or more) users might fetch the same value. If there's any kind of "uniqueness" (unique index, primary key) applied to the BANK_ID column, an error would be raised. Therefore, perhaps you could consider use of SEQUENCES instead.
As of your question: WHEN-NEW-RECORD-INSTANCE trigger should, probably, be WHEN-CREATE-RECORD one.