![]() | |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
i had a basic question on plsql, if i have a variable as varchar2, containing some text like 'A12345', how do i write a function to make sure that the first char. is the letter 'A' or 'a' and the next five characters are numbers? sorry about asking a basic question, but i'm not the dba here, he recently left and i'm just the web developer having to do this for now. Look in the docs you can find documentation at otn.oracle.com. Look in the |
#3
| |||
| |||
|
#4
| |||
| |||
|
#5
| |||
| |||
|
|
i had a basic question on plsql, if i have a variable as varchar2, containing some text like 'A12345', how do i write a function to make sure that the first char. is the letter 'A' or 'a' and the next five characters are numbers? sorry about asking a basic question, but i'm not the dba here, he recently left and i'm just the web developer having to do this for now. |
#6
| |||
| |||
|
|
This procedure is better. You could use the translate function alone, but the string parameters would make your code long and unwieldy. create function word_fmt (word varchar2) return varchar2 is begin return translate(word, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ0123456789', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXX9999999999' ); end; |
|
if word_fmt('a52132') = 'X99999' then ..... end if; or if translate(word, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVW XYZ0123456789', 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX XXX9999999999') = 'X99999' then .... end if; |
![]() |
| Thread Tools | |
| Display Modes | |
| |