Best way to print result of query to file from pl/sql?

If I have a query, let's say 'select * form my_table', what's the best way to print it to a file from pl/sql?
Do I have to create a cursor, go through each line, and use some file output function? Or is there some clever way to say 'print this query to file!'

The rest of my procedure (the one generating the query itself) is in PL/SQL. So it needs to be done from there. Any tricks?
(What's paper? I meant 'write to file')

Similar Messages

  • Best way to spool DYNAMIC SQL query to file from PL/SQL

    Best way to spool DYNAMIC SQL query to file from PL/SQL [Package], not SqlPlus
    I'm looking for suggestions on how to create an output file (fixed width and comma delimited) from a SELECT that is dynamically built. Basically, I've got some tables that are used to define the SELECT and to describe the output format. For instance, one table has the SELECT while another is used to defined the column "formats" (e.g., Column Order, Justification, FormatMask, Default value, min length, ...). The user has an app that they can use to customize the output...which leaving the gathering of the data untouched. I'm trying to keep this formatting and/or default logic out of the actual query. This lead me into a problem.
    Example query :
    SELECT CONTRACT_ID,PV_ID,START_DATE
    FROM CONTRACT
    WHERE CONTRACT_ID = <<value>>Customization Table:
    CONTRACT_ID : 2,Numeric,Right
    PV_ID : 1,Numeric,Mask(0000)
    START_DATE : 3,Date,Mask(mm/dd/yyyy)The first value is the kicker (ColumnOrder) as well as the fact that the number of columns is dynamic. Technically, if I could use SqlPlus...then I could just use SPOOL. However, I'm not.
    So basically, I'm trying to build a generic routine that can take a SQL string execute the SELECT and map the output using data from another table to a file.
    Any suggestions?
    Thanks,
    Jason

    You could build the select statement within PL/SQL and open it using a cursor variable. You could write it to a file using the package 'UTL_FILE'. If you want to display the output using SQL*Plus, you could have an out parameter as a ref cursor.

  • What is the best way to compute the MD5 of a file from within a filesystem filter driver

    Greetings!
    I am developing a filesystem filter driver that monitors file creations. My driver is based on the sample code "scanner" in the DDK. I need to calculate the MD5 of the file in the PostCreate stage. I am using
    FltReadFile() to read the file where I have to read block by block - which I think is kinda inefficient. Is there a way to get the size of the file before I read ? That way I can allocate enough memory in advance and then read it in one shot.
    I don't see a FltXxxx function to read the size of the file. How do I do it ?? (Or if there is a another way to calculate MD5 that would work too)
    I also ran into another problem. For block by block reading, I use FltAllocatePoolAlignedWithTag/Free functions. I noticed that if I don't use the
    same exact variable to Free the block I get bsod. For example I allocate a block using a variable pBlock and then add it to an array of pointers. Later on I Free the blocks with array[index] - then I get the BSOD. The bug check code is BAD_POOL_HEADER.
    Any idea what is going on ? This is okay to do right ?
    Thanks
    ~B

    FltQueryInformationFile will get you the size information.  On the BSOD it is likely you are passing the wrong pointer back, give us a !analyze -v of the crash dump, so we can start the process of debugging.  Run your driver with "Driver Verifier"
    and enable special pool, to catch things.
    Don Burn Windows Driver Consulting Website: http://www.windrvr.com

  • What is the best way to find and remove unneeded language files from Mac OS X 10.8.4?

    I have tried Spring Cleaning and it finds the files and then quits!

    You can do this with a *FREE* utility called Monolingual.  Another app that apparently does all the work for you.  I’ve used it since Tiger w/never any problems.  Just make sure you read all of the instructions.
    However, there is a warning for *native English speakers*. Make sure you keep BOTH English and English (United States).
    Works on OS X 10.8 (Mountain Lion)

  • What is the best way to print from an iPad?

    I have the Printer Pro app, and it seems to do a good job locating my wireless printer, but it gets complicated to print webpages or pages documents. What is the best way to print from an iPad 2?

    If you have a compatible printer, use AirPrint http://www.apple.com/ipad/features/airprint.html and http://support.apple.com/kb/HT4356
    If not, you would need to purchase software, such as:
    http://itunes.apple.com/us/app/printcentral-for-ipad/id366020849?mt=8
    http://www.ecamm.com/mac/printopia/
    http://www.collobos.com/

  • What's the best way to print content of javax Object (JTable for example)?

    Hi there,
    1) I would like to know the best way to print content of jtable (for example)
    2) I would like to know how can I Print content of SQL statment (for example "SELECT ID, NAME FROM COMPANY")?
    Best Regard,
    Eyal
    [email protected]

    Depends on what you want printed. You can do something like System.out.println(myTable);but you may not like what you see. If you want to print anything else, extend JTable and create a new toString() method that prints out what you want.
    As for printing a SQL statement - assuming it is in a String, you can just do System.out.println(mySQLStatement);

  • Best way to print from iPad?

    Which app is best to print from iPad, iPhone?

    Well AirPrint is probably the best way to print from a iOS device but if you dont have a AirPrint printer then there are apps like print central that can help you

  • What is the best way to print from pages on my iPad 2?

    What is the best way to print a pages document directly from ipad 2?

    Purchase and use an AirPrint capable printer.  Everything is described here:
    http://support.apple.com/kb/HT4356

  • Best way to print from application

    Hi!
    I have an application handling employee information. I'm trying to figure out the best way to print all information liked to an employee. What is best? I want to generate the page with a good layout, not just plain text(pictures, different fonts). I've tryed to draw strings on a picture but there are problems with page brakes. Is it hard to generate html files from xml, and are there any good tutorials or is it better to use html?
    Thanks!

    I suppose your app need to print some type of report, right?
    If so, go www.google.com and take a look at Jasper (you can do PDF,HTML,etc)
    and IReports (to build the 'appearence file')

  • I'm buying a new Macbook Pro this week and am wondering what is the best way to copy over the software I have from my existing Macbook Pro to the new one? eg. Photoshop and Office etc. I no longer have the CDs.

    I'm buying a new Macbook Pro this week and am wondering what is the best way to copy over the software I have from my existing Macbook Pro to the new one? eg. Photoshop and Office etc. I no longer have the CDs.

    Ya know what I'm on a brand new MBP just about 24 hours old and you know whats been working amazingly for me. I have a 27inch iMac as well and i've just connected it to my network and been dragging files and apps across the network onto my new MBP. Its really working fast and its flawless. You could always do that option, Just go into sharing options and turn them on for both Macs. Then just click and drag. Of course they have to both be on the same network for this to be possible.
    Look at my network.
    Shared is what your looking at.  I click on there see all my computers files and then drag the ones i want form its folder to my MBP folders.  Hope that helps if your looking for a very simple way on a wireless network.

  • What is the best way to have access to OSX and OS9 from the same machine?

    What is the best way to have access to OSX and OS9 from the same machine?
    Do I need to partition the hard drive? Installed both Tiger and OS 9 on the G5 and it is having problems starting up properly.
    G5   Mac OS X (10.4)  

    And here is the prove for Edwin's message: Macintosh: Some Computers Only Start Up in Mac OS X

  • What is the best way to manage tasks?  I have moved from outlook and only have mail and ical

    What is the best way to manage tasks.  I have moved from a pc with outlook and have lost 'tasks' in that programme.  Do I have to rely on ical or can I download an app to manage business tasks?

    iCal does have reminders but its implementation of tasks is pretty wimpy. There are a number of programs that are better geared to the job. I was a level 4 procrastinator until I discovered Getting Things Done and for me Things is perfect. It lets me handle projects which are dependent upon multiple tasks in a no-nonsense easy fashion. Much less expensive and really not much more than a list maker is Wunderlist. Thankfully there's a ton of shareware offerings - check out MacUpdate.com and see what works for you.

  • Best way to import a 200GB single dump file

    I was given a 200GB size single dump file containing full export of a schema. can any please tell me whats the best way to import such a huge dmp file. I need to get this import done asap in QA for testing which will let us solve some production issues. step by step instructions if possible would be really helpful for me to complete my task asap.
    Thanks in Advance,
    krim.

    Hi Krim,
    Our dump files normally are never that big so that maybe you could face some other issue here.
    If your dump was a full DB schema dump like:
    $ exp username/password file=full.dmp parameter-list
    then the import should first drop the user in the target system
    SQL> drop user username cascade;
    this is to drop the existing schema before importing
    SQL> Create user according to your reqs
    $ imp username/password file=full.dmp full=y commit=y ignore=y
    Don't know which env you have to run this, but in our case for instance using an 8 X 1.6GHz Itanium2 Montecito a 14 GB dump takes about a couple of hours to import (with an EMC Clariion disk array). It's also true that Oracle imp (did you use exp or expdp ?) is not able as far as I understand to achieve parallelism like impdp where in case of multiple huge tables the import time could be sped up.
    Another thing you may want to check is if you have archive logging on, since the import will log there consuming time.
    Cheers,
    Mike

  • Is there a way to print out my itunes purchases, credits (from giftcards) and what is being charged to my credit ca

    Is there a way to print out my itunes purchases, credit (from gift cards) and what amounts are being charged to my actual credit card?  I have two children sharing this account (each with their own gift cards) and I'm trying to keep it fair on who spends what....etc.  PLEASE help.  I'm losing my mind! 

    The ability to connect to the printer or the G5 over the Internet will depend on your company's network. In the good ol' days of modems, you could use a dial-up connection to access your network remotely. Now with cable connections the same can be done, but there are a number of openings that need to be made by your IT dept to allow you access and to restrict others. So you should discuss your desire to remotely connect with them. They could share the printer so that once you are connected to your network, you could use IPP (Internet Printing Protocol) to connect to the printer share and still use the HP driver.
    PaHu

  • HT204003 how can i print a boarding pass image file from passbook?

    how can i print a boarding pass image file from passbook?

    I do not believe that Passbook supports printing. You can email, but not print. Then again I'm not sure what it actually emails, if that is a graphic of the card or what. I'm going to try it with my Starbuck's card, but there is no setting for printing within Passbook.
    EDIT: Actually it sends the email as an attachment for a Passbook card file, that cannot be handled by my computer. Hope that answers your question.
    Message was edited by: ChrisJ4203

Maybe you are looking for