0

I have a table with the faithful "code"

Code character varying (10) NOT NULL,
....

The data must be like VXXXXXXXXX | JXXXXXXXXX where x are numbers with 9 digits, is there a way to add "0" in the numbers with 8 digits or less?

if I get: VXXX add 0 to get V000000XXX?

I want to do this using triggers.

2
  • 1
    Is the prefix always exactly a single character? Commented Feb 14, 2017 at 22:33
  • Yes is always is a single character Commented Feb 15, 2017 at 14:46

1 Answer 1

3

Assuming the prefix is always exactly one character, you can do something like this:

concat(left(code,1), lpad(substr(code,2), 8, '0'))
Sign up to request clarification or add additional context in comments.

1 Comment

Working perfectly! Thanks a lot

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.