Create a file in a format determined by the procedure


Hi gurus!


Your help is greatly appreciated.


I know that to create a procedure to write the file to CSV

But, I have to create a procedure to generate a fixed format file, for each field will be the length according to the length defies in tables and page headers, etc.
Please help me out here


This is the structure of the statae table.

************************************************
State:

NAME Not null VARCHAR2 (40 bytes)

STATE_CODE not null VARCHAR2 (2 bytes)

CONTINENTAL_US_FLAG null VARCHAR2 (1 byte)

**************************************************

sample data:

STATE_CODENAMECONTINENTAL_US_FLAG
AIANGUILLA
AGANTIGUA AND BARBUDA
AWARUBAN
BQBONAIRE, ST. EUSASIUS AND SABA
CWCURACAOTHERE

Data for the journal and the files in the PROCESS_REFERENCE table

ID_PROCESSUSNOM_PROCESSUSFILE_IDENTIFIERNOM_CHEMINPROCESS_FILE_NAMEDATE_FORMAT_FOR_FILE_NAMEDEBUG_FLAG
369FILE_STATEJOURNAL/ home/devtest/log /.< DATE >. FILE_STATE. JOURNALYYYYMMDDTHERE
340FILE_STATEOFF/ home/devtest/RPT /.< DATE >. FILE_STATE. OFFYYYYMMDDTHERE


It's the proc to generate the .csv gall which must be modidfied with Formate of fixed length, as I said above, I created.

CREATE OR REPLACE PROCEDURE SAMPLE_FILE
AS

fLOG_FILE UTL_FILE. TYPE_DE_FICHIER;
fRPT_FILE UTL_FILE. TYPE_DE_FICHIER;

vLOGFILE_PATH PROD. PROCESS_REFERENCE. NOM_CHEMIN % TYPE: = NULL;
vLOGFILE_NAME PROD. PROCESS_REFERENCE. PROCESS_FILE_NAME % TYPE: = NULL;
nLOGFILE_PROCESS_ID PROD. PROCESS_REFERENCE. ID_PROCESSUS % TYPE: = NULL;

vRPTFILE_PATH PROD. PROCESS_REFERENCE. NOM_CHEMIN % TYPE: = NULL;
vRPTFILE_NAME PROD. PROCESS_REFERENCE. PROCESS_FILE_NAME % TYPE: = NULL;
nRPTFILE_PROCESS_ID PROD. PROCESS_REFERENCE. ID_PROCESSUS % TYPE: = NULL;

vDEBUG_FLAG PROD. PROCESS_REFERENCE. DEBUG_FLAG % TYPE: = NULL;
nWRITE_COUNT NUMBER: = 0;
vSYS_TIME VARCHAR2 (30): = NULL;
bLOG BOOLEAN: = FALSE;


PROCEDURE PROC_LOG (LINE_IN IN VARCHAR2)
IS
BEGIN
BLOG of IF
THEN
vSYS_TIME: = TO_CHAR (SYSDATE, ' YYYYMMDD - HH24:MI:SS');
UTL_FILE. Put_line (fLOG_FILE, "the process has started the ' | vSys_Time |) ' - ' || LINE_IN);
UTL_FILE. FFLUSH (fLOG_FILE);
bLOG: = TRUE;
END IF;
EXCEPTION
WHILE OTHERS THEN
DBMS_OUTPUT. PUT_LINE (' ERROR IN THE NEWSPAPER: ' |) SUBSTR (SQLERRM, 1, 225));
LIFT;
END PROC_LOG;

BEGIN
SELECT REPLACE ID_processus, nom_chemin, (PROCESS_FILE_NAME, '< DATE >',
FILE_NAME TO_CHAR (SYSDATE, DATE_FORMAT_FOR_FILE_NAME)), NVL(DEBUG_FLAG,'N') DEBUG_FLAG
IN nLOGFILE_PROCESS_ID, vLOGFILE_PATH, vLOGFILE_NAME, vDEBUG_FLAG
PROD. PROCESS_REFERENCE
WHERE NOM_PROCESSUS = 'FILE_STATE.
AND FILE_IDENTIFIER = 'LOG ';

IF vDEBUG_FLAG = "Y" THEN

