Writing all the rows in one line but cannot write more than 32767 character

Dear All,
i am trying to write the column of a table to a file with the '||' seperators. i want to write all the rows in one line of the file.
for E.g
Column1 Column2
A B
C D
in the file the output needs to be gone like
A||B||C||D
but after 32767 character it gives a write error. could please someone let me know what is wrong with my function below or how can i write more than 32767 character in one one.
CREATE OR REPLACE FUNCTION CORP_IB_DUMP_FILE (
P_QUERY IN VARCHAR2,
P_SEPARATOR IN VARCHAR2 DEFAULT '',
P_DIR IN VARCHAR2,
P_FILENAME IN VARCHAR2
RETURN NUMBER AUTHID CURRENT_USER
IS
L_OUTPUT UTL_FILE.FILE_TYPE;
L_THECURSOR INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_THECURSOR2 INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_COLUMNVALUE VARCHAR2 (4000);
L_STATUS INTEGER;
L_COLCNT NUMBER DEFAULT 0;
L_SEPARATOR VARCHAR2 (10) DEFAULT '';
L_CNT NUMBER DEFAULT 0;
BEGIN
L_OUTPUT := UTL_FILE.FOPEN (P_DIR, P_FILENAME, 'w', 32767);
DBMS_SQL.PARSE (L_THECURSOR, P_QUERY, DBMS_SQL.NATIVE);
FOR I IN 1 .. 255
LOOP
BEGIN
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, I, L_COLUMNVALUE, 4000);
L_COLCNT := I;
EXCEPTION
WHEN OTHERS
THEN
IF (SQLCODE = -1007)
THEN
EXIT;
ELSE
RAISE;
END IF;
END;
END LOOP;
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, 1, L_COLUMNVALUE, 4000);
L_STATUS := DBMS_SQL.EXECUTE (L_THECURSOR);
LOOP
EXIT WHEN (DBMS_SQL.FETCH_ROWS (L_THECURSOR) <= 0);
L_SEPARATOR := '';
FOR I IN 1 .. L_COLCNT
LOOP
DBMS_SQL.COLUMN_VALUE (L_THECURSOR, I, L_COLUMNVALUE);
UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
L_SEPARATOR := P_SEPARATOR;
UTL_FILE.FFLUSH (L_OUTPUT);
END LOOP;
UTL_FILE.FFLUSH (L_OUTPUT);
L_CNT := L_CNT + 1;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (L_THECURSOR);
UTL_FILE.FCLOSE (L_OUTPUT);
RETURN L_CNT;
END CORP_IB_DUMP_FILE;
/

user577300 wrote:
Dear All,
i am trying to write the column of a table to a file with the '||' seperators. i want to write all the rows in one line of the file.
for E.g
Column1 Column2
A B
C D
in the file the output needs to be gone like
A||B||C||D
but after 32767 character it gives a write error. could please someone let me know what is wrong with my function below or how can i write more than 32767 character in one one.
CREATE OR REPLACE FUNCTION CORP_IB_DUMP_FILE (
P_QUERY IN VARCHAR2,
P_SEPARATOR IN VARCHAR2 DEFAULT '',
P_DIR IN VARCHAR2,
P_FILENAME IN VARCHAR2
RETURN NUMBER AUTHID CURRENT_USER
IS
L_OUTPUT UTL_FILE.FILE_TYPE;
L_THECURSOR INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_THECURSOR2 INTEGER DEFAULT DBMS_SQL.OPEN_CURSOR;
L_COLUMNVALUE VARCHAR2 (4000);
L_STATUS INTEGER;
L_COLCNT NUMBER DEFAULT 0;
L_SEPARATOR VARCHAR2 (10) DEFAULT '';
L_CNT NUMBER DEFAULT 0;
BEGIN
L_OUTPUT := UTL_FILE.FOPEN (P_DIR, P_FILENAME, 'w', 32767);
DBMS_SQL.PARSE (L_THECURSOR, P_QUERY, DBMS_SQL.NATIVE);
FOR I IN 1 .. 255
LOOP
BEGIN
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, I, L_COLUMNVALUE, 4000);
L_COLCNT := I;
EXCEPTION
WHEN OTHERS
THEN
IF (SQLCODE = -1007)
THEN
EXIT;
ELSE
RAISE;
END IF;
END;
END LOOP;
DBMS_SQL.DEFINE_COLUMN (L_THECURSOR, 1, L_COLUMNVALUE, 4000);
L_STATUS := DBMS_SQL.EXECUTE (L_THECURSOR);
LOOP
EXIT WHEN (DBMS_SQL.FETCH_ROWS (L_THECURSOR) <= 0);
L_SEPARATOR := '';
FOR I IN 1 .. L_COLCNT
LOOP
DBMS_SQL.COLUMN_VALUE (L_THECURSOR, I, L_COLUMNVALUE);
UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
L_SEPARATOR := P_SEPARATOR;
UTL_FILE.FFLUSH (L_OUTPUT);
END LOOP;
UTL_FILE.FFLUSH (L_OUTPUT);
L_CNT := L_CNT + 1;
END LOOP;
DBMS_SQL.CLOSE_CURSOR (L_THECURSOR);
UTL_FILE.FCLOSE (L_OUTPUT);
RETURN L_CNT;
END CORP_IB_DUMP_FILE;
/Check your logic very carefully. You are using UTL_FILE.PUT() which should not automatically put end-of-line characters i n your file but you are reassigning l_seperator with p_seprator after the first time.
What value are you pasising in as p_seperator?
UTL_FILE.PUT() should allow you to write a string of bytes without newlines as long as its arguments are less than 32K, and you can control when the newlines get written. If your arguments are > 32K can you split them up without writing the newlines until you need to do so? Try something like (untested)
--         UTL_FILE.PUT (L_OUTPUT, L_SEPARATOR || L_COLUMNVALUE);
           UTL_FILE.PUT (L_OUTPUT, substr(L_SEPARATOR || L_COLUMNVALUE,1,32767));
           UTL_FILE.PUT (L_OUTPUT, substr(L_SEPARATOR || L_COLUMNVALUE),32767*2-1,32767));Edited by: riedelme on Sep 10, 2012 6:11 AM

