• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem in copying table

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have a table in SQL 2000 with approx 12000 records & want to copy its data in the PostgreSQL

the problem is that all fields are seperated by ',' but one of the fields itself contains ',' as its part

then this is creating problem how can i copy this table please help me

i need this table
thanks in advance
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you copying it through some code?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
no way 12k records are not possible to insert through any code

actually i have those records in a .txt file & then copying that file to postgre as

copy file from 'e:/a.txt' using delimiters ',';
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

no way 12k records are not possible to insert through any code


Does that mean we can't create any data export/backup utility in java?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i dont know much aout this swastik

if you have any imple code to enterthis through java then please also let me know

thank you
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I haven't exactly worked on the requirement, but may be the following logic works

 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thnks for your reply but this is somthing else from what i needed
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok, I might have got your requirement wrong. Could you please elaborate a bit more?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
actually i have table in SQL server 2000 now i want to use that same table for my different application in postgreSQL that is another database
but problem is that it has afield subject which contains ',' in itself also & when we use to convert table from SQL to postgre we use ',' as delimiters mans end of one column so its increasing the number of columns & thus creating problem

help me out please
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't understand what these "delimiters" are for. Your question is about JDBC, isn't it? So I don't understand what delimiters have to do with anything.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks Paul fo your reply my question is related to copying of SQL table to Postgre & when we do such conversions we need to add delimiters
 
Swastik Dey
Rancher
Posts: 1625
5
Android Java Java ME
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
But whats wrong with the logic I suggested? Why are you doing it in two steps? First convert to text and then again copy to the other database?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hey swastik then what can i do for that can you elaborate it because i think i interpret it wrong
 
Paul Clapham
Sheriff
Posts: 21322
32
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Aditi agarwal wrote:thanks Paul fo your reply my question is related to copying of SQL table to Postgre & when we do such conversions we need to add delimiters


If you converted each row of the table to a string, then yes, you would need some strategy for keeping the columns separate. And yes, using delimiters would be one possible strategy. But there's already two assumptions you have made -- the idea of converting each row to a string, and the idea of using delimiters to separate the columns.

Both of those assumptions are unnecessary. In particular the idea of making a single string out of a row is a bad idea because (as you can see) it immediately raises the question of how to separate the columns. So don't do that. Make each row into some kind of data structure -- there are data structures beyond strings in Java, as I'm sure you know.
 
chris webster
Bartender
Posts: 2407
33
Linux Oracle Postgres Database Python Scala
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming this is a one-off task, why not just export the table to a CSV file, with double quotes around the character columns to cope with the commas inside the text values, then import it into PostgreSQL from the CSV file?

Or you may be able to use the export/import routines of the respective databases to move the data from SQLServer to PostgreSQL more easily.

Or you could look at ways of writing directly from one database to the other using SQL.
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thank you chris & paul for your reply

hey chris i ahve tried through SV but its not working

thank you
 
Jan Cumps
Bartender
Posts: 2599
12
C++ Linux Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And what about "Data Transformation Services" ?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic