oracle - PL/SQL convert string to number -


i want convert string numbers checksum. string consists of universitycode || ' ' || countrycode || ' ' || studentnumber.

an example string be:

tue nl 123456789

i have convert sample string numbers, , tried to_number function, keep getting error.

this code create (or replace) function in pl/sql:

-- een functie om een international student identification number (isin) te genereren create or replace function generateisin(   countrycode country.code%type,   universitycode university.code%type,   studentnumber varchar2 ) return varchar2   newstudentnumber varchar2(50) := ''; begin -- zorgen voor de goede waarde voordat de checksum beginnen newstudentnumber := universitycode || ' ' || countrycode || ' ' || studentnumber; -- newstudentnumber omzetten naar enkel getallen newstudentnumber := to_number(newstudentnumber); -- spaties weghalen in newstudentnumber newstudentnumber := trim(' ' newstudentnumber);   return newstudentnumber; end; / 

could me problem? lot in advance!

it looks you're supposed convert initial string, may/will contain alphabetic characters, string containing numeric characters. you've got other messing around do, following may started:

function convert_str_to_numeric(pin_str in varchar2)   return varchar2   strresult  varchar2(32767);   c          char(1); begin   in 1..length(pin_str) loop     c := substr(pin_str, i, 1);      strresult := strresult || case c                                 when 'a' '16'                                 when 'b' '17'                                 when 'c' '18'                                 when 'd' '19'                                 when 'e' '20'                                 when 'f' '21'                                 when 'g' '22'                                 when 'h' '23'                                 when 'i' '24'                                 when 'j' '25'                                 when 'k' '26'                                 when 'l' '27'                                 when 'm' '28'                                 when 'n' '29'                                 when 'o' '30'                                 when 'p' '31'                                 when 'q' '32'                                 when 'r' '33'                                 when 's' '34'                                 when 't' '35'                                 when 'u' '36'                                 when 'v' '37'                                 when 'w' '38'                                 when 'x' '39'                                 when 'y' '40'                                 when 'z' '41'                                 else c                               end;   end loop;    return strresult; end convert_str_to_numeric; 

for example, if call above test string of 'tue nl 123456789' produces '353620 2927 123456789'.

best of luck.

share , enjoy.


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -