Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

validate field oracle form

Posted on 2016-10-30
3
Medium Priority
?
71 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 1000 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 1000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

Question has a verified solution.

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

In this blog post, we’ll look at how using thread_statistics can cause high memory usage.
In this article, we’ll look at how to deploy ProxySQL.
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 configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.

722 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