How to split the file by using the utl package in oracle.

Hi all

I want ot create several files with utl_file.

Earlier, I'm writing itng cursor files together in a single file.

But now we must divide it into several files when the cursor recrds exceeded 10000.

So the file will become two if it crosses 10000 records Amend now

If a cursor has 30000 records then I hould create 3 files.

Here's how I wrote the simple logic to write the entire records from a single table.

UTL_FILE. PUTF (File1, head);

UTL_FILE.new_line (file1);

FOR vcur_torico_fetch IN cur_torico_fetch

LOOP

stmt: = "

|| Chr (9) | »

|| Chr (9) | vcur_torico_fetch. Application_classification

|| Chr (9) | »

|| Chr (9) | »

|| Chr (9) | vcur_torico_fetch. MY_COMP_CODE

|| Chr (9) | vcur_torico_fetch. OU_org_code;

UTL_FILE. PUTF (File1, stmt);

UTL_FILE.new_line (file1);

END LOOP;

UTL_FILE.fclose (file1);

Kindly let me know the logic to do this.

Best regards

Try this. I used object and I write 33333 lines. It will be writern in 4 files with lines of 10000, 10000, 10000 and 3333.

SQL> declare  2    l_file         utl_file.file_type   default NULL;  3    l_row_per_file integer              default 10000;  4    l_file_name    varchar2(100)        default 'ALL_OBJECT_{FILENO}.CSV';  5    l_file_dir     varchar2(100)        default 'KARDIR';  6    l_file_no      integer              default 0;  7  begin  8    for i in (  9                select object_id 10                     , object_name 11                     , ceil(rownum/l_row_per_file) file_no 12                  from all_objects 13                 where rownum <= 33333 14             ) 15    loop 16        if l_file_no != i.file_no 17        then 18            if utl_file.is_open(l_file) 19            then 20               utl_file.fclose(l_file); 21            end if; 22 23            l_file_no := i.file_no; 24            l_file    := utl_file.fopen 25                         ( 26                              l_file_dir 27                            , replace(l_file_name, '{FILENO}', to_char(l_file_no, 'fm099999')) 28                            , 'w' 29                         ); 30        end if; 31 32        utl_file.put_line(l_file, i.object_id || ',' || i.object_name); 33     end loop; 34 35     if utl_file.is_open(l_file) 36     then 37        utl_file.fclose(l_file); 38     end if; 39  end; 40  /

PL/SQL procedure successfully completed.

SQL>

In the unix box, check the file...

% ls - lrt ALL_OBJECT knani *. CSV | AWK '{print $9} ' | XARGS wc-l
10000 ALL_OBJECT_000001.CSV
10000 ALL_OBJECT_000002.CSV
10000 ALL_OBJECT_000003.CSV
3333 ALL_OBJECT_000004.CSV
33333 total
knani %

Tags: Database