BEGIN
fLOG_FILE: = UTL_FILE. FOPEN (vLOGFILE_PATH, vLOGFILE_NAME, 'W', 32767);

bLOG: = TRUE;
EXCEPTION
WHILE OTHERS THEN
bLOG: = FALSE;
LIFT;
END;
END IF;



BEGIN
SELECT ID_PROCESSUS, NOM_CHEMIN,
REPLACE (PROCESS_FILE_NAME, '< DATE >', TO_CHAR (SYSDATE, DATE_FORMAT_FOR_FILE_NAME)) filename
IN nRPTFILE_PROCESS_ID, vRPTFILE_PATH, vRPTFILE_NAME
PROD. PROCESS_REFERENCE
WHERE NOM_PROCESSUS = 'FILE_STATE.
AND FILE_IDENTIFIER = 'OUT ';

PROC_LOG (' open the file: ' | vRPTFILE_NAME);

fRPT_FILE: = UTL_FILE. FOPEN (vRPTFILE_PATH, vRPTFILE_NAME, 'W');

UTL_FILE. Put_line ('STATE CODE', fRPT_FILE |) ','
|| "NAME" | ','
|| "CONTINENTAL_US_FLAG");

EXCEPTION
WHEN NO_DATA_FOUND THEN
UTL_FILE. Put_line (fLog_File,' in the FILE OPEN ERROR: ' |) SUBSTR (SQLERRM, 1, 1000));
LIFT;
END;


FOR CUR IN (select state_code, name, State, COUNTRY CONTINENTAL_US_FLAG)
WHERE ALPHA_CODE = STATE_CODE)

LOOP
UTL_FILE. Put_line (fRPT_FILE, CUR.state_code |) ' ,'
|| '''' || CUR. CONTINENTAL_US_FLAG | " «, »
||'"'|| CUR.name |' « ') ;

nWRITE_COUNT: = nWRITE_COUNT + 1;
END LOOP;

IF (fRPT_FILE) UTL_FILE.is_open
THEN
UTL_FILE.fclose (fRPT_FILE);

END IF;

PROC_LOG ('-> END PROCESS "");
PROC_LOG (' - TOTAL WRITTEN DOCUMENTS ARE -: ' | nWRITE_COUNT);

IF UTL_FILE.IS_OPEN (fLOG_FILE)
THEN
UTL_FILE. FCLOSE (fLOG_FILE);
bLOG: = FALSE;
END IF;


EXCEPTION
WHILE OTHERS
THEN
IF UTL_FILE.is_open (fLOG_FILE) THEN
PROC_LOG (' ERROR IN HAND!) » || SUBSTR (SQLERRM, 1, 250));
UTL_FILE.fclose (fLOG_FILE);
bLOG: = FALSE;

ON THE OTHER
DBMS_OUTPUT. PUT_LINE (' ERROR IN HAND!) » || SUBSTR (SQLERRM, 1, 250));

END IF;

END SAMPLE_FILE;
/

**********************************************************

Hello

Sorry, I don't understand.

If you do not want commas, then do not add commas.

You will probably not want quotes, either, in this case, do not add them either.  (If you do not want the quotes, you can concatenate them before calling RPAD.)  In this case, you won't need to NVL, but you must add 2 to the 2nd argument of RPAD, because the quotes will be an extra character 2.)

What do you want in the header file?  Do you really want a separate header file, rather than a header row (or two) in the same file?

Post a small example of data (CREATE TABLE and INSERT statements), and the (formatted) exact result you want from these data.

Tags: Database

Similar Questions

  • Print a Word 2013 file in PDF format, which prints the PDF, but when printing the PDF gereated on a laser printer, an error occurs: Error: invalidfont Offending Command: see battery :)

    I was wondering if anyone had a problem with printing PDF error codes that caused Word to Acrobat Pro Xi 2013. I converted fonts to local installation to common font - Arial, and the same error occurs.

    Help!

    Problem has been resolved the Konica Minolta C552 internal software had to be updated!

  • Ripple packaging error: Oh, Snap! Build request failed with the message: zip i/o error: no zip file or directory error: could not create output file

    I am trying to package and sign an application with ripple and I get this error: Oh, Snap! Build request failed with the message: zip i/o error: no zip file or directory error: could not create output file

    What can possibly be the problem here?

    Solved!

    I had the field output folder of the same value as the name of the archive

  • Lately, I have had difficulties dealing with somee of Photoshop Save tiff files!   As he works on the photo layer by layer and then decide to "save under" as a file it seems to get corrupted quite often.  Look, I'm a Windows of the image itself is

    Recently, I had a few difficult problems with Photoshop and trying to save files in TIFF format with all the preview in the folder looks more like a negative image seems to be missing information.  At the same time, I can record it all this is a JPEG or a PSD file, it seems no problem!  The previous and JPEG without problems!  I wonder if my Photoshop (CC 2015) program may be corrupt? I've updated some sixteen days ago or so and since then I have had this problem.  Suggestions of what the problem may be, suggestions of either try to go back or do a complete reinstall?  All this is very frustrating for an old man, just trying to make good photos!  Any help would be appreciated.

    Hi crusty

    Greetings!

    Recommend to reset preferences to default Photoshop

    Press and hold the keys Alt + Ctrl + Shift (Windows) or Option + command + shift (Mac OS) you launch Photoshop. You are prompted to delete the current settings. New preferences files are created the next time you start Photoshop.

    Or see How to remove/reset the Photoshop preferences

    * Backup stock/Modified Workspaces/Plugins before (if any)

    Let us know if this helps

    finished an excerpt in the record looks more like a negative image seems to be missing information.

    Could you share the image with us so that we can better help you?

    Concerning

    ~ Assani

  • How can I determine if a created PDF file has been encrypted in a unix or linux box

    I'm not sure if execution of the command file on my box will tell me if a given created PDF file is encrypted and with what level of encryption.  Is there a way to determine if the file is encrypted by using the Unix/Linux tools after the fact?

    Thank you

    Sam

    It is assumed that you want to do this in UNIX command line / Shell / Terminal.  There is a way that you could do that and that is to 'rolling' and build the tool with the Adobe PDF Library SDK.  Datalogics, which is an Adobe partner has a port of UNIX for the Adobe PDF Library SDK which could be used to create a tool that does this for you, but there is a very big opposition involved in the price structure for the Adobe's PDF library.

    http://www.Datalogics.com/products/PDF/PDFLibrary/

  • Discs CD - R burned with the Finder in Yosemite are unreadable by other players of CD despite the burned music files individual, .aif format. When it is burned with iTunes, all right. Any ideas?

    Discs CD - R burned with the Finder in Yosemite are unreadable by other players of CD despite the burned music files individual, .aif format. When it is burned with iTunes, all right. Any ideas?

    A CD to use in an Audio CD drive must be formatted as an Audio CD.

    Finder cannot create an audio CD, instead, it creates a data CD.

    Therefore, use iTunes to create create an Audio CD.

  • Basic binary file not read unless placed in the Exact Format, it is from?

    OK, check this.  This just makes no sense to me.  First, you will need to run it and create two files.  You will get an error at the close.  Now... Here's what makes no sense to me.  If you enable the disabled diagram and read this file, you can watch how the file is read and interpreted data.  How is it different and not causing no not a mistake?  I took the U8 and changed its original format of Boolean Array [8] and received an error message.  Which means that the data has been read as a U8 at some point.  But... for any reason, cannot be read and displayed as a U8.  What is happening with this?  What I don't understand?

    Freeshape wrote:

    Huh... no reading and writing.  Read or write.  Gotcha.

    Not quite.  It is hence is the file pointer.

    The file pointer is where in the file will be read or written, according to what you are doing then.  When you write to a file, the file pointer is set to be directly after what you just wrote.  When you write a new file, the file pointer is at the end of the file.  When you try to read when the file pointer is at the end of the file, an attempt to read at the end of the file is located.  But there is that nothing so he could read it.  As a result, you get an end of file error.

    So if you added a file position set to set the file at the beginning of the file pointer, you can read your byte without error.

  • Save the file in pdf format

    Help! Pressed for time!

    Need to save files in pdf format, so I can have received their approval. When I save as pdf all encrypted fate (?) Not my file!

    Need to save files in pdf format, so I can have received their approval.

    Here is the program I use to create PDF files: http://pdf-redirect.en.softonic.com/ , it installs as if it were another printer.

  • convert files to email in pdf format to transfer the thumb in training

    convert files to email in pdf format to transfer the thumb in training

    convert files to email in pdf format to transfer the thumb in training

    • What email program are you using?
    • They have in PDF format, or just readable?

    If you use Outlook Express, you can create a folder on the desktop (or elsewhere) and drag messages from OE to it. B it will be readable EML files. If it is necessary to convert them to PDF format, there are many EML to PDF converters available.

    http://www.Google.com/search?q=eml+to+PDF+Converter&RLS=com.Microsoft: en - us & ie = UTF-8 & oe = UTF-8 & startIndex = & startPage = 1

    There are also some DBX to Converters PDF, but if you want to waste time in the message store, make sure you convert a copy of the dbx file and not the original. Otherwise, it will not open in OE.

    http://www.Google.com/search?q=dbx+to+PDF+Converter&RLS=com.Microsoft: en - us & ie = UTF-8 & oe = UTF-8 & startIndex = & startPage = 1

    Bruce Hagen
    MS - MVP October 1, 2004 ~ September 30, 2010
    Imperial Beach, CA

  • When I try to burn a DVD with Windows DVD Maker, he says that the file is not a valid project create DVD file. Why?

    When I try to click on add items in Windows DVD Maker, it will allow me to select a file, then it tells me that the file is not a valid project create DVD file. Why?

    What is the format (extension) of the files of the selection?

    Windows 7 - burn a video DVD with Windows DVD Maker disc
    http://Windows.Microsoft.com/en-us/Windows7/burn-a-DVD-video-disc-with-Windows-DVD-Maker

  • How to extract the same song, several times using different bit rates or formats and store all the digital music files in WMP 12 default on the same HDD music library

    Using Windows Media Player 12 (w/under Windows 7), "can I ripping the same song, several times, using different bitrates & and/or formats and store all the digital music files in the music library by default WMP - 12, on the same hard drive?

    1.) #1 goal: tear up the same song repeatedly, w / "different rates" as a WMA file.

    2.) #2 goal: tear up the same song repeatedly, w / "different rates" as an mp3 file.

    3.) #3 objective: NOT to each subsequent copy (version) of the song, deleted & and/or replaced by the previous version of the song [even].

    4.) question Bottom Line Up Front--> is Windows Media Player 12 (included with the Windows 7 operating system) are able to achieve '#1 objectives; #2; & #3 above?

    5.) details/example: I want to tear the piece "Maria Maria by Carlos Santana" to my laptop as a Windows Media Audio [WMA] file.  In addition, I would like to rip the song 'Maria Maria' three several times with 3 different bitrates in format WMA; and, as an MP3 file.  Therefore, my final result wished (after the extraction process), will take place the four 4 audio files split up as follows: (a) 'Maria Maria by Carlos Santana'--> Format: file WMA; Ripped @128 Kbps bitrate.  (b) ' Maria Maria by Carlos Santana'--> Format: file WMA; Ripped to the "Variable bit rate; (c) ' Maria Maria by Carlos Santana'--> Format: file WMA; Ripped commissioning "Lossless." and (d). 'Maria Maria by Carlos Santana'--> Format: MP3 file. Ripped @256 Kbps bitrate.

    6.) my preference: I do NOT want to rename the file (s). {for example, 'Maria Maria by Carlos Santana' renamed/changed for--> "Maria_Maria_by_Carlos_Santana_128kbps.wma",...} 'Maria_Maria_by_Carlos_Santana_256kbps.mp3 '; etc.}.  In addition, I am not concerned about the additional disk space that will be consumed after multiple copies of the same song with different speeds of transmission and different formats.

    7.) my experience w / Windows Media Player 10 (w / the operating system of Windows XP): using WMP - 10, my goal (s) described above is not a problem at all.  Simply insert the CD purchased by Carlos Santana, containing the song "Maria Maria"... Select the desired Format (WMA; WMA VBR; WMA Lossless; or mp3)... Select the desired flow rate (WMA... 128/160/192kbps_mp3: 128/192/256/320 kbit / s; etc.) ; and click on the "RIP" button to start the copy process on the hard disk of of Carlos Santana's "Maria Maria".  This process (w / WMP-10) would result in having the same song, copied on the hard disk, with levels of quality different "audio" (via the different bit rate settings); regardless of the format (MP3/WMA) which was chosen.

    8.) my experience w / Windows Media Player 11 (w / the operating system of Windows XP): using WMP 11, to described above of my objective (s) could not be reached e-a-s-i-l-y.  The problem with WMP - 11 - in short - which was after the desired selection "Rip settings" tab 'Options' of WMP - 11 (i.e., Format & Bit Rate) and heart-wrenching piece wanted to {'Maria Maria by Carlos Santana'} a moment later/second, WMP11 remove / would crush the previous version of the song [even].  Therefore, the program would NOT allow the user to have multiple copies of the same song on the hard drive of the PC; which obviously restricts a user to have the freedom to choose what level of quality digital audio, they prefer to listen to.

    9.) the ability to have multiple copies [at my descretion] of the same song (on my hard drive) with different bitrates and formats in my music library, is important for me because it has a direct impact on "how I enjoy MY music ', and in what form (audio quality), I choose to listen to my music.  {For example, when I exercise and listening to my camera, digital audio player (Zune), a song ('Maria Maria by Carlos Santana'), will usually be torn off at a lower rate due to the unit of capacity reduction of storage - compared to the storage capacity of notebook PCs/desktop/external hard drives PC.}  However, when I listen to my music through my home cinema or entertainment system (which contains a hard disk dedicated with a large storage capacity), I prefer to load the entertainment system with digital music files that have been ripped to WMA... with the bit being rate-setting is for the: settings "WMA Variable Bit Rate" or "WMA Lossless.

    10.) there you have it.  This is my first post in this forum.  I hope that [detailed] explanations, will be sufficient to encourage these "with knowledge & the hands on experience" using Windows Media Player 12 (as well as with WMP-10/WMP-11 respectively), by providing a [step] "How-to"... "solution to my situation.  It would be highly appreciated.  I'm looking forward-'the solution' - and relevant suggestions & and/or community feedback regarding my request for assistance.

    * Thank 'All' (that would) in advance... For your time & Assistance *.

    Certainly, you can, but I would say that they be in different folders, for your convenience as well as Windows.  You can create one for each debit/format, then you will know who is who.

    In Windows Media Player, on the toolbar, select Tools, Options, Rip, and then select the flow you want first, rip music, then change the folder (higher on the same tab) and rip again... and so on and so forth.

    When you are at home on your home theater, you can use the 320 bitrate folder, when you transfer to the Zune, you can use one of the lower bitrate files (although I personally tear it up to 320 and let the Zune reduce as he wants, even with the iPhone via iTunes, hard drive space is not really a problem here) my server has several hard drives, and I can always add more if and when space is low!

  • Folder permissions in Windows 7 - a program that creates a file always has the authority to check the size of this file?

    Hello

    Where I work, we have a phone call, saving application that creates records of calls as .wav files.

    Before placing each record in long-term storage, the application creates a copy of the file (which is smaller) MP3 and then made a calculation of the free space to ensure that there is place in the long term for the newly created file storage.

    As part of the application must check the size of the MP3 file that he had just created and - I thought - calculation of space under Windows 7 that determination of the size of the file is sometimes a failure.

    (I think I understand, is that a .net function allows to determine the size of the file.)

    My query...

    If an application has sufficient privileges to create a file in a folder on the drive C: of the PC default also always have the right to determine the size of this file?

    Or are these two completely separate rights?

    For example, is it possible to have with no other rights granted write access?

    Thank you very much.

    The order of the questions, you asked:

    Yes

    Yes

    NO.

    It is indeed possible to give the file 'write' - access to the account, but not 'read' - access. However, even in this case the account can determine the size of the file.

    Log in under the account you are using for the conversion allows you to confirm my answers. To see the size of a file, use Windows Explorer or the Console command "dir".

  • Creating a file of resources in Arabic

    I am localize my application and have managed to integrate 3 different languages.  I want to create an Arab .rrc file for my application.  One of my friends created the .rrc file and sent it across.  Eclipse, however, does not seem to like it when I load it into the project.  I get errors like "Integer required to line x: yy ' or ' should ' # ' around.

    Must the Arab .rrc file be in a specific format?  For the moment, it looks like a standard file of key/value pairs, viz.

    FIELD_ALL #0 = "arabictext [from right to left]";

    FIELD_YOUR #0 = "arabictext [from right to left]";

    FIELD_BASE #0 = "arabictext [from right to left]";

    I played a bit with the encoding of the file change to US-ASCII, ISO-8859-1, Cp1252, UTF8, UTF16, etc. within Eclipse, but still no dice.

    I use Eclipse JDE 1.1.2.201004161203 - 16.  I enclose an excerpt from the .rrc file if anyone wants to take a look.

    the CRR files are in ANSI format, the characters are encoded in unicode.

    Here is an example of my language file Chinese:

    LICENSE_ACCEPT #0 = "\u63A5\u53D7";

    I suggest that you create your empty language file in the jde/eJDE and use copy it + paste to fill it with the Arabic words.

  • How to create a file name variable with the County and the date?

    Objective: Create a file name variable with the County and the date

    Error: get a lot of error. Do you know how to change my code?

    Question: how to create a file name variable with the County and the date?

    Mini code:

    std::string * rawfilepath;
    std::string * rawfilename;

    rawfilepath = "./shared/documents/";
    RawFileName = rawfilepath + 'rawlog -' + 0 + '-.txt ';
    QFile file (rawfilename);
    If (file.exists ()) {}
    rawfilenamecount ++;
    RawFileName = "./shared/documents/rawlog-" + rawfilenamecount + "-.txt ';
    }

    Thank you for your attention,

    Thank tzander reminding me the idea. Method of cascades is not good for me because all of the kernel code is written by Native. If I change the channel to QString, I need to change a lot of codes.

    Solution is below.

    While (access (rawfilename, F_OK)! = - 1) {}
    rawfilenamecount ++;
    sprintf (format, RawFileName, rawfilenamecount);
    fprintf (stderr, "file exists");
    }

    Rawlog = fopen (rawfilename, "w"); Save the file in a specific path.
    fprintf (rawlog, "System Time (ms)" "");

  • How you copy mp3 files from the my music for a cd drive folder and keep the files in mp3 format, format it with windows 8

    in the past with previous versions of windows, you can easily copy MP3s to a cd and keep the files in format mp3, format thus creating an mp3 disc, you made by selecting the songs you want to copy on disk, you must select the songs of the my folder music and make a click right then on the song selected or songs , you would then select send, and then select the drive that contains the blank cd in it to send the songs to, you choose then to a standard audio CD or data cd, you must select the option data cd and the drive will keep the songs in mp3 format, it was all done using windows Explorer. I would like to do the same thing to do these discs mp3 on my computer windows 8, however I can not understand how do, can help a whole me with that?

    Hello

    I would ask you to check out the link and follow the steps in the article.

    Burn a CD or DVD in Windows Media Player

    http://Windows.Microsoft.com/en-in/Windows-8/burn-CD-or-DVD-Media-Player

    Hope that answers your query. You can write back to us for other queries/problems related to windows and we will be happy to help you further.

Maybe you are looking for

  • common indexer for a number of paintings

    Hi all Can someone tell me how to set up a number of paintings (string and entries numbers) using the control to the index of one of the paintings to the reversal of all the other tables Thanks for your help guys

  • OR DAQ6009 with sensor and LabVIEW

    I use the DAQ6009 OR and I try to attach a sensor sensitive resistant four to him. I placed a resistor in the circuit so the voltage divider rule is applied, but I'm not sure what channels to use? At the moment I have the 5Volts on the digital side c

  • 3 weeks hp-500 214 never no sound

    PC brand new never had any sound Re loudspeaker activated, they work Re pluged to the orange plug through tests to see if I had a map its 'yes '. test is not pluged in What now?

  • Remove 'blue bar' at the top of the screen

    I just installed Jabber 9.2.1 on a Windows 7 machine and noticed a "blue bar" at the top of the screen. Is it possible to disable this? See attached screenshot if you know what I mean.

  • Unrecoverable internal error: java.lang.NullPointerException when compiling

    Recently, I changed my code, and when I am compiling it, I got this error: Unrecoverable internal error: java.lang.NullPointerException   Previously, I had met this exception several times, but when running the application in the Simulator. I've trie