Home » SQL & PL/SQL » SQL & PL/SQL » text formatting
text formatting [message #223614] Fri, 09 March 2007 15:04 Go to next message
ozzy80
Messages: 55
Registered: June 2005
Member
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!
Ozzy
Re: text formatting [message #223616 is a reply to message #223614] Fri, 09 March 2007 15:38 Go to previous messageGo to next message
joy_division
Messages: 4644
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
Littlefoot
Messages: 20901
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: Fri Dec 09 19:10:03 CST 2016

Total time taken to generate the page: 0.12650 seconds