aspose file tools*
The moose likes JDBC and the fly likes problem in copying table Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "problem in copying table" Watch "problem in copying table" New topic
Author

problem in copying table

Aditi agarwal
Ranch Hand

Joined: Feb 23, 2011
Posts: 225
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

Joined: Jan 08, 2009
Posts: 1477
    
    6

Are you copying it through some code?


Swastik
Aditi agarwal
Ranch Hand

Joined: Feb 23, 2011
Posts: 225
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

Joined: Jan 08, 2009
Posts: 1477
    
    6


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

Joined: Feb 23, 2011
Posts: 225
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

Joined: Jan 08, 2009
Posts: 1477
    
    6

I haven't exactly worked on the requirement, but may be the following logic works

Aditi agarwal
Ranch Hand

Joined: Feb 23, 2011
Posts: 225
thnks for your reply but this is somthing else from what i needed
Swastik Dey
Rancher

Joined: Jan 08, 2009
Posts: 1477
    
    6

Ok, I might have got your requirement wrong. Could you please elaborate a bit more?
Aditi agarwal
Ranch Hand

Joined: Feb 23, 2011
Posts: 225
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
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Feb 23, 2011
Posts: 225
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

Joined: Jan 08, 2009
Posts: 1477
    
    6

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

Joined: Feb 23, 2011
Posts: 225
hey swastik then what can i do for that can you elaborate it because i think i interpret it wrong
Paul Clapham
Bartender

Joined: Oct 14, 2005
Posts: 18570
    
    8

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

Joined: Mar 01, 2009
Posts: 1701
    
  14

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.

No more Blub for me, thank you, Vicar.
Aditi agarwal
Ranch Hand

Joined: Feb 23, 2011
Posts: 225
thank you chris & paul for your reply

hey chris i ahve tried through SV but its not working

thank you
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2499
    
    8

And what about "Data Transformation Services" ?


OCUP UML fundamental and ITIL foundation
youtube channel
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: problem in copying table