Solved

validate field oracle form

Posted on 2016-10-30
3
58 Views
Last Modified: 2016-11-20
hi i what to validate field based on this condition
If empInd = A and/or  deptControl = Y , then the RegCode may not be "R" or "N".
0
Comment
Question by:chalie001
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 250 total points (awarded by participants)
ID: 41866769
Which is it "and" or "or"? The following would provide records that violate the criteria.-
where empId = 'A' and deptControl = 'Y' and RegCode in ('R','N')
or
where empId = 'A' or deptControl = 'Y' and RegCode in ('R','N')
0
 
LVL 35

Accepted Solution

by:
Mark Geerlings earned 250 total points (awarded by participants)
ID: 41866897
I agree with awking00, that your question isn't clear, so we don't which of the two suggestions he provided is what you need.  I'm guessing that his second suggestion (with "or") is what you need.

If this is an Oracle Forms application, you also need to decide which trigger(s) to put this check in.  One option is the when-validate-record trigger for the block, but that is not my first choice.  I would prefer to put this in a when-validate-item trigger on the last one of these fields that the user normally enters.  To be safe with this approach, you also need logic in the when-validate-item triggers on the other two fields to copy the contents of the next field to itself (to make sure that the later when-validate-item triggers fire if the user ever uses the mouse or a back-tab to go back and change an earlier value).

For example, if the order of these fields in your form is:
1. empId
2. deptControl
3. RegCode

and your block is named "myblock" then the "when-validate-item" triggers on these three fields should look like this:
1. (any validation you need for the empld value) plus: :myblock.deptControl := :myblock.deptControl;
2. (any validation you need for the deptControl values) plus: :myblock.RegCode := :myblock.RegCode;
3. if :myblock.RegCode in ('R','N') and (:myblock.empId = 'A' or :myblock.deptControl = 'Y') then
      display an alert with an error message (or use whatever mechanism you normally use to inform the user of an error) and: raise_form_trigger failure...
  end if;

Of course, you could put this logic in both the pre-insert and pre-update triggers, but I like catching this problem as early as possible (so that's why I don't recommend the "when-validate-record" trigger) and I try to avoid putting this logic into multiple triggers.
1

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Shell script to create broker configuration file using current broker Configuration, solely for purpose of backup on Linux. Script may need to be modified depending on OS-installation. Please deploy and verify the script in a test environment.
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
This video shows how to recover a database from a user managed backup

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question