How to write data to existing file using spool command?

Hi,
I am calling a stored procedure from a shell script. This stored procedure is having a CLOB object as an OUT parameter. How to write the data in CLOB object a existing file which is there in my client system. Below is the shell and sql scripts.
Shell script
( echo "hello" ) > /root/file.txt
sqlplus -s $user/$pass@$tns @/root/proc.sql /root/file.txt << EOF
EOFSQL script
set pages 0
set trimspool off
set serveroutput off
set feedback off
set term off
set echo off
variable out CLOB
define file='&1'
begin
pack.proc(:out);
end;
spool &file
select :out from dual;
spool offThis code writes contents of the OUT variable to file.txt, but my existing data ('hello') is lost. Please help me.
I figured the it...Use append in the spool command... :)
Edited by: Balaji on Jul 19, 2012 8:55 PM

>
Hi Balaji
I figured the it...Use append in the spool command... :Please mark the thread as answered as per the FAQ.
Paul...

Similar Messages

  • How to write data to text file using external tables

    can anybody tell how to write data to text file using external tables concept?

    Hi,
    Using external table u can load the data in your local table in database,
    then using your local db table and UTL_FILE pacakge u can wrrite data to text file
    external table
    ~~~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_7002.htm#i2153251
    UTL_FILE
    ~~~~~~~~~
    http://download-east.oracle.com/docs/cd/B19306_01/appdev.102/b14258/u_file.htm#sthref14093
    Message was edited by:
    Nicloei W
    Message was edited by:
    Nicloei W

  • How to Write data in Excel File using java

    Hi
    can anybody help me to write data in excel file
    using java code
    Thankx In Advance

    How much are you willing to pay for that?
    If you want it for free, http://jexcelapi.sourceforge.net/

  • Not able to extract performance data from .ETL file using xperf commands. getting error "Events were lost in this trace. Data may be unreliable ..."

    Not able to extract  performance data from .ETL file using xperf commands.
    Xperf Commands:
    xperf –i C:\TempFolder\Test.etl -o C:\TempFolder\BootData.csv  –a process
    Getting following error after executing above command:
    "33288636 Events were lost
    in this trace. 
    Data may be unreliable
    This is usually caused
    by insufficient disk bandwidth for ETW lo
    gging.
    Please try increasing the minimum
    and maximum number of buffers
    and/or
                    the buffer size. 
    Doubling these values would be a good first at
    tempt.
    Please note, though, that
    this action increases the amount of me
    mory
                    reserved
    for ETW buffers, increasing memory pressure on your sce
    nario.
    See "xperf -help start"
    for the associated command line options."
    I changed page size file but its does not work for me.
    Any one have idea, how to solve this problem and extract ETL file data.

    I want to mention one point here. I have total 4 machines out of these 3 machines above
    commands working properly. Only one machine has this problem.<o:p></o:p>
    Hi,
    I consider that you can try to use xperf to collect the trace etl file and see if it can be extracted on this computer:
    Refer to following articles:
    start
    http://msdn.microsoft.com/en-us/library/windows/hardware/hh162977.aspx
    Using Xperf to take a Trace (updated)
    http://blogs.msdn.com/b/pigscanfly/archive/2008/02/16/using-xperf-to-take-a-trace.aspx
    Kate Li
    TechNet Community Support

  • How to write a CLOB to file using UTF-8

    I'm new to java and I have the following problem.
    I need to write a CLOB to file using the UTF-8 characterset (I'm generating an xml file). My database characterset is WE8ISO8859P15.
    I've tried the code below but the resulting output fails validation in an xml editor due to an 'invalid character' error :
    create or replace
    and compile
    java source named "ClobUtil"
    as
    import java.io.*;
    import java.lang.*;
    import java.sql.*;
    import java.util.*;
    import oracle.jdbc.driver.*;
    import oracle.sql.*;
    public class ClobUtil {
    public static void save(CLOB clob, String filename) throws Exception
    Connection conn = DriverManager.getConnection("jdbc:oracle:kprb:");
    conn.setAutoCommit(false);
    InputStream is = clob.getCharacterStream();
    FileOutputStream os = new FileOutputStream(filename);
    int size = clob.getChunkSize();
    byte buffer[] = new byte[size];
    int length;
    while ((length = is.read(buffer, 0, size)) != -1) {
    os.write(buffer, 0, length);
    is.close();
    os.close();
    conn.close();
    I see that the getCharacterStream() method returns a Unicode character stream but how do I output this to file ??
    Thanks in advance

    File file = new File( "myfile.utf8" );
    FileOutputStream fos = new FileOutputStream( file );
    OutputStreamWriter osw = new
    OutputStreamWriter( fos, "UTF8" );
    Writer w = new BufferedWriter( osw );
    PrintWriter out = new PrintWriter( w );
    Or whatever you need. Note that this merely allows you to specify the encoding to be used in the output file, it does convert the encoding for you. I think in your case this will work since you already know the output stream will not contain the full range of UTF8 characters anyway.

  • How to write data to xml file?

    Hi,
    I have done a project which read data from a web then write in log file.
    Now i want to write data in xml file.
    how to write?
    i read some java and xml tutorial, quite quite difficult.
    Who can give a simple example with some comments?
    If you also give some tips on learning java web services, i will be very appreciated.
    Thanks
    Yang Bin

    Choose Xerces2.4 to serialize the DOM object is an option.
    javac XercesTest.java -classpath xmlParserAPIs.jar;xercesImpl.jar;.
    java -classpath xmlParserAPIs.jar;xercesImpl.jar;. XercesTest test.xml
    below is the source file: XercesTest.java
    //JAXP
    import javax.xml.parsers.*;
    import org.w3c.dom.*;
    //APACHE SERIALIZE FUNCTION
    import org.apache.xml.serialize.*;
    class XercesTest
    public static void main(String[] args) throws Exception
    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    Document doc = builder.parse( new File( args[0] ) );
    File f = new File( "copy_of_"+ args[0] );
    OutputFormat format = new OutputFormat("xml","UTF-8",true ) ;
    FileOutputStream fout = new FileOutputStream( f );
    XMLSerializer ser = new XMLSerializer(fout, format );
    ser.serialize( doc );
    hope it's helpful
    land

  • How to write newline character to file using bytes along with content

    Hi All,
    I need to write headers into the file using byte[]. I am creating the strings of header which will form the different rows in the file. I am new to java and would like to know how to embed new line character so that when the byte[] is written to file headers come in different rows.
    like
    hrd1:abcd
    hdr2:1234
    when i embed \n and \r in string and do getBytes() and write it to file, some boxes are written in the file and everything comes into single line.
    Please advice me the correct way .
    Thanks in advance.
    Cheers!!
    Puneet

    not sure about it, but i was always told that "\r\n" meant "new line" on "lots of documents" whereas "\n" only or "\r" only were meaningless on some type of documents

  • How to delete data from a file using IO package

    Hi All,
    i am trying to remove some content of the file.
    this content is not at starting of file not even at end of file.
    can anybody tell me how can i delete number of lines from file using IO package.

    iam having some data in text file .ex:in flowrist.txt
    12/5/07,500,300,6000 like many set of datas are
    there.In these if i want to delete the data based on
    the date which i specified.How to do this specific
    deletion?You need to open a stream to read in the file and then use the indexOf method provided in the Sting class to check if the line contains the date or whatever String you are looking for, if so then skip that line and store or re-write the lines you wish to keep, as well as some extra lines you may wish to add.
    Take a look below at this example found on Google.
    http://www.java-tips.org/java-se-tips/java.io/how-to-read-file-in-java.html
    The above read a file line by line and prints it to console. You should be able to modify this, instead of using System.out to print the line you should use index of to check the lines for a date/String. Index of return -1 if the String you specify is not in the line you parse.

  • How to write data into a file

    Hi
    I want to write data from a string into a file. I am created a directory and a .doc file . But when i write this data from a string into .doc file , its give an error : File not found exception
    But, when i check in my directory, a file is created with blank.
    My code is:
    import java.io.*;
    import java.util.*;
    import java.lang.*;
    class createFile {
         public static void main(String[] args) {
    try {
         String mss = "This is for dedo";
         FileInputStream fis;
         FileOutputStream fos;
    File file = new File("C:\\JD\\m4.rtf");
    // Create file if it does not exist
    boolean success = file.createNewFile();
         success = true;
    if (success) {
                   System.out.println("suc");     
                   fis = new FileInputStream(mss);
                   System.out.println(fis);
              fos = new FileOutputStream(file);
              int c;
                   while ((c = fis.read()) != -1) {
         fos.write(c);
                   System.out.println("mss");
              fis.close();
              fos.close();
         System.out.println("created");
    // File did not exist and was created
    } else {
    // File already exists
    } catch (IOException e) {
         System.out.println(e);
    regards
    madhu

    InputStream inputStream = new ByteArrayInputStream(mss.getBytes());Use this to push into the file>
    Ummm.... no. InputStreams are for reading, not for writing.
    Anyway, OP, you're making a mistake. You're trying to open a stream to a file called "This is for dedo". Use FileOutputStream(File file) constructor or FileOutputStream(String pathToFile). You can then wrap that stream with a PrintWriter or whatever you need.

  • How to write data in the Infocube using BI IP input ready functionality

    Hi All,
    Please help me in the following scenario...
    Input given to me is-- ZCUBSDID cube with associated role ZSP_BW_SAI_BUDGETS-DID_ALL.
    Query is ZR_V7_CO_PA_CH_PB_DID_BUDGET_2 based on agregation level ZALBSDID (& ZALBVDID) in infoarea ZDACOPA.
    I have to write data in the cube by using Input-Ready functionality of BI IP. Can you please provide me step by step procedure for writing the data in the cube as i am very new in IP side.
    Also if any further input required just let me know.
    My Analysis-> I checked that cube is in Planning mode and in Query Designer>Property Pane-->Planning Pane, Query is in Change mode and also associated Keyfigures are in Input-Ready enabled.
    Also i am able to access query in Analyzer.
    This is very critical for me and need to provide solution asap. Please update asap. It really be great help.
    Thanks & Regards
    Rupali Singh

    Hi,
      To enter data in to planning cube through manual planning, you can do the following,
    1. In a query that is used for manual planning, a cell is only input ready if each characteristic value of all the characteristics included in the aggregation level is unique. None of the aggregated values on the aggregation level are therefore input ready: Totals, subtotals and inner hierarchy nodes are not input ready.
    2. To be able to change values for calculated key figures (like Average Price as a quotient of Amount and Quantity), these must be based on input-ready formulas, and at least one operand must be input ready. More information: Defining Inverse Formulas (Designtime) and Inverse Formulas (Runtime).
    3. In order to change aggregated values (with respect to the aggregation level), these values must be disaggregated on all the data records that contribute to the aggregated value of the cell. More information: Disaggregation (Top-Down-Distribution).
    4. If a query used for manual planning includes a navigation attribute that is restricted using a fixed or dynamic filter or a restricted key figure, the system treats the navigation attribute as a normal characteristic. The rule under point 1 applies here. The system only reacts as though the navigation attribute were not part of the query if the navigation attribute is not restricted.
    5. In a query defined on a MultiProvider or a complex aggregation level that you want to use manual planning for, a cell is not input ready if the InfoProvider that is defined by this cell is:
                                a.      Not a real-time InfoCube
                                b.      A real-time InfoCube that has been switched to load mode
    6. If an input-ready query is executed in change mode, but the requested data is locked by another user, the query starts in display mode.
    For more details, you can refer to the following link,
    http://help.sap.com/saphelp_nw70ehp1/helpdata/en/43/0c033316cd2bc4e10000000a114cbd/frameset.htm
    Hope this helps you to solve your issue.
    Regards,
    Balajee

  • How to generate text file using spool command

    How can I use a SPOOL command with DBMS_OUTPUT.PUT_LINE with PL/SQL to produce text file on oracle client machine.

    You could try using a REF CURSOR as an alternative. Bare bones example listed below:
    --- SQL Script
    SET FEEDBACK OFF
    COLUMN first_name FORMAT A25
    COLUMN last_name FORMAT A25
    VARIABLE example_data REFCURSOR
    BEGIN
    example.get_data(:example_data);
    END;
    SPOOL example_data.txt
    PRINT example_data
    SPOOL OFF
    -----Output in example_data.txt
    FIRST_NAME LAST_NAME
    First Name 1 Last Name 1
    First Name 2 Last Name 2
    First Name 3 Last Name 3
    First Name 4 Last Name 4
    First Name 5 Last Name 5
    First Name 6 Last Name 6
    First Name 7 Last Name 7
    First Name 8 Last Name 8
    First Name 9 Last Name 9
    First Name 10 Last Name 10
    -----Example package used in SQL Script
    CREATE OR REPLACE PACKAGE example
    IS
    TYPE result_set IS REF CURSOR;
    PROCEDURE get_data
    p_result_set OUT result_set
    END;
    SHOW ERRORS
    CREATE OR REPLACE PACKAGE BODY example
    IS
    PROCEDURE get_data
    p_result_set OUT result_set
    IS
    BEGIN
    -- replace this with your query
    OPEN p_result_set FOR
    WITH fake_data AS (
    SELECT
    'First Name ' || level first_name,
    'Last Name ' || level last_name
    FROM DUAL
    CONNECT BY LEVEL <= 10
    SELECT *
    FROM fake_data
    END;
    END;
    SHOW ERRORS
    SPOOL OFF

  • How to write Data from INI file to Ring control

    Hai,
    I need to write the Data read from INI file to a RING control.While doing this operation using Variants i am getting error.
    I will be pleased if somebody help me.I have attached the Particular INI file and the VI. 
    Solved!
    Go to Solution.
    Attachments:
    Read Serial IO INI data.vi ‏34 KB
    Serial IO paramters.ini ‏1 KB
    Serial Engine Initialize.ctl ‏6 KB

    Adding data to ring
    Kudos are always welcome if you got solution to some extent.
    I need my difficulties because they are necessary to enjoy my success.
    --Ranjeet
    Attachments:
    Adding data to ring.vi ‏10 KB

  • How can I navigate through a file using keyboard commands?

    For example, if I wanted to go to Scene 1, frame 2 if I press escape, what would the code be for that?

    what's the trace output using:
    stage.addEventListener(KeyboardEvent.KEY_DOWN, keydownF);
    function keydownF(e:KeyboardEvent):void{
    trace(e.keyCode,Keyboard.ESCAPE);
    if(e.keyCode==Keyboard.ESCAPE){
    gotoAndStop(2,"Scene 1");

  • How to write data in differt line in .txt file

    Hi all,
    I am tring to write data on one file using utl_file,
    the first cursor loop write data on first line of the file using
    utl_file.put_line(..........................);
    end the second cusor loop write the data on secion line of the same file using
    utl_file.put_line(..........................);
    file format we are given as .txt;
    problem we are facing is when we open the file in notepad all the data is showing in one line...
    same file if we open another tools like edit plus, word pad etc it showing the write formate( line by line)
    Can any one help on this we need to set any setups in note pad????????????/

    As others have said it sounds like an operating system difference.
    If your Oracle is installed on a unix based server then the file will be written using Unix style newlines which are just Line Feed characters.
    In Windows environments a newline is considered to be made of the Carriage Return/Line Feed character pair, not just the Line Feed.
    Some applications such as MS Word or Wordpad can read Unix style linefeeds and interpret them as you expect as a Newline. However Notepad doesn't.
    When you transfer the file from Unix to Windows, usually this is done using an FTP based mechanism. If you transfer the files using FTP Binary mode, then every byte of the file is transferred as it is on Unix, and the file will essentially be a unix file on a windows system. If, however, you transfer the files (from Unix to Windows) using FTP ASCII mode, then whenever FTP encounters a LineFeed character it will convert it to a Carriage Return/LineFeed pair of characters, so that the file will appear correctly in Notepad. Likewise if you transfer files from Windows to Unix in ASCII mode, then Carriage Return/LineFeed pairs of characters are converted to just a LineFeed character so that the file becomes Unix compatible. Note, you shouldn't transfer binary files in ASCII mode as it can corrupt them, it's only intented for text based files.

  • Writing Data to a file using TEXT_IO in Forms

    I have a situtation where i have 5 columns and having arabic as well as english data. when i want to write this data to a txt file using TEXT_IO in a specific format, it writes to a file but as soon as it finds an arabic field, it changes the posistion. how can i write to a txt file in the posistion i want???

    vaishnavinatarajan wrote:
    How to write data to a file without leaving any blank lines in the file? How to check if the cursor is placed in the corner of a notepad file using LAB VIEW?
    If you write data to a file, simply don't include any blank lines. We cannot give more specific advice unless you are telling us how you are writing. Are you writing to a new file or appending to an existing file. If the blank lines already exist, you need to read the entire file, remove the undesired lines from the string, and write the data back.
    Notepad files don't have any "corners". Please describe what you are trying to do.
    What is "LAB VIEW"?
    LabVIEW Champion . Do more with less code and in less time .

Maybe you are looking for

  • I cant download apps. On ipad2,  prevented by Error 1004. Any answers?

    Does anyone know what is error 1004 preventing apps. Download on ipad2?

  • Error while loading Masterdata Txt using process chains

    Hi Guru's               I am loading the masterdata texts for infoobject 0material, i am getting the following error: "0MATERIAL : Data record 24 ('1215619 E '): version '1215619 ' is not valid     " Points assured. Thanks in advance. Peddinti

  • Count the number of records in a group

    Hi , My requirement is to display in the BI reprt - records in Order Entry Line Items based on several conditions on the fields. If the above conditions do not returm any records ,show an error message - NO DATA FOUND. 1.checked in standard RTF templ

  • Appending user id to field in header with iPlanet 6.0

    I am maintaining an iPlanet 6.0 server that handles a few static web pages and proxies to a web logic server and an oracle 9ias server. The iPlanet server is setup to authenticate users via Basic Authentication against an OpenLDAP server. I would llk

  • RGB, Luminosity, and Black Point

    I have an image shot in a forest, with a footbridge over a stream and a path in it. It has a lot of green, naturally, and a few blown out places in addition to dark shadows. While I like it, I've always found it a little flat. Looking at the histogra