Microsoft
Software
Hardware
Network
Question : Subtract number and pad as 3 digits in Oracle 9i
Oracle 9i environment.
I need to read the first 3 digits of a field, subtract 400 from it, and ensure the result remains as three digits.
The code I am working with is as follows:
TO_CHAR(TO_NUMBER(SUBSTR(m
y_field,1,
3))-400,'0
09')
It is returning the correct value, but the next step in the process fails and says it cant read the value. I suspect it is because it is looking for a number, and this has converted it to CHAR.
Normaly the - 400 is not required and the code is simply
SUBSTR(my_field,1,3) which works perfectly
examples:
523 should return 123
403 should return 003
Any thoughts on how to acheive this and keep it as a number. maybe LENGTH ?
Answer : Subtract number and pad as 3 digits in Oracle 9i
sorry
lpad(TO_NUMBER(SUBSTR(my_f
ield,1,3))
-400,3,'0'
)
Random Solutions
Restoring SQL server .MDF file, without .LDF file (cannot load database)
Is there an equivilant of "XP Mode" for Terminal Server 2008 R2?
Lost user password on Vista Home Basic notebook. chntpw
Update Query to Delete everything to thr right: 4th comma
VS 2008 Hangs (slow) on Open Website when searching through Mapped Network Drives
"Database could not recover. Contact Technical Support." (with link to logs)
Attach-Detach vs. Backup-Restore database ?
MSSQL2000
Exchange 2003 Private Store increased/decreased
Windows XP drops network connection freezes because of offline files