Similar Questions

  • How to split the screen of my mac book

    How to split the screen of my Macbook?

    There may be a solution on how to split the screen into two (halves) for independent display

    through the use of third-party software options. I haven't tried everything, but have read of some who can work.

    Such a "solution party' appears in the Mac App Store; See the second link to the manufacturer.

    https://iTunes.Apple.com/us/app/split-screen/id453757310?MT=12

    • Split screen - Mac app for windows (approximately $7 USD) display management

    http://www.splitscreenapp.com/

    There may be others, beware of questionable sources, as they may contain others? content.

    This may work on a Mac, not a portable desktop computer:

    • Apple introduced mode split for the apps full screen on a Mac in OS X El Capitan - 9to5Mac.com:

    http://9to5Mac.com/2015/06/08/Mac-split-screen-multitasking/

    In any case...

    Good luck & happy computing!

    under the direction

  • How we split the screen for different horizontal and vertical divisions

    Hello

    How we split the screen for different horizontal and vertical divisions. I can't use panelSplitter because I need fixed screen and not the division which is movable/sliding. I tried inlineframe, but which fails because you cannot use forms, other trees components... :(

    so I would like to know how to do division without panelSplitter.

    Thanks in advance,
    Jyothi

    Hi Jyothi,

    If you set the panelSplitter attribute disabled to true, the delimiter becomes permanent/mobile no.

    
    

    Kind regards
    Amélie Chan

  • How to split the PHONE NUMBER in the column of database?

    Hello - how to split the telephone within the same column number?

    Existing column PHONE data

    3711943

    8744723

    8487928

    3349262

    I want to split the data in the same

    371-1943

    874-4723

    etc...


    Is this possible? I need to do this only through SQL query not PL/SQL.



    SUBSTR (your_col, 1, 3). » -'|| SUBSTR(your_col,4)

  • How to split a video for use with Windows Movie Maker

    movie maker help?

    my video is too long, so he used open, does anyone know how I can divide or shorten it so I can open it in movie maker?

    Thanks :)

    my video is too long, so he used open, does anyone know how I can divide or shorten it so I can open it in movie maker?

    Thanks :)

    ===============================================
    Are you sure that is the problem and not an incompatible format?

    In any case... the following freeware might be worth a try:

    VirtualDub
    http://www.videohelp.com/tools/VirtualDub
    (left click of he who said):
    "Download from mirror (direct link) (1.3 MB)")
    (installation is not necessary... just unzip)
    and run it by clicking left VirtualDub.exe)

    VirtualDub: Splitting AVI files
    http://www.Afterdawn.com/guides/archive/cut_avi_with_virtualdub.cfm

    VirtualDub: How to split the video
    http://www.ScreenVirtuoso.com/VirtualDub-split-video.html

    Video editing tutorial - using VirtualDub
    http://www.astahost.com/info.php/video-editing-tutorial_t11655.html
    > not compatible with .wmv or .asf files

    Volunteer - MS - MVP - Digital Media Experience J - Notice_This is not tech support_I'm volunteer - Solutions that work for me may not work for you - * proceed at your own risk *.

  • How to create the BC4J Package in JDev 10 g (with OAF)?

    How to create the BC4J Package in JDev 10 g (with OAF)?

    I use JDev 10.1.3.3.0 with Extension OA release 12.0.6. Right-click on the project of the new option Business Package of components is missing, I tried the business components of the Tables option but could not continiue as steps in the tutorial have does not match this wizard individual. I read on this forum that you can use this option to create the EOs and your and then specify packages later.

    Any help will be appreciated. The tutorial that I'm following is the Oracle Application Framework (tutorials) the JDevDoc\Index.html Toolbox

    Thank you
    Vijay

    Hello

    Tutorial is not being updated, Jdeveloper 10 g, there is no need to create the BC4j package explicitly, you just create AM OT or VO and mention the name of package, JDeveloper will take care rest of things, create new your EOs

    Right-click on the project--> New--> business components ADF (under the enterprise level)---> Module object/Application/view of object entity.

    Thank you
    Pratap

  • How to remove the menu by default oracle froms 6i

    How to remove the default window menu Oracle forms 6i.

    Amatu Allah Neveen Ebrahim wrote:

    As Salamu Asalam we Rahmatu Allah we Barakatu,.

    How are Hamid, you?

    The OP wondered about: form Menu of the window no.

    Best Regatds,

    Amatu Allah.

    Walikum As Salam O Rahmatillahi we Barakatu, sister Amatu Allah.

    Alhumdolilah. How about you?

    Average don't want to see window menu name?

    Oh, so that's that.

    1. quastion in THE HOW TO REMOVE MENU 'WINDOW' of ORACLE FORMS

    Hamid

  • How to remove the extra space of oracle database column

    How to remove the extra space of oracle database column. I would like to clean up the column in the database by deleting the extra space is entered by the dataentery people.

    When I run the query:
    SELECT
    ROWID, C.CODETABLE_ID, C.CODEVALUE_ID, C.DESCR, LENGTH (C.CODEVALUE_ID).
    C.OBSOLETE_DT, C.RECORDSOURCE, C.CREATED_DT,
    C.CREATEDBY, C.LASTUPDATED_DT, C.LASTUPDATEDBY
    OF CODEVALUE C
    Where LENGTH (C.CODEVALUE_ID) > 6

    the data type is varchar2 and I would get rid of the any extra blank space added to the column. in my case, if the length is greater than 6

    Hello

    user452051 wrote:
    Thanks for the reply. Why should I have this line?

    AND codevlaue_id! = TRIM (codevalue_id) - see note below
    ;

    I just changed my post when you posted this. The explanation is there now:

    Frank Kulash wrote:
    ...
    The condition "codevlaue_id!" = TRIM (codevalue_id)"does not change the results of everything, but it can make the most effective statement if there are lines where codevalue_id is on 6 characters long, but contains no additional space. It will prevent the triggers from firing and redo the data generated.

  • With the changes made in the Adobe Acrobat DC he has made things more difficult for me. All I want to do is to rename a file. Used to be simple. Please tell me how to rename a file without using the cloud. I'm not paying for storage when I have an SD card

    Hate the new update.  I need to rename files and cannot do without using the cloud.  Could not sign in the cloud free services.  Someone knows how to rename the files with Adobe Acrobat DC? I use a HD with Android corner.

    Do you have any file manager installed on your device? This feature is no longer available in the latest version of Acrobat DC but we actively seek to provide the same in one of our future releases. To work around the problem, you will need to duplicate/rename the files using a third-party file manager application.

  • How to split the screen with 2 or more apps

    How do I split the screen when I have 2 or more open applications?

    Here are the instructions for use, two Mac apps side by side in split - view Apple Support

  • How to split the screen on 2 monitors?

    I have 2 screens (monitors) and to split the info on the main screen so that I / 2 if poster on the 1 screen and the other half appears on the other screen. How is that done?

    Keep it keys on your keyboard and type P until the desired option is selected (probably the option to extend my display ).

  • How to create the new folder on Oracle UCM?

    Hello

    After that I start the UCM_server I can't find how to create the new folder and I can't find the record of the 'Contribution records '. as shown in the attached picture.

    ucmfolder.JPG

    Hello

    Is it a new installation? You can configure the WCC with folder folder_g or framwork. You can use Server Admin-> component for Manager screen set up. It is recommended to use the framework with version dot 8 for optimizing the performance and scalability.

    About java applet question please check forums UCM browser compatibility issue

    Internet Explorer
    1. Click on Tools , then Internet Options
    2. Select the Security tab, and then select the custom level button
    3. Scroll to script Java applets
    4. Make sure the enable radio button is checked
    5. Click OK to save your preferences
    Chrome

    Chrome 42 version and more. From Chrome version 42 (released in April 2015), Chrome has disabled the way the browsers support plugins. More information

    Firefox
    1. Open the Firefox browser or restart it if it is already running
    2. In the Firefox menu, select Tools, and then click the option Add-ons
    3. In the Add-ons Manager window, select Plugins
    4. Click on plugin Java (TM) Platform (Windows) or the Java Applet plug-in (Mac OS X) to select the option
    5. Ensure that the option selected is Ask to activate or enable always or on older versions of Firefox, click the Activate button (if the button is disable, Java is already enabled)
    Safari
    1. Click on Safari and select Preferences
    2. Choose the Security option
    3. Select allow Plug-ins, and then click manage the Web site settings
    4. Click on the Java element, select an option (Ask, authorize or allow always) in the drop-down list When you visit other Web sites
    5. Click done, and then close the Safari preferences window
    Opera 4.x and Up
    1. Opera for Windows does not use Java, but an embedded already inside the Opera Web browser version.
    2. Opera for other platforms can supports Java. Please consult your Opera Platform documentation.
    3. For more information, please see the following Opera support article:
      Support for the Java software at the opera

    Thank you

    Amey

  • How to remove the XML prologue in Oracle?

    Our system works as follows:

    1. place a piece of XML code in the database as a CLOB
    2 database converts this value to XMLTYPE (stored as a CLOB (you can skip this, Marco * {;-)))))
    3. a request then reads XML from the database and inserts it into another bit of XML
    4. the application continues his treatment based on this new composite XML.

    So far, the XML that is loaded into the database in step 1 (for various systems) has never contained a prologue. However, a new system came along and is now passing in a prologue. There are problems of application in step 3.

    Apart from trying to get the new system do not spend in the prologue, is there a way to remove it of in Oracle?

    I came up with two solutions are not elegant:

    1. use XMLTABLE to retrieve the main root node (which might be different, depending on the system sent in the data and could change)
    2 convert the prologue in a commentary, using REPLACE the product, before converting the CLOB in an XMLTYPE.

    If I was forced to use one of the following methods, I would go with 2, but I really, really hope that there is a better way to do it.

    Someone at - it any other suggestions, please?

    PS. We are currently on 10.2.0.4 and are about to move to 11.2.0.3, but the solution is to work on both versions, for more fun and excitement!

    It's error, the application gives: "error obtaining Exception of SAX for additional information: no processing instruction begins with"xml"" who says that the app dev is due to the presence of the prologue in the middle of xml, the app has build up.

    So, basically, the app just "glue" XML in the middle of the other regardless of the structure? What kind of design is?
    IMO, the application needs to be fixed, not the XML input.

    A lot about how to add the prologue, nothing on how to remove it!

    You can use the XMLQuery function to get the root element:

    SQL> create table tmp_xml3 of xmltype
      2  xmltype store as basicfile clob;
    
    Table created
    
    SQL> insert into tmp_xml3 values (xmltype(''));
    
    1 row inserted
    
    SQL> select * from tmp_xml3;
    
    SYS_NC_ROWINFO$
    --------------------------------------------------------------------------------
    
    
    SQL>
    SQL> select xmlquery('*' passing object_value returning content)
      2  from tmp_xml3;
    
    XMLQUERY('*'PASSINGOBJECT_VALU
    --------------------------------------------------------------------------------
    
     
    

    Published by: odie_63 on August 22, 2012 15:26

  • How to know the version number of Oracle Developer Suite?

    Hello

    I installed 11.5.10 CU2 on Windows XP SP2.
    I have here is dirs after installtion:

    (1) D:\orclapps\orclappsappl
    (2) D:\orclapps\orclappscomn
    (3) D:\orclapps\orclappsdata
    (4) D:\orclapps\orclappsdb\9.2.0
    (5.1) D:\orclapps\orclappsora\8.0.6
    (5.2) D:\orclapps\orclappsora\iAS

    Suite notes 391564.1 . I want to know Oracle Developer Suite version choose fix appropriate according to point 3.3. How can I find out Developer Suite number.

    Thank you.

    We discussed in the forum before, please see these discussions/docs, it should be useful.

    How to find the developer version
    How to find the developer version

    How to get Forms Oracle Oracle Applications 11i Command Line [ID 392793.1] Version

    Thank you
    Hussein

  • How to read the Statspack report in Oracle 11.2 g Standard Edition

    Dear all,

    I use Oracle 11.2 g Standard Edition in the laboratory.

    For the performance tuning, how to read the Statspack report?

    Please note I cannot use the feature of Oracle AWR due to the Limitation of the license. Thus, as if I will generate report AWR with Oracle Standard Edition, it will be not correct error and printing "time DB is equal to zero for any report interval."

    Sumit-
    Bangalore, India

    The CWA requires additional licenses - Oracle's Diagnostics Pack.
    http://download.Oracle.com/docs/CD/E11882_01/license.112/e10594/options.htm#CIHIHDDJ

    This is only available for the Enterprise Edition licenses on top. I don't know anyway to the CWA standard edition licenses, so I recommend against using it even where it does not on its own.

Maybe you are looking for

  • How can I remove annoying clicking noise when opening new tab?

    I have goggled it and it says something of non-script (I'm not running) and nothing else that sounded remotely close to my problem. Basically, every time I open a new tab (which I do tons of) I hear the most odious type click hard and he's pushing me

  • Satellite P200-1JY and Win7 - SDHC card can not be read

    HelloI am owner of a Satellite P200-1JY, my OS is windows 7 and I can't read SDHC cards, but only the SD card.On the same PC under windows XP, I could read SDHC cards!So I should have a driver problem? Thanks for your help.

  • Impossible to install an old Hanes program (Tshirt maker) that runs under Windows 95/98 Windows Vista

    I have an old (Tshirt maker) Hanes program that runs under Windows 95/98. My Vista computer will not work the old program. I dug my old laptop that works under Windows 98 and, of course, it took the program, but I can't figure out how to get the logo

  • Read audio streaming...

    Hi all I want to play the song streaming. I want to play the audio file. But instead of the connection with the specific file. I want to skip the array of bytes to the stream and then play these bytes to the players. How can I achieve this?

  • Licenses of telepresence

    Hi all Hope this does not sound very stupid. What is the difference between the following license two of the Cisco telepresence room: (1) LIC-MX200-MS - MX200 G2 MultiSite Option (2) LIC-TP-SMP-EP - shared multi-party Lic for 1 session simultaneous I