0

I was given Oracle code and I'm trying to figure out what it is doing. Specifically it's converting a number to a string and I don't understand it.

The code is:

TO_CHAR(QTY_DISPENSED,'0000000V000') 

What does the V do?

Jeff

1 Answer 1

2

It's a "Format Model" for converting numbers to strings: https://docs.oracle.com/cd/B19306_01/server.102/b14200/sql_elements004.htm

Returns a value multiplied by 10n (and if necessary, round it up), where n is the number of 9's after the V.

So basically it's taking your QTY_DISPENSED multiplying it by 1000 and returning a string.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks. Does that mean in the above example the resulting string would be length of 7 characters?
In that same link you'll see that 0 Returns leading zeros. so it should have at least 7 characters, and if less it will LPAD with 0's. *I believe

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.