Similar Messages

  • Exporting PDF document to Excel.  When I export a PDF document to Excel containing lists of  people the Excel page shows all the names on  one line several inches deep instead of on separate lines which makes editing impossible.  What am I doing wrong?

    Exporting PDF document to Excel.  When I export a PDF document to Excel containing lists of  people the Excel page shows all the names on  one line several inches deep instead of on separate lines which makes editing impossible.  What am I doing wrong?

    Murray is right. Padding (and margins) is added to the width. However, when using percentages, you should never use figures that add up to exactly 100%.
    Browsers need to convert the percentages to pixels. Because pixels must be whole numbers, some percentages are rounded up, which results in the final element dropping down below its neighbours. With percentages, it's much safer to use values that add up to 98% (99% often works, but 98% is safer).

  • On iPhoto I can see all the pictures for one event, but about 9 out of 106 I can't move to print or place it anywhere else?

    On iPhoto I can see all the pictures for one event, but about 9 out of 106 I can't move to print or place it anywhere else?

    Basics from the manual are restrt, reset, restore.
    Have you tried each of these?

  • I have just erased my iphone 3gs n the reset is taking place but its been more than an hour since the black screen is loading ? what should i do

    I have just erased my iphone 3gs n the reset is taking place but its been more than an hour since the black screen is loading ? what should i do

    Do a
    Reset: Hold down the Sleep/Wake button and the Home button at the same time for at least ten seconds, until the Apple logo appears. Note: You will not lose any data

  • Since downloading the iOS on my iPad, I cannot download more than one pdf from mail to iBooks.  I have to shut down y iPad and start again.  Any suggestions?

    Since downloading iOS on my new iPad, I cannot downlaod more than one pdf from mail into iBooks.  I have to shut down my iPad and restart it to save a second pdf. Wasn't a problem with the old operating system.  Any suggestions?

    It seems that I have solved my issue by performing a full factory reset (erasing all content, something which I had hoped to avoid) restoring from an iCloud backup did not alleviate the issue, I had to set up as a new iPad.
    Hopefully anyone else else who has this issue in the future will be able to find this.

  • When using mail, I can fill in the address and subject line but cannot get to the body of the email to type.

    When using my regular mail, I can hit reply or start a new email and can fill in the address line and the subject line.  I cannot get to the body of the email to type my message.  The curser will not go there and the keyboard does not pop up.  How can I correct this so I can send emails when travelling?
    Thank you
    TrudyN

    Oh, ok. That changes my answer completely. The problem here is that Shawmail's webmail interface isn't made to work correctly with the iPad. Gmail works because Google made sure it works. You need to contact Shaw and ask them to correct this. In the meantime, set up your Shawmail account in the native Mail app on the iPad. Do this by going to Settings>Mail, Contacts, Calendars and take it from there.

  • HT1688 My phone is glitching all the time and won't stay on for more than 30 sec...

    Until a few days ago my phone was fine but then the screen turned kind of denim looking almost and slowly faded black and I would restart it but it continued to go through this proccess

    Could be faulty battery. Apple Store can perform free quick (minutes) battery diagnostic testing. Make Genius reservation to avoid long wait.

  • Can't open mail on Facebook, can't write more than 2 lines in the status on Facebook and there are no "older posts" showing on Facebook

    This is regarding Facebook: I can no longer open mailbox to receive or send. The result is a white page with the Facebook index on the left. I can no longer write more than 2 lines in status updates. Lastly, the "older posts" that is usually at the bottom of the page is no longer there. Incidentally, all these things work in IE. There's nothing in Facebook referring to these issues except to say it doesn't support Firefox 3.6.8.

    Launch the Console application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Console in the icon grid.
    Step 1
    Enter the name of the crashed application or process (Finder) in the Filter text field. Post the messages from the time of the last crash, if any — the text, please, not a screenshot.
    When posting a log extract, be selective. In most cases, a few dozen lines are more than enough.
    Please do not indiscriminately dump thousands of lines from the log into a message.
    Important: Some private information, such as your name, may appear in the log. Edit it out by search-and-replace in a text editor before posting.
    Step 2
    Still in the Console window, look under User Diagnostic Reports for crash reports related to the process. The report name starts with the name of the crashed process, and ends with ".crash". Select the most recent report and post the contents — again, the text, not a screenshot. In the interest of privacy, I suggest that, before posting, you edit out the “Anonymous UUID,” a long string of letters, numbers, and dashes in the header of the report, if it’s present (it may not be.) Please don’t post shutdownStall, spin, or hang logs — they're very long and not helpful.

  • So I have purchased every song on the Up All Night album by One Direction but it isn't showing up as Purchased in the iTunes store and it isn't saying that I can download the iTunes LP...help!

    I bought every single song on the Up All Night album by One Direction, but iTunes is not showing the album as purchased when I'm in the iTunes store. It doesn't even have the complete my album option. It's showing as full price and I don't want to pay $12.99 just so that I can have the iTunes LP. However, I do really want the iTunes LP. What do I do?

    Then you need to click the link below and fill out the email form to the itunes store about the issue
    http://www.apple.com/support/itunes/store/games/

  • How to show all the rows of a report in one page

    My report has 30 rows, by default it just show 15 rows. I want to show all the rows just in one page, without cliking link or arrow to see the left.
    In the Layout and Pagination:
    Report Template: template: 15. Standard Report (PPR)
    Pagination Scheme: Row Ranges X to Y (no pagination)
    Display Position: Bottom - Right
    Number of Rows: 1000
    Number of Rows (item) 1000
    Maximum Row Count: 1000
    How to fix it?
    Thanks.
    Jen

    Ok, I think I got it. I needed to blank out Number of Rows(item), Maximum row count and only populate Number of Rows. I was sure I did that before and it didnt work.
    Do you think that the Sessions in Apex can cause unexpected results? I have found that when I make changes I have to log all the way out of Apex, close my browser and reopen everything to ensure that my change took. Does anyone else have this issue? I can move this into a different thread if need be.
    Thx!

  • HT1918 Hi - I think I have different apple devices recorded under different apple IDs. Now I would like to consolidate all the devices under one Apple-ID.  I have tried to do this going through the manage accoung like, but it timed out - could somebody he

    Hi - I think I have different apple devices recorded under different apple IDs. Now I would like to consolidate all the devices under one Apple-ID.  I have tried to do this going through the manage accoung like, but it timed out - could somebody help, pls

    Purchases of multple Apple ID accounts cannot be merged as noted here >  Frequently asked questions about Apple ID

  • I would like to copy all the songs from one Ipod into another. All the songs are into my Itunes account, I tried to drag and drop the songs from the old Ipod to the new one but it doesn't work. Is there a way to do it ?

    Hello everybody,
    I would like to copy all the songs from one Ipod into another. All the songs are into my Itunes account, I tried to drag and drop the songs from the old Ipod to the new one but it doesn't work. Is there a way to do it ?
    I share one Itunes account with other people from my family and one person would like to keep the same songs on the new Ipod as the ones which were on the old one.
    Thanks in advance for your answer.
    Yan

    Hello Chris,
    Thanks for your answer. I was hoping for an easier answer. Too bad there is no drag and drop solution, it would have been much easier.
    Thanks for answering so fast.
    Bye.
    Yan

  • In my email all the messages from one person bunch together and I would like to separate them. I have done this before on my iPhone but just recently got an iPad and its doing it on this, so does anyone have any ideas how to fix this issue?

    In my email all the messages from one person bunch together and I would like to separate them. I have done this before on my iPhone but just recently got an iPad and its doing it on this, so does anyone have any ideas how to fix this issue?

    Settings >> Mail, Contacts. Calendars >> Organise by Thread. Switch to OFF to see every individual email in the Inbox.

  • How to get all the values in one column of a JTable

    How to get all the values in one column of a JTable as a Collection of String.
    I don;t want to write a for loop to say getValueAt(row, 1) eg for 2nd column.

    I don;t want to write a for loop to say getValueAt(row, 1) eg for 2nd column. You could always write a custom TableModel that stores the data in the format you want it. It would probably be about 50 lines of code. Or you could write a loop in 3 lines of code. I'll let you decide which approach you want to take.

  • How to show all the rows in PRint html option in obiee 11g

    Hi ,
    I am facing a issue in obiee 11g(windows 2003 server). I have 2 environments (SIT & dev)
    In dev I am not facing any issue but in SIT when i print the report in html only 1-25 rows are displayed.
    What should i do to see all the rows
    Thanks in advance
    Abdul

    Hi,
    In your Dev Server its configured on instanceconfig.xml file that why are getting the all rows with setting pdf/print control properties.
    1. Change instanceconfig.xml file in <biee11g_install>\instances\instance1\config\OracleBIPresentationServicesComponent\coreapplication_obips1 as following
    <Views>
    <Pivot>
    <!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager-->
    <DefaultRowsDisplayedInDelivery>75</DefaultRowsDisplayedInDelivery>
    <!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager-->
    <DefaultRowsDisplayedInDownload>2500</DefaultRowsDisplayedInDownload>
    <!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager-->
    <DisableAutoPreview>false</DisableAutoPreview>
    <MaxVisibleColumns>5000</MaxVisibleColumns>
    <MaxVisiblePages>2500</MaxVisiblePages>
    <MaxVisibleRows>500000</MaxVisibleRows>
    <MaxVisibleSections>5000</MaxVisibleSections>
    </Pivot>
    <Table>
    <!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager-->
    <DefaultRowsDisplayedInDelivery>75</DefaultRowsDisplayedInDelivery>
    <!--This Configuration setting is managed by Oracle Business Intelligence Enterprise Manager-->
    <DefaultRowsDisplayedInDownload>2500</DefaultRowsDisplayedInDownload>
    <MaxVisiblePages>2500</MaxVisiblePages>
    <MaxVisibleRows>500000</MaxVisibleRows>
    <MaxVisibleSections>5000</MaxVisibleSections>
    </Table>
    </Table>
    </Views>
    3. Note the new elements added are the following to both <Pivot> and <Table>, the Pivot part controls Pivot view, and Table part controls Table View, my testing was done with Table View.
    <MaxVisiblePages>2500</MaxVisiblePages>
    <MaxVisibleRows>500000</MaxVisibleRows>
    <MaxVisibleSections>5000</MaxVisibleSections>
    4. Restart Presentation Server from EM, then run your request, do pdf export to verify.
    Note:
    When a table or pivot table includes a large number of rows, a set of buttons can be displayed under the view. You can use the following buttons to page through the rows in the view:
    •First 25 Rows — Displays the first 25 rows of data for the view. The number that is used for the First, Previous, and Next buttons is specified by the Rows per Page field in the "Table Properties dialog: Style tab".
    •Previous 25 Rows — Displays the previous 25 rows of data for the view.
    •Next 25 Rows — Displays the next 25 rows of data for the view.
    •Display maximum (500) rows per page — Allows you to display as many as the maximum number of rows per page at one time temporarily. The default is 500. The administrator can specify a different maximum value that is displayed on the tooltip for the button using the MaxVisibleRows element in the configuration file.
    For more Refer my blog post
    http://obieeelegant.blogspot.sg/2011/09/unable-to-export-all-rows-from-request.html
    Note: this same thing you can also configure your UAT/Prod Server. then its will automated so you no need to configure each report.its will affect all the pivot/table view
    also its noted as a bug in obiee11g(11.1.1.3/5) and its fixed in obiee11.1.1.6.0 and above version
    FYI:
    Thanks
    Deva

Maybe you are looking for

  • Lightroom won't open my RAW files in Photoshop

    I've had this problem for a few months now, but I thought I'd test the waters and see if there's anyone out there who can help me now. Here is a video of what happens when I try to open ANY raw file from ANY camera type in Lightroom to edit in Photos

  • How to change the order of pages in Pages '09

    What is the most direct (easiest) way to change the order of the pages in an existing ".page" document. In QuarkXpress, for example, it was possible to simply drag a page to it's new location in the layout view. Thanks

  • If I don't install lion will I be cloud less next june

    I am not planning on installing lion.  On reason is iTunes 10.  I don't like it, the only reason I have it installed is to update my iPhone.  I use iTunes 9 for everything else.  iTunes is colorless and it sounds like finder is also.  If I don't upgr

  • Need a Free designing program. for example: something to help me make shirt

    Need a Free designing program. for example: something to help me make shirt graphics, posters, and other designs. i do not think my mac came with any such program. i have ilife 08 but i dont think anything there can help me?

  • Using launchctl with python script

    I have been trying to get launchctl to run a python script for me every 3 minutes. I have read many threads and such to no avail. Following describes files and such. PLIST file location = /Users/mike/Library/LaunchAgents File name = scraper.plist Fil