You only need a single regular expression for this task.
A moment's reflection will reveal that a string that must contain at least one letter and at least one digit, and contains ONLY letters and digits, must contain either a letter followed immediately by a digit, or a digit followed immediately by a letter. I won't spend much time on this, since it's a matter of basic logic (not of Oracle SQL programming).
With this insight, the solution becomes clear. You need something like this (using POSIX bracket expressions). Don't forget the anchors ^
and $
to make sure that the entire string is matched, not just a part of it.
with
sample_inputs(string) as (
select 'kjds327' from dual union all
select 'dkfsdsf' from dual union all
select '132564' from dual union all
select 'asjv@3#34342fd' from dual union all
select null from dual union all
select '8B' from dual
)
select string,
case when regexp_like(string,
'^[[:alnum:]]*(([[:alpha:]][[:digit:]])|([[:digit:]][[:alpha:]]))[[:alnum:]]*$')
then 'true' else 'false' end as test_result
from sample_inputs
;
STRING TEST_RESULT
-------------- -----------
kjds327 true
dkfsdsf false
132564 false
asjv@3#34342fd false
false
8B true