is it possible to do something at the format file level on a particular column ?
Main Topics
Browse All TopicsI am extracting data from sybase using bcp tool ( building pipe delimited data file ) & there by loading into oracle database.
Issue: some fields are having newline characters and it is making the load in correct.
Is there a way to remove the newline character while pulling the data through BCP.....can anything be done at the format file....??
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
I agree with grant300's suggestion, a couple of comments:
1st approach, as grant300 suggests, however, I don't know BCP so he must help here with the Sybase part.
Make sure the text column is enclosed by quotes, then you can also use the stream format in sql loader, as grant suggests, using a combination of characters as the line terminator.
This uses |\n as terminator in the SQL Loader control file and use stream format.
LOAD DATA
INFILE 'foo.dat' "str '|\n'"
TRUNCATE INTO TABLE foo
FIELDS TERMINATED BY '|' OPTIONALLY ENCLOSED BY '"'
TRAILING NULLCOLS
(
... your field defs go here
)
2nd approach:
Or.. run a SQL query on sybase replacing all occurences of \n with something like "<SLASH_N>"
Extract with BCP
Load normally with SQL Loader
Run Oracle update, replacing <SLASH_N> with '\n' again
i thought of doing like this....
instead of \n as line terminator...i will be using <eol>.
Now i get the data file with single line ( line breaks only when there is a \n in column values )...
Now use sed to replace \n with \t (tab).....
and use sed to replace <eol> with \n....
now i will get the data file with \n as the line terminator....
--------------------------
but my question is ....... can we get it done at the format file level ....
something like.... replace ( newline with space or tab on a particular column)...?
To answer OP's question:
You can't use a BCP format file to do any updates to the data. The format file specifies the format and says nothing about the content (other than its datatype).
You could however create a view on the underlying data that does some transformations, and the BCP out of the view.
@vishali_vishu
A more equitable point split would probably have been to include grant300's initial advice that led to the final solution, so I feel like accepting the comment that you selected is not a proper closure for this question. When closing a question, please consider the comments in the thread that actually helped you with the solution, not just the final one. Thanks.
Business Accounts
Answer for Membership
by: grant300Posted on 2009-05-11 at 06:34:23ID: 24354358
The way around this is to choose a different Line Terminator character on your BCP out and SQL*Loader in. If necessary, choose a non-printable character that both utilities can handle. That way you preserve the integrity of the data.
Regards,
Bill