Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How to prevent user from entering a duplicate batch number?

Consultant IanJan 26 2015 — edited Jan 27 2015

Hello

I need some help with displaying a message to the Oracle APEX 4.2.6.00.03 user. I need to display a message to the user when he/she enters batch number that already exists in the batch table. I have created a Interactive Report that the user can insert, update and delete data from. My challenge is when the user enters a new record in the form fields. My current solution does not work. And I am not sure what I am doing wrong

So far I have created a dynamic action called "Set session value". My aim is to populate P2_BATCH (number data type) with the session value as soon as a value is entered in the Batch Number field. The details of the first dynamic action are as follow:


When

Sequence: 10

Event: Lose Focus

Selection Type: Item(s)

Item(s): P2_BATCH

Condition: is not null

True Actions

Action: Execute PL/SQL Code

Execution Options:
Fire when event result is : True

Fire on page load: no

Stop execution on error: yes

wait for result: yes

Settings:

PL/SQL Code: null;

Page items to submit: P2_BATCH

Page item to return: null

False Actions
None

Advance:
Event Scope: Static

Condition:

Condition Type: Dynamic Action Not Conditional

When I enter 101 in the batch number field then I can see the 101 is inserted in the sessions item value. So it looks like the session value is set correctly.

I then created another dynamic action called "Use session value". My aim is to use this second dynamic action to check for duplicate records in the batch table. If I find a match then I want to display a message. If the batch number does not exist in the table then the user can go ahead and create the batch.

When

Sequence: 20

Event: Change

Selection Type: Item(s)

Item(s): P2_BATCH

Condition: is not null

True Actions

Action: Execute JavaScript Code

Execution Options:
Fire when event result is : True

Fire on page load: no

Settings:

Code: alert('Already exist')

Attached Elements Select Type: Item(s)

Item(s): P2_BATCH


False Actions

None

Advance:
Event Scope: Static

Condition:

Condition Type: Exists (SQL query return at least one row)

Expression 1: select 1 from batch where batch  = :P2_BATCH

When I run the application and enter a batch number that already exist in the batch table then the second dynamic action does not seem to do its job. It is as if the second dynamic action cannot see that the batch number I just entered already exists in the table.

does anyone know what I am doing wrong?

Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 24 2015
Added on Jan 26 2015
7 comments
3,136 views