How to write the result of a SQL query to a text file?

I'm using Oracle 11 g and SQL Plus.

I have a large table called side.

Whenever I do


SQL > select * rating.

The output goes well beyond what can show the screen sqlplus. So, I want to store the result of this query in a text file.

How is that possible? Help, please. Thank you.

SQL > SPOOL results.txt
SQL > select * rating.
SQL > SPOOL OFF

Tags: Database

Similar Questions

  • How to connect the console to ExtendScript Toolkit prints to a text file

    Hi Chaps,

    I want to put prints in my entire Script and take the script logs.

    To do this, I need to connect the output of the entire console to a text file.


    Can someone tell me please how to write the console output to a log file?

    I would suggest placing the code of luda.dall in a function.  Then just call the function instead of $. writeln() to connect to the console and the file:

    function logMe (input)

    {

    var now = new Date();

    output var = now.toTimeString () + ":"+ entry;»

    $.writeln (output);

    var logFile = File("/path/to/logfile.txt");

    logFile.open ("e");

    logFile.writeln (output);

    logFile.close ();

    }

  • How to display the results of a MySql query in multiple columns?

    Hi, I know how to display PHP/MySq

    l of the results in a single column, but I'm really stuck to show

    Ying the results of several columns in DW CS4.

    Can someone help me with a code example? I'm new to php/mysql. Thank you

    Are you asking how to rotate the query results? Do a search for a horizontal loop. If this isn't what you're asking, please provide more details.

  • How to move the Page Item in SQL query

    Hello, I have a need to transmit a page element in a function, plsql on the way but none of it works according to the following. What Miss me?
    select aplsqlfunction(:P29_X) from dual; 
    I tried immediately, but no luck.


    : P29_X
    #P29_X #.
    & P29_X.
    P29_X

    Thank you
    R

    Published by: Rich V on June 6, 2010 16:55

    Well then...

    Select aplsqlfunction (V('P29_X') AS Xyz of double;

    Thank you

    Tony Miller
    Webster, TX

  • Need help to reduce the cost of my sql Query below 100 to optimize.

    Can you please suggest how to reduce the COST of my SQL query? Is it possible to get the < 100 COST?

    My goal:
    ------------------------

    To recover the data of length (a column is in normalised_event: table) corresponding to each type of call (which is to extract the column rc.abbreviation in reference_code: table) in a given range of dates. So I wrote the following as SQL below:

    ------------------------------------------------------------------------------------------------------------------
    Select nvl (sum (round(ne.duration/60,3)), 0), rc.abbreviation
    Since the rc reference_code, normalised_event not
    where to_char (rc.reference_code) = ne.full_path
    and rc.reference_type_id = 505002 AND
    trunc (don't. CHARGE_START_DATE) between trunc (to_date (January 1, 2008 "," dd-mm-yyyy hh24:mi:ss'))))
    and trunc (to_date (January 1, 2009 "," dd-mm-yyyy hh24:mi:ss'))))
    Rc.abbreviation group

    -----------------------------------------------------------------------------------------------------------------

    IAM using Toad Software which is taken in charge by oracle 9i.


    Explain the plan above query is:

    explain plan
    Set statement_id = "mp01" for
    Select nvl (sum (round(ne.duration/60,3)), 0), rc.abbreviation
    Since the rc reference_code, normalised_event not
    where to_char (rc.reference_code) = ne.full_path
    and rc.reference_type_id = 505002 AND
    trunc (don't. CHARGE_START_DATE) between trunc (to_date (January 1, 2008 "," dd-mm-yyyy hh24:mi:ss'))))
    and trunc (to_date (January 1, 2009 "," dd-mm-yyyy hh24:mi:ss'))))
    Rc.abbreviation group



    Select LPad (' ', 2 *(Level-1)). Level | '.' || NVL (position 0). ' ' ||
    Operation | ' ' || Options of | ' ' || Object_name | ' ' ||
    Object_type | ' ' || Decode (id, 0, Statement_Id |) "Cost = ' | Position)
    "Query plan.
    From Plan_Table
    Start with id = 0 and Statement_Id = 'mp01 ".
    Connect Id Parent_Id = prior
    And Statement_Id = 'mp01 ";


    ---------------------------Query Plan explained is----------------------------------------------------------

    1.555 INSTRUCTION SELECT mp01 cost = 555
    2.1 TYPE GROUP
    3.1 FILTER
    4.1 HASH JOIN
    5.1 TABLE ACCESS BY INDEX ROWID REFERENCE_CODE
    6.1 INDEX RANGE SCAN NON-UNIQUE I_REFERENCE_CODE_REF_TYPE
    5.2 PARTITION RANGE ALL THE
    6.1 TABLE ACCESS FULL NORMALISED_EVENT

    -Automatic tracking of the SQl query is:.

    recursive calls - 0
    DB block gets - 0
    compatible gets - 174
    physical reads - 0
    size - 104
    Parse count (hard) - 0
    Parse count (chess) - 0
    run the County - 2
    bytes sent via SQL * Net to dblink - 0
    bytes received via SQL * Net from dblink - 0

    I was wrong. Once again, this shows how it is dangerous to assume (I assumed that FBI was new in 10g because it is when I used them), and the power of the community to ensure that accurate information is provided.

    John

  • How to write the query

    Hello

    How to write the sql query

    I have three type of table as

    1 table emp

    EMP_ID FIRST_NAME DEPT_ID

    ---------- -------------------- ----------

    1 kumar 10

    2 sam                          20

    3 30 damu

    2 table dept

    EMP_ID SALE_ID DEPT_ID

    ---------- ---------- ----------

    1 101 10

    2 102 20

    3 103 30

    3. table sale

    EMP_ID SALE_ID SALE_AMT

    ---------- ---------- ----------

    1 101 7

    2 102 8

    3 103 9

    I want the result as

    EMP_ID DEPT_ID SALE_AMT

    -------      ---------   -            --------

    1                10                  7

    Thank you

    Are you looking for this?

    SELECT T1. EMP_ID,

    T1. DEPT_ID,

    W3M SALE_AMT

    FROM EMP T1,

    SALE T3

    WHERE T1. EMP_ID = T3. EMP_ID;

    OUTPUT:

    EMP_ID DEPT_ID SALE_AMT

    ------- ---------- ----------

    1         10          7

    2         20          8

    3         30          9

    If this is not the case, after the actual output, you need. Because that gives you the amount of sales deptwise

  • How to write the script in FDMEE below.

    How to write the script in FDMEE below.

    Script below is the FDM Script.How write in FDMEE.

    If (varValues (14) '113101' =) OR (varValues (14) '113201' =) OR (varValues (14) '113301' =) OR (varValues (14) = "252111") OR (varValues (14) '156101' =) then

    Result = "21_asd."

    Please help me on this issue.

    Kind regards

    Satheesh, S

    If you want to determine the id of the target account your opening assignment statement must be:

    Account = fdmRow.getString ("ACCOUNTX")

    As if - elif-instructions else keep lowercase stream operators. If you continue a command on multiple lines, then place parentheses is

    If (account == "113101") or (account == "113201") or (account == "113301") or (account == "113401") or (account == "113501") or (account == "113601") or (account == "215101") or (account == "215201") or (account == "215301") or (account == "215401") or (account == "215501") or (account == "215601") or (account == "252111") or (account == "156101"):

    fdmResult = "21_ADNIP".

    should be (also get rid of the unnecessary parentheses)

    If (account is "113101" account is "113201" or account is '113301' account is "113401" or account is "113501" or account is "113601" or account is "215101" or account is "215201" or account is "215301" or account is "215401" or account is "215501" or account is "215601" or account is "252111" or account is "156101"):

    fdmResult = "21_ADNIP".

  • How to enable the Java Script function in APEX 4.2.6 running on the result of an Xquery query.

    How to take a SQL query result in the source section of an APEX "agenda of the page" field and allow this request to be formatted using XML in an HTML format for a Java Script file to perform a function on the result?

    Currently I have the following text:

    To query the DB table and format the result as HTML:

    SELECT XMLELEMENT ("UL id ="ticker01"', XMLAGG (XMLFOREST (Scroll_Mess AS LI))") "item UL' OF Web_Ticker where Mess_Id < 10 order by Mess_Id;


    That displays the following:


    < UL id = "ticker01" > < LI > HELLO < /LI > < LI > HELLO < /LI > < /UL id = "ticker01" >

    I need the output of this to be visible to a JScript function that is currently called the "head of page", but there doesn't seem to be its scope? The function works correctly if there is a list in the page field items 'Text element Pre' but does not work correctly when used in conjunction with the query to generate a table form.

    If everyone is happy to help I would be grateful .

    James.

    Solved!

    In order for the request to be part of the DOM of the page of the APEX, the Java Script allows to perform its function on the result marked "HTML" to query, you must set page of the apex on which the query resides and then add the inner text of this page to a second variable for which the function of web ticker can run on as follows:

    $(function() {})

    var x = $("#P9_TICKER_DATA");

    var y = x [0] .innerText;

    x.Append (y);

    $("UL#ticker01").liScroll ();

    });

    From there, on the Java script is able to properly see the result of the query in HTML format.

  • How to write the even-odd fill feature?

    How to write the even-odd fill feature?

    Maybe like this:

    app.executeMenuCommand ('* ');

    01.jpg

    There is a command in the PathItem object named evenodd. I think that if you change the property of evenodd and get a member of a composite path path, you can achieve a desired result.

  • How to display the result of a java class in InputText?

    Hi all
    How can I get the result of the java classes to InputText or OutputText?
    also everyone in the forum can road map me to deal with Java in oracle adf because I am a beginner in oracle adf
    I saw a few samples in corner of oracle adf, but it is difficult for me.

    I use JDeveloper Version 11.1.2.3, technology of the Adf.
    My question is how to return the result of java Bean InputText or OutText
    Thank you

    see if you want to have show some .so beans instance variable value you can have a few bean .define managed a variable as
    string abc = "abc";

    create the getter set for her.

    in the value property of inputText or OutPutText write an el as #{beanscope.managedbeanName.abc}

  • How to display the result sqlplus in java?

    I want to call sqlplus to run some commands sql in java, but how can I print the result of sqlplus?

    In java code, I call sqlplus as:

    Process of p;
    Run the command
    p = Runtime.getRuntime () .exec (commandString);
    print the result of the command
    InputStream inputStream = p.getInputStream ();

    How to display the result of the execution?

    Published by: Yi on February 26, 2012 23:41

    You can use ProcessBuilder. Copy the following code starts sql * more and runs the script in the variable "filename". It displays the results in the console of NetBeans.

    import java.io.BufferedReader;
    import java.io.InputStreamReader;
    import java.io.File;
    import java.util.Map;
    
    public class test1 {
    
        public static void main (String args []) {
    
            test_script();
        }
    
        public static void test_script () {
    
            String fileName = "@test_table.sql";
            String sqlPath = "E:\\";
    
            String sqlCmd = "sqlplus";
    
            String arg1   = "user/password@sid"; -- plug in your user, password and db name
            String arg2   = fileName;
            try {
                String line;
                ProcessBuilder pb = new ProcessBuilder(sqlCmd, arg1, arg2);
                Map env = pb.environment();
                env.put("VAR1", arg1);
                env.put("VAR2", arg2);
                pb.directory(new File(sqlPath));
                pb.redirectErrorStream(true);
                Process p = pb.start();
              BufferedReader bri = new BufferedReader
                (new InputStreamReader(p.getInputStream()));
              BufferedReader bre = new BufferedReader
                (new InputStreamReader(p.getErrorStream()));
              while ((line = bri.readLine()) != null) {
                System.out.println(line);
              }
              bri.close();
              while ((line = bre.readLine()) != null) {
                System.out.println(line);
              }
              bre.close();
              System.out.println("Done.");
            }
            catch (Exception err) {
              err.printStackTrace();
            }
    
        }
    
    }
    

    Here is the content of the script at E:\\test_table.sql

    Prompt drop TABLE ANOTHER_TEST;
    DROP TABLE ANOTHER_TEST CASCADE CONSTRAINTS
    /
    
    Prompt Table ANOTHER_TEST;
    CREATE TABLE ANOTHER_TEST
    (
      BATCH_SEQ             NUMBER,
      BATCH_GROUP_ID        NUMBER,
      STATUS_FLAG           VARCHAR2(30 BYTE),
      OBJ_BEING_PROCESSED   VARCHAR2(80 BYTE),
      BATCH_RUN_START_DTTM  DATE,
      BATCH_RUN_END_DTTM    DATE,
      CREATE_DTTM           DATE,
      CREATE_USER           VARCHAR2(30 BYTE),
      UPDATE_DTTM           DATE,
      UPDATE_USER           VARCHAR2(30 BYTE)
    )
    LOGGING
    NOCOMPRESS
    NOCACHE
    PARALLEL ( DEGREE DEFAULT INSTANCES DEFAULT )
    MONITORING
    /
    
    COMMENT ON TABLE ANOTHER_TEST IS 'This is a test table.'
    /
    
    EXIT
    /
    
  • Want to write the results to submit the login form to log on the server

    I cooked up a little family site to share memories and old photos. This is a members only site and I use a PHP login script that compares the user name and password to a list.

    I would like to know
    (a) if someone tries to guess their way in.
    (b) If a member is having connection problems... We have a few not so computer savvy family members which eventually get frustrated and give up.
    (c) whose members are logging... It is a new effort, to run one year on a trial basis... and it is worth.

    To do this, I add code to take the results of any shipment (on my login form) and to add the results of this to some sort of log file that I can periodically review. Because the foundations are in place this (I think) not an otherwise difficult task. But I have no idea on how to do this and hope someone can show me.

    Thank you for your time and help

    Ralph

    If it helps, it's the PHP code that I guess deals with the connection.

    / Repairable none by the user under this item. */

    $php_self = $_SERVER ['PHP_SELF'];

    / * Clean up variables: we only do $user and $password of the form. */
    $submit = $_POST ['submit'];
    $user = ";
    $password = ";
    If ($_GET ['user']) {}
    $user = $_GET ['user'];
    $password = $_GET ["password"];
    }
    If ($_POST ['user']) {}
    $user = $_POST ['user'];
    $password = $_POST ["password"];
    }

    session_start();

    / * Check the couple login/password until you find the one that is correct, or re-display the login form. */
    $loginsuccessful = FALSE;

    {foreach ($authorization as $loginpair)}
    {If (($user == $loginpair[0]) & & ($password == {$loginpair [1]}))}
    $_SESSION ['user'] = $user;
    $_SESSION ["password"] = $password;
    $loginsuccessful = TRUE;
    }
    {If (($_SESSION ['user'] == $loginpair[0]) & & ($_SESSION ['password'] == {$loginpair [1]}))}
    $loginsuccessful = TRUE;
    }
    }

    If ($loginsuccessful = TRUE) {}
    / * The user is connected, go on our merry way. */
    echo $loginmsg;
    } else {}
    / * User does not match our valid connection, their decline to the form. */
    $loginmsg = "invalid username or password";
    require ($indexphp);
    "exit";
    }

    No, it's not particularly difficult. Of course, you use a login script you obtained, because the code is very different from the one generated by Dreamweaver. Judging from the code, you do not use a database to store the usernames and passwords. Thus, you probably want to save the details of an external text file.

    Add the following code where indicated:

    if ($_POST['user']) {
        $user = $_POST['user'];
        $password = $_POST['password'];
    }
    
    // New code goes here
    
    $logfile = 'log.txt';
    $date = date('j M Y H:i:s');
    $address = 'Unknown';
    if (isset($_SERVER['REMOTE_ADDR'])) {
         $address = $_SERVER['REMOTE_ADDR'];
    }
    if ($file = fopen($logfile, 'a')) {
      fwrite($file, "\r\n$date $address $user $password");
      fclose($file);
    }
    
    // end of new code
    
    session_start();
    

    This will create a text file named log.txt in the same folder as the logon script. Since it is a text file, it should ideally be outside the root of the web server, then you must change the value of $logfile to point to a file outside of the root of the server, but in a folder where the script is allowed to write.

    Whenever someone tries to connect, it will record the date and time, IP address, if known, and the user name and password submitted.

    Once you got this job, I suggest you change the following line:

    if ($file = fopen($logfile, 'a')) {
    

    Change to this:

    if ($file = @fopen($logfile, 'a')) {
    

    This will remove any error message if the script is unable to open the log file. However, you should not do that change until you have things market, because deleting an error will prevent you to discover what the problem is if this does not work.

  • How to write the select query for it

    Hello

    I had an html form and the area I drop down and he needs to select several values in the drop-down box. When I select multiple values then I have to write the query to SQL select statement.

    When I try to write the select statement and trying to run I get the error message.

    Select * from Table

    where emo_no = '1,2,3 '.

    That's how I write the query please suggest me how to write the query to select several values in the drop-down box.

    Thank you

    Use the keyword sql 'in '.  If you don't know how, I've heard good things about the book Teach Yourself SQL in 10 Minutes by Ben Forta.

  • How to display the results in the order based on the value of research

    Hi all

    How to display the results in the slot order.
     
    
    CREATE TABLE TEST( SONGID  NUMBER, TITLE   VARCHAR2(200))
    
    INSERT INTO TEST(SONGID,TITLE) VALUES (10,'AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (11,'CICCONE, MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (12,'DALLIN, MADONNA LOUISE/STOCK');
    INSERT INTO TEST(SONGID,TITLE) VALUES (13,'MADONNA');
    INSERT INTO TEST(SONGID,TITLE) VALUES (14,'MADONNA (A)/ AHMADZAI, MIRWAIS (C)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (15,'MADONNA (CA)');
    INSERT INTO TEST(SONGID,TITLE) VALUES (16,'MIRWAIS AHMADZAI, MADONNA');     
    INSERT INTO TEST(SONGID,TITLE) VALUES (17,'MIRWAIS (CA)/ MADONNA (CA),AHMADZAI');
    INSERT INTO TEST(SONGID,TITLE) VALUES (18,'MADONNA (CA),CICCONE');
    
    SELECT *FROM  TEST WHERE INSTR (TITLE, 'MADONNA') > 0
    
    output: 
    SONGID     TITLE
    10     AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
    11     CICCONE, MADONNA (CA)
    12     DALLIN, MADONNA LOUISE/STOCK
    13     MADONNA
    14     MADONNA (A)/ AHMADZAI, MIRWAIS (C)
    15     MADONNA (CA)
    16     MIRWAIS AHMADZAI, MADONNA
    17     MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
    18     MADONNA (CA),CICCONE
    
    Expected output :
    13     MADONNA
    14     MADONNA (A)/ AHMADZAI, MIRWAIS (C)
    15     MADONNA (CA)
    18     MADONNA (CA),CICCONE
    ..
    ..
    ..
    ..
    ...
    If the user makes a search with "MADONNA", I view the results as title begins with "MADONNA" first then the rest of the records.
    Please let me know is possible to show the results in this order.


    Kind regards
    Rajasekhar

    This can be a little more specific:

    SQL> SELECT *
      2  FROM   TEST
      3  WHERE  INSTR (TITLE, 'MADONNA') > 0
      4  ORDER  BY INSTR (TITLE, 'MADONNA')
      5           ,TITLE
      6  ;
    
                  SONGID TITLE
    -------------------- --------------------------------------
                      13 MADONNA
                      14 MADONNA (A)/ AHMADZAI, MIRWAIS (C)
                      15 MADONNA (CA)
                      18 MADONNA (CA),CICCONE
                      12 DALLIN, MADONNA LOUISE/STOCK
                      11 CICCONE, MADONNA (CA)
                      17 MIRWAIS (CA)/ MADONNA (CA),AHMADZAI
                      16 MIRWAIS AHMADZAI, MADONNA
                      10 AHMADZAI, MIRWAIS (CA)/ MADONNA (CA)
    
  • Don't know how to read the results of netstat EI s list? If I received 860592506 bytes sent from 43421482 how to convert MB? And does this mean byte received?

    Don't know how to read the results of netstat EI s list? If I received 860592506 bytes sent from 43421482 how to convert MB? And does this mean byte received?

    Hello

    This shows the total number of bytes transmitted and received via the Ethernet card. This is the total of the amount of use up to this day.

    This includes all the Web sites you have visited and emails you sent, etc..

    You can calculate using one of the following methods:

    Method 1:

    860592506 / 1048576 = 820,72 MB

    Method 2:

    Multiply 860592506 with 9.53674316 * 10 ^-7 that will give us the result in mega bytes.

    860592506 bytes = 820 MB 9MB not, accept my apology for the miscalculation.
    Similarly 43421482 acroos = 40MB

Maybe you are looking for