mie_miauwkes
2012-03-06 11:44:13 UTC
I'm having a database inside Oracle APEX. No idea what type of database, but I presume 11g.
Apex version is 4.1.1.00.23.
I'm trying to replace comma's inside the data of a column with points.
For example, the kcal value has 24,5 and I want this to change to 24.5
So, comma turns into a point.
This is my code so far:
UPDATE FOODALL a
SET a.kcal = (
SELECT REPLACE(b.kcal, ',','.')
FROM FOODALLES_5_COPY b
WHERE b.kcal like '*')
This tells me 1360 row(s) were updated, but instead of changing the comma, all the values are now gone. Luckily for me I have backups from this table, so I can easily restore the lost data.
Now, I'm sure it should be possible. I tried the following code to see if the REPLACE is correct:
SELECT REPLACE (kcal, ',', '.')
FROM FOODALL
Before the above code, the column had data like this:
KCAL
120,00
85,00
84,00
125,00
157,00
220,00
73
100,00
188,00
337,00
After executing the code mentioned above, it returns data like this:
REPLACE(KCAL,',','.')
120.00
85.00
84.00
125.00
157.00
220.00
73
100.00
188.00
337.00
SO! Tada! It can replace the comma's with points! Now, why won't it work with the UPDATE statement?
What am I doing wrong?
Please, help me with this if you have an idea!
I've been trying for so long now, doing a search on the web didn't help me so far... I've been busy with normalizing a XLS sheet and importing it in the database (1360 rows, that's not small to normalize!), it was the first time I had to do this (I'm a trainee at Oracle) and I really need to find out how to properly change the comma's with points...
Also, getting rid of the WHERE clausule isn't an answer. Because then I get the error that a single-row subquery returns more than one row.
Thank you in advance for your answers!