tags:

views:

398

answers:

3

Hi, we are using oracle forms... we have to protect (or) block a text item field from special charecters. like ( !@#$%^&*) please send some guidences.... thanks in advance...

Regards, Vijay

+1  A: 

When your text box as some entered text you got to have a function that validates all input.

On that function you have a range off invalid values. That range is made in ASCII.

rpf
Thanks, Is there any inbuild functions available in Oracle to do this? Or else we have to sit and write a function for this functionality.Regards,Vijay
+2  A: 

You can use format mask property like 999.99

Bigballs
+2  A: 

Which version of forms?

Brute force method:

v_prohibited_chars VARCHAR2(100) := '!@#$%^&*';
v_result           VARCHAR2(4000);
...
-- strip prohibited characters
v_result := TRANSLATE(:form_field,'A'||v_prohibited_chars,'A');

-- if anything was stripped, lengths will differ
IF LENGTH(:form_field) <> LENGTH(v_result) THEN
  error...
END IF

If I understand your comment correctly, you want to be able to filter the special character(s) out of the form field?

The above code does that, and places the result in v_result. So, if you have an input value of 'ABC#DEF#', and your filter mask is '!@#$%^&*', then after executing TRANSLATE your result will be 'ABCDEF'. You can then reassign this value to your form field. If you just want to silently strip the character, you can skip the LENGTH checking and simply assign the output of TRANSLATE back to your form field:

:form_field := TRANSLATE(:form_field,'A'||v_prohibited_chars,'A');

What TRANSLATE does is check the characters in the first parameter against the characters in the second parameter. When it finds a match, it translates that character into the corresponding character in the third parameter. If no corresponding characters exist in the third parameter for one in the second, then the character is translated to NULL. If a character does not appear in the second parameter, it remains unchanged. So, the character 'A' is translated to 'A', and all of the other characters in the mask are translated to NULL. The third parameter cannot be NULL, hence the dummy translation of 'A' to 'A'.

DCookie
Thanks, We have to write a code to filter a special character which occures anywhere in the actual text..all characters will change example, 'JI345LP#' or 'AB#CD' there is no proper sequence...in this case how to get the length of the field by using translate... please guide us...Thanks again.
Modified my answer to address your comment.
DCookie