Validation for form Items on client side--- Urgent Plz... [message #153309] |
Sat, 31 December 2005 03:37 ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
srinivasocp
Messages: 91 Registered: December 2005 Location: INDIA
|
Member |
|
|
Dear All,
I am new to this site and I really appreciate the great job
of this site, helping to share lots of Ideas.
I have a basic doubt. Please help me to clear this.
I am using Forms 6i.
-> I have created a form on dept table.The fields are
deptno,dname,location based on DB table dept with columns
deptno number(3),dname varchar2(10),location varchar2(10)
So from my form even if i am entering the value, for example
XYZ for deptno field and 12345 for dname and 3333 for location
field, these values are getting stored in the dept table.
-> Now I don't want this to happen. I want to do a validation(client side validation)
that prevents the user from entering the character value for
deptno and number's for character fields i.e., dname and
location here.
How can I do this? What Form triggers shuld I have to use? Where shuld I write the
code?
Any help will be higly appreciated.
Thnx & Regards
Srini...
|
|
|
Re: Validation for form Items on client side--- Urgent Plz... [message #153311 is a reply to message #153309] |
Sat, 31 December 2005 04:20 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
RJ.Zijlstra
Messages: 104 Registered: December 2005 Location: Netherlands - IJmuiden
|
Senior Member |
|
|
To validate the item:
Use your mouse and select the desired item. Use right button, go to smart triggers, take 'WHEN-VALIDATE-ITEM'.
On record level use when-validate-record.
Also check the help for the following triggers:
key-commit
pre-insert
pre-update
HTH,
Happy New Year
|
|
|
|
Re: Validation for form Items on client side--- Urgent Plz... [message #153327 is a reply to message #153312] |
Sat, 31 December 2005 10:44 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
RJ.Zijlstra
Messages: 104 Registered: December 2005 Location: Netherlands - IJmuiden
|
Senior Member |
|
|
Ok, startfrom here: The item is (let say) 'Block.Itemname'
Get to the property of Block.Itemname. Put the item data type to numeric. Run the form; put a character in ( 'a' ) Hit enter:
status bar will give you FRM-50016. And the item will not accept the value.
If you want something more user friendly:
For a number field
In the When Validate Trigger:
Declare
v_number number;
Begin
v_number := to_number( :Block.itemname );
Exception
when others then
**** Put your user friendly message here
raise from_trigger_failure;
End;
For a characterfield:
This is a bit difficult to answer, because I don't know if a character value of '123' is considerd a number or not in your application.
If this is considered a number then:
Declare
v_number number;
Begin
v_number := to_number( :Block.itemname );
-- it goes ok, so it is a number, which is not allowed
**** Put your user friendly message here
raise from_trigger_failure;
Exception
when others then
--ok, it raised an error, so it cannot be a number: continue
null;
End;
Ok, HTH
Regards and a heppay New Year
(Of to the champagne and fireworks now...)
|
|
|
|
Re: Validation for form Items on client side--- Urgent Plz... [message #153539 is a reply to message #153344] |
Tue, 03 January 2006 01:21 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
RJ.Zijlstra
Messages: 104 Registered: December 2005 Location: Netherlands - IJmuiden
|
Senior Member |
|
|
Good morning Srini,
(At least here it is morning).
Well, after you try this, sit back and think for a while about what we have done now.
We deleted a record and then put an exact copy back...
Don't you think this is a bit funny, to say the least? I answered your question and this will work, but of course -as another member already pointed out- it is not a good solution at all.
I think you must seriously rethink your strategy / table design / and maybe your database design.
If you cannot change it then instead of a pre-update trigger, you might look at the WHEN-VALIDATE-RECORD trigger. Study the docs and I'm sure you will see very quick that this could be a better solution.
Also you might look at the table itself and -if possible- make a pre-update trigger on the table itself. If you got a DUP_VAL_ON_INDEX exception, you might consider raising an application-error you can gracefully use in the form to display a message. Look up the PRAGMA EXCEPTION_INIT text in the HELP.
I think this will be a much better solution, because now you made sure that any update from any source ( not only from your form ) will be validated. I always try to validate on the db level, and you can tons of docs on the net why to do this.
Hope to have given you some usefull points,
(And ask again if nec.!)
Regards,
Rob Zijlstra
|
|
|
|
Re: Validation for form Items on client side--- Urgent Plz... [message #153876 is a reply to message #153872] |
Wed, 04 January 2006 10:10 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
srinivasocp
Messages: 91 Registered: December 2005 Location: INDIA
|
Member |
|
|
Hi Guys,
Please help me to find a solution for my posting. It is simple
and many of u might have come through a situation like this.
I am again repeating my QUest..
I am using Forms 6i.
-> I have created a form on dept table.The fields are
deptno,dname,location based on DB table dept with columns
deptno number(3),dname varchar2(10),location varchar2(10)
So from my form even if i am entering the value, for example
XYZ for deptno field and 12345 for dname and 3333 for location
field, these values are getting stored in the dept table.
-> Now I don't want this to happen. I want to do a validation(client side validation)
that prevents the user from entering the character value for
deptno and number's for character fields i.e., dname and
location here.
How can I do this? What Form triggers shuld I have to use?
Where shuld I write the
code?
Any help will be higly appreciated.
Thnx & Regards
Srini...
|
|
|
Re: Validation for form Items on client side--- Urgent Plz... [message #153878 is a reply to message #153872] |
Wed, 04 January 2006 10:23 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) ![Go to next message Go to next message](/forum/theme/orafaq/images/down.png) |
RJ.Zijlstra
Messages: 104 Registered: December 2005 Location: Netherlands - IJmuiden
|
Senior Member |
|
|
Srini,
Whoops....
The mess starting with 'Good morning' had nothing to do with your original qst. I'm sorry for the confusion.
Did you test :
Declare
v_number number;
Begin
v_number := to_number( :Block.itemname );
Exception
when others then
**** Put your user friendly message here
raise from_trigger_failure;
End;
etc?
Regards and once more sorry , stupid of me
Rob Zijlstra
|
|
|
|
|
|
|
|
Re: Validation for form Items on client side--- Urgent Plz... [message #155946 is a reply to message #155917] |
Thu, 19 January 2006 16:39 ![Go to previous message Go to previous message](/forum/theme/orafaq/images/up.png) |
![](/forum/images/custom_avatars/67467.jpg) |
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
These are basic questions so I suggest that you work your way through the Forms demonstration white paper which can found on or from http://www.oracle.com/technology/sample_code/products/forms/index.html.
If you want a field to be numeric define it as a number field in the property sheet of the Forms Builder. Alternatively you can make the department field be based on an LOV which is a list of the available departments or a fixed list that you create. There are no triggers for you to write to do this.
Please remember that Forms Does the Work FOR you. This is not VB where you have to do all the work yourself.
Try that and then come back with your next issue - but in this thread, don't start another one.
David
|
|
|