Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

checking letters in string PL/SQL

RaivisJan 18 2013 — edited Jan 18 2013
Hi everyone. I have problem.
I have varchar2 field in my form. In this form user write car numer.

Example: 'AB1234'

I have specific rules, that first 2 symbols must be leters 'AA' and other symbols must be numbers....

Can someone tell me is it possible to use statement not between 'A' and 'Z' .....

for example i have code...
declare
letters varchar2(2);
letter1 varchar2(1);
letter2 varchar2(1);
numbers varchar2(4);
leng_numb number;
symb varchar2(1);
begin ... 
.....
letters := substr('AB1234', 1,2);
letter1 := substr(letters,1,1);
letter2 := substr(letters, 2,1);
numbers := substr('AB1234',3);
if letter1 between '0' and '9' then
raise error.... 
elsif letter2 between  '0' and '9' then
raise error...
else
leng_numb :=length(numbers);
for i in 1..leng loop
symb := substr(numbers,i,1);
if symb between 'A' and 'Z' then
raise error....
end if;
end loop;
end;
Help me if i can do this kind of logic.... i need to check if that numbers part in string dosn't contain any leters.... because later i need to do arithmetic functions with this string....
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 15 2013
Added on Jan 18 2013
11 comments
5,839 views