Redirect the output of SQL*Plus to the file

Hi all,
I have the following command to run:
sqlplus username/password @myfile.sql
I don't know how to redirect the output to the file.
Also in the script myfile.sql I have the defined variable, &VP and
How can I substitute this variable(&VP) at the run time.
Thanks,
JP

Assumed you like to replace your defined variable VP by number 4. SInce it is posintional parameter,instead of wrinting &VP, write
VP:=&1
sqlplus>spool redirect.txt
sqlplus>@myfile.sql 4
sqlplus>spool off

Similar Messages

  • Procedure to save the output of a query into excel file or flat file

    Procedure to save the output of a query into excel file or flat file
    I want to store the output of my query into a file and then export it from sql server management studio to a desired location using stored procedure.
    I have run the query --
    DECLARE @cmd VARCHAR(255)
    SET @cmd = 'bcp "select * from dbo.test1" queryout "D:\testing2.xlsx;" -U "user-PC\user" -P "" -c '
    Exec xp_cmdshell @cmd
    error message--
    SQLState = 28000, NativeError = 18456
    Error = [Microsoft][SQL Server Native Client 10.0][SQL Server]Login failed for user 'user-PC\user'.
    NULL
    Goel.Aman

    Hello,
    -T:
    Specifies that the bcp utility connects to SQL Server with a trusted connection using integrated security. The security credentials of the network user,
    login_id, and password are not required. If
    –T is not specified, you need to specify
    –U and –P to successfully log in.
    -U:
    Specifies the login ID used to connect to SQL Server.
    Note: When the bcp utility is connecting to SQL Server with a trusted connection using integrated security, use the
    -T option (trusted connection) instead of the
    user name and password combination
    I would suggest you take a look at the following article:
    bcp Utility: http://technet.microsoft.com/en-us/library/ms162802.aspx
    A similar thread regarding this issue:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/b450937f-0ef5-427a-ae3b-115335c0d83c/bcp-connection-error-sqlstate-28000-nativeerror-18456?forum=sqldataaccess
    Regards,
    Elvis Long
    TechNet Community Support

  • How to write the output of a mapping into a file (OWB10.2

    Hi
    I am using Oracle 10.2.0.1 version of OWB.
    the task is to write the output of a mapping into a File (Flat File).
    Please help me out!
    Regards
    Abi

    Hi,
    Create the file format thru OWB and mention the location in OWB. Deploy the file and it will be ready to use for target load. Make sure the connection to the target loc is available.
    Regards
    Bharadwaj Hari

  • Does SSIS guarantee that it loads the data into SQL Server in the same order as it is in Excel

    Hi,
    We are trying to load several Excel files into SQL Server SSIS and we need to save the data in the database in the same order as it is in Excel..
    My question is, Does SSIS guarantee that it loads the data into SQL Server in the same order as it is in Excel. If so, we will add a sequence to ensure we have the order.
    Please advise.
    Thanks & Regards,
    Dhanumjay

    Thanks for your response.
    If it is one file then we can add an index column, but we have to load hundreds of files.
    How adding an index/key column to the table works unless SSIS picks and loads the data in the table in the same order as it is in Excel?
    Just to explain my question better,
    If excel has three rows  {a,b},{c,d},{e,f}, does SSIS ensure it loads the data in the same order in a table.
    Thanks.

  • While executing the query the output is completey different from the query

    Dear friends,
    We built a query and loaded the data for that infoprovider.
    While executing the query the output is completey different from the query what we have built.
    Output has no relevance to the query.
    Kindly help the same.
    Regards,
    Sathya

    HI Satya,
    In my opinion the issue is with your front end.
    Results should be identical in RSRT, BEx Analyzer (Workbooks) and the ABAP-Web since all three frontend tools use the "ABAP Runtime layer".
    It may differ In the Portal where the new "Java Runtime layer". (Java-Web.) is used.
    This is given in OSS Note 1296576 - Different Query Behaviour: ABAP - Java.
    So i think the problem lies in your analyser. If you are using Analyzer: BI Add on 7.X (Based on 7.10) try and get support package 8.
    Hope this helps.
    Thanks,
    Rahul

  • Where do I find the Output Pop Up Menu on the Soundtrack Interface?

    Where do I find the Output Pop Up Menu on the Soundtrack Interface?

    Assuming you are in Address Book, you choose the records you want to print and then the File/Print menu selection.
    If the printer menu comes up with only the name of the printer and "Presets" dropdown choices, you click on the arrow to the right of the printer name to expand the print menu. Make sure the box below the pages to print is showing "Address Book" and you will see the "Style" below it.

  • SQL*Plus Change to File While Being Run

    Anyone,
    Once you execute a file run in SQL*Plus does the entire file get cached by SQLPlus? (i.e. @C:\temp\myfile.sql)
    If I change the file C:\temp\myfile.sql while the session is running (long runing script) will it take effect or not?
    I was able to open the file make a change and save but not sure if SQLPlus will pick up my change when it gets to the point in the script where I made the change. Since it was already running.
    Thanks,
    Miller

    That is a very bad idea to begin with.
    If you made a change at the location that has not yet reached by the SQL*Plus script processing, you could see those changes (again depending upon where and how you do them).
    But in most circumstances, the results will be unpredictable (most likely with error messages) since you cannot control what part of the script the SQL*Plus application is currently executing at the moment you decide to make change to the script.
    For example, I started with this script:
    REM --- Script start ---
    prompt "Waiting ..."
    begin
      dbms_lock.sleep(20) ;
    end ;
    begin
      dbms_output.put_line('This is text') ;
    end ;
    prompt "Finished..."
    REM --- Script end ----And run this within SQL*Plus. While the PL/SQL block was waiting on the sleep call, I removed the first line of the script (the one that starts with the prompt statement) and saved it. Below is the output from this run:
    SQL> @test
    "Waiting ..."
    PL/SQL procedure successfully completed.
    SP2-0734: unknown command beginning "ut_line('T..." - rest of line ignored.
    SP2-0042: unknown command "end " - rest of line ignored.
    PL/SQL procedure successfully completed.
    "Finished..."
    SQL>I would not consider this as a successful completion of the script.
    At this point, you are probably playing with probability and taking chances.
    Message was edited by:
    Kamal Kishore

  • A question about the impact of SQL*PLUS SERVEROUTPUT option on v$sql

    Hello everybody,
    SQL> SELECT * FROM v$version;
    BANNER
    Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
    PL/SQL Release 11.2.0.1.0 - Production
    CORE    11.2.0.1.0  Production
    TNS for Linux: Version 11.2.0.1.0 - Production
    NLSRTL Version 11.2.0.1.0 - Production
    SQL>
    OS : Fedora Core 17 (X86_64) Kernel 3.6.6-1.fc17.x86_64I would like to ask a question about the SQL*Plus SET SERVEROUTPUT ON/OFF option and its impact on queries on views such as v$sql and v$session. Here is the problem
    Actually I define three variables in SQL*Plus in order to store sid, serial# and prev_sql_id columns from v$session in order to be able to use them later, several times in different other queries, while I'm still working in the current session.
    So, here is how I proceed
    SET SERVEROUTPUT ON;  -- I often activate this option as the first line of almost all of my SQL-PL/SQL script files
    SET SQLBLANKLINES ON;
    VARIABLE mysid NUMBER
    VARIABLE myserial# NUMBER;
    VARIABLE saved_sql_id VARCHAR2(13);
    -- So first I store sid and serial# for the current session
    BEGIN
        SELECT sid, serial# INTO :mysid, :myserial#
        FROM v$session
        WHERE audsid = SYS_CONTEXT('UserEnv', 'SessionId');
    END;
    PL/SQL procedure successfully completed.
    -- Just check to see the result
    SQL> SELECT :mysid, :myserial# FROM DUAL;
        :MYSID :MYSERIAL#
           129   1067
    SQL> Now, let's say that I want to run the following query as the last SQL statement run within my current session
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;According to Oracle® Database Reference 11g Release 2 (11.2) description for v$session
    http://docs.oracle.com/cd/E11882_01/server.112/e25513/dynviews_3016.htm#REFRN30223]
    the column prev_sql_id includes the sql_id of the last sql statement executed for the given sid and serial# which in the case of my example, it will be the above mentioned SELECT query on the employees table. As a result, right after the SELECT statement on the employees table I run the following
    BEGIN
        SELECT prev_sql_id INTO :saved_sql_id
        FROM v$session
        WHERE sid = :mysid AND serial# = :myserial#;
    END;
    PL/SQL procedure successfully completed.
    SQL> SELECT :saved_sql_id FROM DUAL;
    :SAVED_SQL_ID
    9babjv8yq8ru3
    SQL> Having the value of sql_id, I'm supposed to find all information about cursor(s) for my SELECT statement and also its sql_text value in v$sql. Yet here is what I get when I query v$sql upon the stored sql_id
    SELECT child_number, sql_id, sql_text
    FROM v$sql
    WHERE sql_id = :saved_sql_id;
    CHILD_NUMBER   SQL_ID          SQL_TEXT
    0              9babjv8yq8ru3    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES); END;Therefore instead of
    SELECT * FROM employees WHERE salary >= 2800 AND ROWNUM <= 10;for the value of sql_text I get the following value
    BEGIN DBMS_OUTPUT.GET_LINES(:LINES, :NUMLINES);Which is not of course what I was expecting to find in v$sql for the given sql_id.
    After a bit googling I found the following thread on the OTN forum where it had been suggested (well I think maybe not exactly for the same problem) to turn off SERVEROUTPUT.
    Problem with dbms_xplan.display_cursor
    This was precisely what I did
    SET SERVEROUTPUT OFFafter that I repeated the whole procedure and this time everything worked pretty well as expected. I checked SQL*Plus documentation for SERVEROUTPUT
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Could anyone kindly make some clarification?
    thanks in advance,
    Regards,
    Dariyoosh

    >
    and also v$session page, yet I didn't find anything indicating that SERVEROUTPUT should be switched off whenever views such as v$sql, v$session
    are queired. I don't really understand the link in terms of impact that one can have on the other or better to say rather, why there is an impact
    Hi Dariyoosh,
    SET SERVEROUTPUT ON has the effect of executing dbms_output.get_lines after each and every statement. Not only related to system view.
    Here below what Tom Kyte is explaining in this page:
    Now, sqlplus sees this functionality and says "hey, would not it be nice for me to dump this buffer to screen for the user?". So, they added the SQLPlus command "set serveroutput on" which does two things
    1) it tells SQLPLUS you would like it <b>to execute dbms_output.get_lines after each and every statement</b>. You would like it to do this network rounding after each call. You would like this extra overhead to take place (think of an install script with hundreds/thousands of statements to be executed -- perhaps, just perhaps you don't want this extra call after every call)
    2) SQLPLUS automatically calls the dbms_output API "enable" to turn on the buffering that happens in the package.Regards.
    Al

  • Can we generate the output of SQL Query in XML format ..

    Hi Team,
    Can we generate an XML doc for an SQL Query.
    I've seen in SQL Server 2000.It is generating the output of an SQL Query in xml format.
    select * from emp for xml auto
    The output looks like
    <emp EMPNO="7369" ENAME="SMITH" JOB="CLERK" MGR="7902" HIREDATE="1980-12-17T00:00:00" SAL="2800" DEPTNO="20"/><emp EMPNO="7370" ENAME="SMITH" JOB="CLERK" MGR="7902" HIREDATE="1980-12-17T00:00:00" SAL="2800" DEPTNO="10"/>

    Just a little bit of short hand.
    Get the XML out of your database, via HTTP
    Of course the easiest method is just to return an XMLType from a stored procedure and let the calling routine figure out what to do with it. Instead
    of that way though, I'll show you how to do it via HTTP. It's all completely built into 10g and is super easy to use.
    CREATE OR REPLACE VIEW emps_and_depts AS
    SELECT e.employee_id AS "EmployeeId",
    e.last_name AS "Name",
    e.job_id AS "Job",
    e.manager_id AS "Manager",
    e.hire_date AS "HireDate",
    e.salary AS "Salary",
    e.commission_pct AS "Commission",
    XMLFOREST (
    d.department_id AS "DeptNo",
    d.department_name AS "DeptName",
    d.location_id AS "Location"
    ) AS "Dept"
    FROM employees e, departments d
    WHERE e.department_id = d.department_id
    Some people hear web and immediately start salivating about security issues. Let me address that quickly. Just because you have the HTTP and/or
    FTP servers running in the database, that does not mean you have a security problem. For one, I would hope your databases are behind a firewall.
    Second, with the correct architecture (DMZ, app servers, etc) you can make this data available outside the firewall fairly transparently and third,
    just because it's on the web does not mean the data MUST be available on the internet. This is a good way to make your data available on your
    intranet. If you are worried about people INSIDE your firewall, that still doesn't preclude web based access. Follow Oracle security guidelines.
    Before I show you how to get to your data, let's talk about URLs and URIs. A URL is a Uniform Resource Locater and URI is a Uniform Resource
    Identifier. A URL is the way you would identify a document on the net, i.e. http://www.oracle.com is a URL. A URI is a more generic form of a URL.
    Oracle supports three types of URI: HTTPURIType - basically a URL (which would be like the URL above), XDURIType - a pointer to an XDB resource
    (usually an XML document but can be other objects), and DBURIType - a pointer to database objects.
    It's the DBURIType that we're going to concentrate on here. The DBURIType let's us reference database objects using a file/folder paradigm. The
    format for a DBURI is /oradb/<schema>/<table>. Oradb is shorthand for the database; it is not the database name or SID. My database is named XE
    but I still use oradb in the DBURI. For example, the view we created above is in my XE database, is owned by HR (at least in my case) and is called
    EMPS_AND_DEPTS. This can be referenced as /oradb/HR/EMPS_AND_DEPTS.
    If the view had many rows and you wanted only one of them, you can restrict it by including a predicate. The documentation for XDB has a great
    write up on Using DBURIs.In our case, we are going to write out the entire document. Now that you understand that the DBURI is a pointer to
    objects in our instance, we can use that to access the data as a URL.
    The format for the URL call is http://<machinename>:<port>/<DBURI>
    In my case, my XE database is running on a machine called mach1 and is listening on port 8080. So to see the view we created above, I open my
    browser and navigate to: http//mach1:8080/oradb/HR/EMPS_AND_DEPTS
    The created URL will be as http//mach1:8080/oradb/PUBLIC/EMPS_AND_DEPTS
    If your database is set up correctly and listening on port 8080 (the default), your browser should ask you to login. Login as the user who created the
    view (in my case HR). You should now get an XML document displayed in your browser.
    And that's it. It doesn't get much simpler than that. If you get rid of the descriptive text above, it basically comes down to:
    Create a table or view
    Open your web browser
    Enter a URL
    Enter a user ID and password
    View your XML
    If you notice, Oracle formatted the data as XML for us. Our view returns scalar columns and an XML fragment called Dept. Oracle formatted the
    return results into an XML format.
    And as a side note, if you look closely, you'll see that my URL has PUBLIC where I said to put HR. PUBLIC is a synonym for all objects that your
    logged in user can see. That way, if your user has been granted select access on many schemas, you can use PUBLIC and see any of them.

  • How to come out of the output in sql 11g

    In sql 11g release 2 i am not able to come out of the query window..if i use ctrl c it throws me out of the window..
    Some times i fire control c it does through me out of the ouptut screen to sqlplus prompt but sometimes it just throws me out of the sql window..
    What is the best way to cancel a sql command in oracle 11g release 2.
    in sql . In 10 g things were easier.. dont know what do we need to do in 11g release 2
    Edited by: zycoz100 on Jan 27, 2013 10:57 PM

    Use the "exit" or cntrl +c command to terminate your SQL*Plus session.
    Read the doc too
    Stopping a Command while it is Running
    http://docs.oracle.com/cd/B19306_01/server.102/b14357/ch4.htm#i1040012
    How to use Sql*plus
    http://docs.oracle.com/html/A88829_01/ch3.htm
    Edited by: Rahul India on Jan 28, 2013 12:35 PM

  • The output of sql loader displays '?' for the chinese character

    I'm run the sql loader to import the data. The following is the ctl script:
    LOAD DATA
    CHARACTERSET ZHS16CGB231280
    APPEND
    INTO TABLE xxabc_gti_feedback
    when (5:6) ='~~' and (8:9)='~~'
    FIELDS TERMINATED BY "~~"
    TRAILING NULLCOLS
    absoluted
    ,exist_lists
    ,invoice_type
    ,invoice_category_code
    ,invoice_number
    ,line_count
    ,invoice_date DATE "YYYYMMDD"
    ,invoice_month
    ,trx_number
    ,amount_without_tax
    ,tax_rate
    ,tax_amount
    ,gti_feedback_id "xxban_gti_feedback_s.nextval"
    ,creation_date sysdate
    ,last_update_date sysdate
    EBS version: R12(12.0.4)
    The characterset of database is UTF-8
    The file characterset is GB2312
    The following is the example of data file.
    SJJK0201~~已开发票传出
    39~~20110413~~20110413
    //发票1
    0~~0~~0~~325676740~~11085979~~3~~20110413~~04~~~~3336.71~~0.17~~567.24~~珠海XX机电设备有限公司~~440407897878~~珠海市香洲区XXX 0756-3666666~~建行前山支行777777~~XX电子(苏州)有限公司~~32170078678890~~苏州工业园区 6267565~~中国银行园区支行25456672~~1653\n31263\n67126~~XXX~~XXX~~XXX
    0~~aaa~~P83782~~个~~2~~6854.70~~0.17~~1165.30~~4010~~1~~1601
    1~~bbb~~~~~~~~-4065.00~~0.17~~-691.05~~~~1~~1601
    0~~ccc~~P80792~~个~~4~~547.01~~0.17~~92.99~~160~~1~~1601
    I create a sql*loader concurrent program to load the data. the data can be loaded into the table successfully(The chinese customer name is correct). Only for the aborted lines, it will be listed in the outtput of the concurrent request, but out of my expect, the chinese characters in the output are displayed as '?'.
    How to solve the issue? Thanks.
    Edited by: 852938 on 2011-4-17 下午10:41

    like the following:
    SJJK0201~~??????????
    39~~20110413~~20110413
    //???1
    0~~aaa~~P83782~~??~~2~~6854.70~~0.17~~1165.30~~4010~~1~~1601
    1~~bbb~~~~~~~~-4065.00~~0.17~~-691.05~~~~1~~1601
    0~~ccc~~P80792~~??~~4~~547.01~~0.17~~92.99~~160~~1~~1601
    You can find that any chinese characters are became '?'. The loaded line(Line 4th) is not listed in the output.
    Thanks for your quick answer! :)

  • How to send output from SQL script to the specified log file (not *.sql)

    ## 1 -I write sql command into sql file
    echo "SELECT * FROM DBA_USERS;">results.sql
    echo "quit;">>results.sql
    ##2- RUN sqlplus, run sql file and get output/results into jo.log file
    %ORACLE_HOME/bin/sqlplus / as sysdba<results.sql>>jo.log
    It doesn't work please advise

    $ echo "set pages 9999" >results.sql ### this is only to make the output more readable
    $ echo "SELECT * FROM DBA_USERS;" >>results.sql
    $ echo "quit" >>results.sql
    $ cat results.sql
    set pages 9999
    SELECT * FROM DBA_USERS;
    quit
    $ sqlplus -s "/ as sysdba" @results >jo.log
    $ cat jo.log
    USERNAME                          USER_ID PASSWORD
    ACCOUNT_STATUS                   LOCK_DATE  EXPIRY_DAT
    DEFAULT_TABLESPACE             TEMPORARY_TABLESPACE           CREATED
    PROFILE                        INITIAL_RSRC_CONSUMER_GROUP
    EXTERNAL_NAME
    SYS                                     0 D4C5016086B2DC6A
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        SYS_GROUP
    SYSTEM                                  5 D4DF7931AB130E37
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        SYS_GROUP
    DBSNMP                                 19 E066D214D5421CCC
    OPEN
    SYSTEM                         TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUP
    SCOTT                                  60 F894844C34402B67
    OPEN
    USERS                          TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUP
    HR                                     47 4C6D73C3E8B0F0DA
    OPEN
    EXAMPLE                        TEMP                           06/12/2003
    DEFAULT                        DEFAULT_CONSUMER_GROUPThat's only a part of the file, it's too long :-)

  • SQL Plus: retrieve the commands

    11g R2 (11.2.0.3) on Linux. At the SQL Plus prompt such as SQL>, I typed some commands, say, select from test;* Sometime I want to re-use the query, so I need to retype in select from test.* Is there a way to retrieve the earlier issued commands back?
    Also, I can not use the BACK arrow key. Suppose I want to insert or delete a character in the middle of the commandline, how can I move the cursor over the character?
    Thanks

    955300 wrote:
    11g R2 (11.2.0.3) on Linux. At the SQL Plus prompt such as SQL>, I typed some commands, say, select from test;* Sometime I want to re-use the query, so I need to retype in select from test.* Is there a way to retrieve the earlier issued commands back?Yes. The utility is called rlwrap. You use it to run sqlplus. I alias it. So in my +.bash_profile+, I will have the following line:
    alias sqlplus="rlwrap $ORACLE_HOME/sqlplus"It provides full command line recall (inside SQL*Plus) and command line editing.
    There is no rlwrap rpm available for installation AFAIK. I'm downloading the source code and doing a manual build and install for all the server installations I do (I do not use Oracle Linux or RHEL as a desktop o/s - think for my Ubuntu desktop it installed via an <i>apt-get</i>). For a manual source code build, you need to install a couple of development rpm's as I recall, such as the readline lib.

  • Accessing the recyclebin through sql plus

    Hi
    I have droped a table by mistake and want to see if it in the recyclebin
    I cab only use sql scratchpad at the minute on the oracle windows client
    when i try to select from the recyclebin it says table doesnt exist
    is it in a particular schema?
    Thanks in advance

    Double post.
    dropped a table by mistake
    Did you read the link I posted over there? It is all documented:
    "RECYCLEBIN is used to control whether the Flashback Drop capability is turned on or off. If the parameter is set to OFF, then dropped tables do not go into the recycle bin. If this parameter is set to ON, dropped tables go into the recycle bin and can be recovered."
    http://download.oracle.com/docs/cd/B19306_01/server.102/b14237/initparams175.htm#REFRN10264
    YOu, or your DBA will probably have to enable the recyclebin.
    What result do you get for:
    SQL> show parameter recyclebin
    NAME                                 TYPE        VALUE
    recyclebin                           string      on

  • How to Strip Extraneous Output from SQL*Plus Session

    We are running Oracle Database 11g on Solaris 10, and I am trying to use SQL*Plus to create a temporary .sql file that I can execute in a later step of a Korn shell script. Here is the code:
         $ORACLE_HOME/bin/sqlplus / as sysdba <<EOF
    --whenever oserror exit failure;
    --whenever sqlerror exit sql.sqlcode;
    set serveroutput on
    set termout off
    set trimspool on
    set verify off
    set heading off
    set feedback off
    set echo off
    spool /usr/oracle/temp/apply_site_security_for_oracle_database_11g.ksh.tmp
    declare
         Value_DSC varchar2(2000);
         CommandLine_DSC varchar2(4000);
    begin
         select v\$parameter.value into Value_DSC from v\$parameter where lower(name)='diagnostic_dest';
         CommandLine_DSC := 'host chmod 751 ' || Value_DSC;
         dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
         dbms_output.put_line(CommandLine_DSC);
         CommandLine_DSC := 'host ls -ld ' || Value_DSC;
         dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
         dbms_output.put_line(CommandLine_DSC);
    end;
    spool off;
    exit;
    EOF
    I've tried to turn off everything I don't need, but I am missing something. When I run the script, I get the following in the temporary file:
    SQL>
    SQL> declare
    2 Value_DSC varchar2(2000);
    3 CommandLine_DSC varchar2(4000);
    4
    5 begin
    6 select v$parameter.value into Value_DSC from v$parameter where lower(name)='diagnostic_dest';
    7
    8 CommandLine_DSC := 'host chmod 751 ' || Value_DSC;
    9 dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
    10 dbms_output.put_line(CommandLine_DSC);
    11
    12 CommandLine_DSC := 'host ls -ld ' || Value_DSC;
    13 dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
    14 dbms_output.put_line(CommandLine_DSC);
    15 end;
    16 /
    --Ready to execute: host chmod 751 /s01/app/oracle
    host chmod 751 /s01/app/oracle
    --Ready to execute: host ls -ld /s01/app/oracle
    host ls -ld /s01/app/oracle
    SQL>
    SQL> spool off;
    I am hoping to whittle this down to just the following lines so I can execute them as a script.
    --Ready to execute: host chmod 751 /s01/app/oracle
    host chmod 751 /s01/app/oracle
    --Ready to execute: host ls -ld /s01/app/oracle
    host ls -ld /s01/app/oracle
    Any ideas?
    Edited by: shew01 on Jan 19, 2010 10:51 AM

    I just found it. Just add "-S" to the sqlplus command. Argh... I hunted for that a while back. Why didn't I remember it??????????
    This works:
         $ORACLE_HOME/bin/sqlplus -S / as sysdba <<EOF
    whenever oserror exit failure;
    whenever sqlerror exit sql.sqlcode;
    set serveroutput on
    set linesize 2000
    set pagesize 0
    set termout off
    set trimspool on
    set feedback off
    spool /usr/oracle/temp/apply_site_security_for_oracle_database_11g.ksh.tmp
    declare
         Value_DSC varchar2(2000);
         CommandLine_DSC varchar2(4000);
    begin
         select v\$parameter.value into Value_DSC from v\$parameter where lower(name)='diagnostic_dest';
         CommandLine_DSC := 'host chmod 751 ' || Value_DSC;
         dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
         dbms_output.put_line(CommandLine_DSC);
         CommandLine_DSC := 'host ls -ld ' || Value_DSC;
         dbms_output.put_line('--Ready to execute: ' || CommandLine_DSC);
         dbms_output.put_line(CommandLine_DSC);
    end;
    spool off;
    exit;
    EOF
    Edited by: shew01 on Jan 19, 2010 11:02 AM

Maybe you are looking for