Skip to Main Content

Integration

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

SQL Replicate function ORACLE equivalent

user8812324Feb 23 2010
Hi,

Im converting replicate function from sql to oracle.

SQL:
select convert(char(7), replicate('0',(7-datalength(ltrim(rtrim(convert(char(7),@name)))))) + ltrim(rtrim(convert(char(7),@name))))

when i converted it to oracle as follows:
SELECT CAST(LPAD('',(7 - LENGTHB(LTRIM(RTRIM(CAST(v_name AS CHAR(7)))))),'0') || LTRIM(RTRIM(CAST(v_name AS CHAR(7)))) AS CHAR(7))

if i let my variable as anne

i got the word itself, theres no '000' in the result.

Please help...
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Mar 23 2010
Added on Feb 23 2010
0 comments
1,722 views