File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JDBC and the fly likes Need a SQL script for migration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Need a SQL script for migration" Watch "Need a SQL script for migration" New topic
Author

Need a SQL script for migration

M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
Hi,
I need a script to read in a comma-delimitated file and insert the rows into a database (Sybase). The file field numbers do not match the columns in the table, so I will have to map the fields to the columns. Anyone have one or know how to do it?

They won't let me use JDBC
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
how about awk?

awk -F, '{print "insert into table_a (C1, C20) values (\"" $1 "\", \"" $2 "\"")' csv-file

then pipe result into isql or somesuch.

just nosy, but why are they dictating what tool(s) you can use? what's wrong with letting you get the job done the best way you know how?
M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
I can give that a try. I am not familiar with awk. Do I put it into a shell script?

Well, it�s a long story. But upper management is making development decisions. They bought into a BPM tool (without our input) that costs millions and now they want to use it for everything. They blame Java for their application problems rather than the consultants that used it.
john guthrie
Ranch Hand

Joined: Aug 05, 2002
Posts: 124
awk is a unix command, so you'd run it in a shell script (if on windows, you can run it in cygwin, dunno if there's a native windows awk). it's very useful, and looks very impressively cryptic to newbies and beautiful women.
M Burke
Ranch Hand

Joined: Jun 25, 2004
Posts: 388
Originally posted by john guthrie:
awk is a unix command, so you'd run it in a shell script (if on windows, you can run it in cygwin, dunno if there's a native windows awk). it's very useful, and looks very impressively cryptic to newbies and beautiful women.


Yeah, Unix guys get all the chicks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Need a SQL script for migration