• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Bear Bibeault
  • Henry Wong
  • Devaka Cooray
Saloon Keepers:
  • salvin francis
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Frits Walraven
Bartenders:
  • Jj Roberts
  • Carey Brown
  • Scott Selikoff

problem in copying table

 
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Are you copying it through some code?
 
Aditi agarwal
Ranch Hand
Posts: 225
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thnks for your reply but this is somthing else from what i needed
 
Swastik Dey
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Marshal
Posts: 26382
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Bartender
Posts: 2268
20
Android Java ME Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Marshal
Posts: 26382
81
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2407
36
Scala Python Oracle Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 2658
19
Netbeans IDE C++ Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
And what about "Data Transformation Services" ?
 
Who among you feels worthy enough to be my best friend? Test 1 is to read this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic