I have existing records in the database the field description is

aa_desc NOT NULL VARCHAR2(8) 

i have existing record for this field and now i have to add - (hyphen) with the existing record.

since it is restricted to eight characters i have to pad only the remaining characters with existing.

ex : if the existing value is aaa it needs to be padded like -----aaa.

how do i do this.

Technical environment :

DB : Oracle

Development : java
有帮助吗?

解决方案

You should use Oracle's LPAD function. It adds the necessary character to the left side of the string to make of the specified lenght.So in your case, it should be:

LPAD(aa_desc, 8, '-')

http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions095.htm#SQLRF00663

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top