Introduction To Database Management Systems By Atul Kahate. Introduction To Database Management Systems, 1st Edition, Pearson Education 2004.
jvideobooks.com Free Download Pdf Atul kahate Introduction To Database Management Systems - Page 2. "Introduct to Database Management Systems"
Category:1962 births
Category:Indian computer scientists
Category:Living peopleQ:
Convert a string to an integer in PL/SQL
I have some data that is being returned from a web application. This data is in the format of "1", "0", "-1" or "0.5".
For this to be stored in a database, I have to convert this to integers.
I have tried doing this:
SELECT TO_INTEGER('0.5') FROM dual;
and
SELECT TO_NUMBER('0.5') FROM dual;
This works fine, but the web application is returning these values as strings (hence the reason why I have to convert them to integers).
Is there a way to do this conversion and retain the string values?
For example, using a function something like:
TO_INTEGER('0.5') as result
Which I would like to return "1".
A:
try this function.
create or replace function to_int(value varchar2) return number is
v number;
len varchar2(1);
begin
if (value = '-')
then
len := length(value);
elsif (value = '.')
then
len := length(value);
else
len := length(value) - 1;
end if;
v := substr(value, 1, len);
return v;
end to_int;
/
A:
What I'd do is to get this in my web application. It would be best to have a set of types that you can easily represent as ints. I do not think there is any way to do that conversion from strings, without knowing what data types you have.
If you want to be able to store the data in any be359ba680
Related links:
Comments