General
cancel
Showing results for 
Search instead for 
Did you mean: 

make field manditory with digits then the rest can be fluff

SOLVED
Go to solution
Ratzie
Super Advisor

make field manditory with digits then the rest can be fluff

I need to make a field manditory that will allow the first 10 characters to be digits.

I know this can be done, but can I also in the same field, make the first 10 character digits then the user can enter in what the want.

So make the field 25 character length, first 10 is manditory digits. Rest can be what the want to enter.
5 REPLIES
A. Clay Stephenson
Acclaimed Contributor

Re: make field manditory with digits then the rest can be fluff

We can leverage enhanced grep to do what you want. We will use -q since we only care about the exit status:

typeset MYVAR=""
typeset -i STAT=0

read MYVAR # read a value
echo "${MYVAR}" | grep -E -q -e '[0-9]{10}.*'
STAT=${?}
if [[ ${STAT} -eq 0 ]]
then
echo "Ok"
else
echo "Bad"
fi

Man grep for details.
If it ain't broke, I can fix that.
Ratzie
Super Advisor

Re: make field manditory with digits then the rest can be fluff

I need all this validation as part of oracle.
Can all this been done in Oracle?
Indira Aramandla
Honored Contributor
Solution

Re: make field manditory with digits then the rest can be fluff

Hi LHradowy,

You can do this using the length or the substr functions and then compare.

Declare the variable to be varchar2(25).
Eg:-
ws_text varchar2(25)

Then verify if the entered variable value is not less then 10 characters using the length function [eg: length(ws_text < 10 then prompt again].
Or
Verify that substr(ws_test,1,10) should not be null or spaces and then compare if theya re numeric and not alphanumeirc.


IA

Never give up, Keep Trying
Indira Aramandla
Honored Contributor

Re: make field manditory with digits then the rest can be fluff

Hi LHradowy,

Attached is an example to check and see if the user defined text is less than 10 characters and then compare the first 10 characters to be numeric.

The example assumes the user enters text is â 123testingâ . First it will check if the length is less than 10 characters. As it is 10 characters, the script will loop for the first 10 characters to compare for non-numeirc (any other characters other that 0 to 9).


IA
Never give up, Keep Trying
Ratzie
Super Advisor

Re: make field manditory with digits then the rest can be fluff

Thanks