Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Need a SQL script for migration

 
M Burke
Ranch Hand
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 124
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 406
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic