Home » SQL & PL/SQL » SQL & PL/SQL » text formatting
text formatting [message #223614] Fri, 09 March 2007 15:04 Go to next message
Messages: 55
Registered: June 2005
Can anyone plz let me know how I can achieve this...

I have a csv file with numbers 1...4999, say. I need to load this into a table where the above data should be loaded as Z0001...Z4999.

Thnx much!
Re: text formatting [message #223616 is a reply to message #223614] Fri, 09 March 2007 15:38 Go to previous messageGo to next message
Messages: 4759
Registered: February 2005
Location: East Coast USA
Senior Member
Not sure what you are trying to achieve, but I would forego the CSV file and do this instead:
insert into a
select 'Z'||lpad(to_char(rownum),4,'0')
from dual
connect by rownum < 5000;

Whoops, added the padding.

And...I was sloppy not to use the TO_CHAR as Littlefoot pointed out. Added that too.

[Updated on: Fri, 09 March 2007 15:42]

Report message to a moderator

Re: text formatting [message #223617 is a reply to message #223614] Fri, 09 March 2007 15:39 Go to previous message
Messages: 21128
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Apply something like this:
'Z' || LPAD(TO_CHAR(the_number), 4, '0')
Previous Topic: how
Next Topic: can we insert in multiple tables with one insert command
Goto Forum:

Current Time: Mon Jul 24 17:51:07 CDT 2017

Total time taken to generate the page: 0.25966 seconds