Executing sql scripts from command line

Hi!
We setted the environment and navigated to the directory where the scripts are, but the instance is idle.
[oracle@at1srv0080 preparation]$ export ORACLE_SID=OMDEMO01
[oracle@at1srv0080 preparation]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Feb 28 10:07:13 2012
Copyright (c) 1982, 2010, Oracle.  All Rights Reserved.
Connected to an idle instance.and a startup resulted in:
Error 6 initializing SQL*Plus
Message file sp1<lang>.msb not found
SP2-0750: You may need to set ORACLE_HOME to your Oracle software directoryWhat could the cause be?
Thanks!

It is a new and clean installation of a RAC database and we already created some tablespaces.
Here is the environment:
_=/bin/env
CVS_RSH=ssh
DISPLAY=localhost:10.0
G_BROKEN_FILENAMES=1
HISTSIZE=1000
HOME=/home/oracle
HOSTNAME=at1srv0080.xxx.net
INPUTRC=/etc/inputrc
LANG=en_US.UTF-8
LD_LIBRARY_PATH=oracle/app/oracle/product/10.2.0/db_1/lib
LESSOPEN=|/usr/bin/lesspipe.sh %s
LOGNAME=oracle
LS_COLORS=no=00:fi=00:di=00;34:ln=00;36:pi=40;33:so=00;35:bd=40;33;01:cd=40;33;01:or=01;05;37;41:mi=01;05;37;41:ex=00;32:*.cmd=00;32:*.exe=00;32:*.com=00;32:*.btm=00;32:*.bat=00;32:*.sh=00;32:*.csh=00;32:*.tar=00;31:*.tgz=00;31:*.arj=00;31:*.taz=00;31:*.lzh=00;31:*.zip=00;31:*.z=00;31:*.Z=00;31:*.gz=00;31:*.bz2=00;31:*.bz=00;31:*.tz=00;31:*.rpm=00;31:*.cpio=00;31:*.jpg=00;35:*.gif=00;35:*.bmp=00;35:*.xbm=00;35:*.xpm=00;35:*.png=00;35:*.tif=00;35:
MAIL=/var/spool/mail/oracle
OLDPWD=/tmp/OMCore
ORACLE_BASE=/oracle/app/oracle
ORACLE_HOME=oracle/app/oracle/product/10.2.0/db_1
ORACLE_SID=OMDEMO01
PATH=/oracle/app/oracle/product/10.2.0/db_1/bin:/usr/kerberos/bin:/usr/local/bin:/bin:/usr/bin:/home/oracle/bin
PWD=/tmp/OMCore/preparation
SHELL=/bin/bash
SHLVL=1
SSH_ASKPASS=/usr/libexec/openssh/gnome-ssh-askpass
TERM=xterm
USER=oracle

Similar Messages

  • Executing sql scripts with command line Sql plus

    Hello
    Well I will be gradefull if I have an answer to the follow questions
    a) How can I connect to a remote XE using sqlplus (command line)?
    for example I'm trying to connect like this : sqlplus sys/syspassw@//remoteserver:1521/xe
    and I get responce from server that I have to connect as SYSDBA or SYSOPER, so what is the proper syntax in this case?
    b) I want to execute a script file with DDL commands from Windows conscole using sqlplus. Inside this script I have the connect command and others. Is there a way to pass the name of script file as parameter to the sqlplus and execute it ? If yes what is the proper syntac from command line of Windows?
    Thank you

    There are two ways to do that...
    Either use the spool command in sqlplus, or on your command line calling sqlplus use a >> to direct the output to a file. Usually the spool is cleaner.
    It goes like this:
    spool C:\logfile.txt
    {sql commands here}
    spool off
    or
    sqlplus /nolog @sqlfile.sql >> C:\logfile.txt
    The output will be formatted slightly differently, and if you use the DOS method you won't be able to see the output as it's running.
    ~Jer

  • How to execute sql scripts from Powershell across multiple databases

    Re: How to execute sql scripts from Powershell across multiple databases
    I have an tsql script that I want to run across a list of databases. How is the best way to do this in Powershell? Thanks.

    My example below, using just the SMO and not breaking up the batches, the ExecuteWithResults give the following error when the .sql file contains a GO. My script files are as simple as a DECLARE and then a GO.
    WARNING: SQL Script Failed
    The object of type "Microsoft.PowerShell.Commands.Internal.Format.FormatStartData" is not valid or not in the correct sequence. This is likely caused by a user-specified "format-list" comm
    and which is conflicting with the default formatting.
        + CategoryInfo          : InvalidData: (:) [out-lineoutput], InvalidOperationException
        + FullyQualifiedErrorId : ConsoleLineOutputOutOfSequencePacket,Microsoft.PowerShell.Commands.OutLineOutputCommand
    Also, when executing from the ISE, is there a way to force the ISE to release the files. I am having to close the ISE and reopen my script every time I want to make a testing change to the .sql file.
    [reflection.assembly]::LoadWithPartialName("Microsoft.SqlServer.Smo")
    $scriptspath = "C:\temp\psExecuteSQLScripts\scripts"
    $SQLServer = "fidevc10"
    $SQLDB = "Bank03"
    # Create SMO Server Object
    $Server = New-Object ('Microsoft.SQLServer.Management.Smo.Server') $SQLServer
    # Get SMO DB Object
    $db = $Server.Databases[$SQLDB]
    # Load All SQL Scripts in Directory
    $scripts = Get-ChildItem -Path (Join-Path $scriptspath "*") -Include "*.sql" -Recurse
    # Loop through each script and execute
    foreach ($SQLScript in $scripts)
    $fullpath = $SQLScript.FullName
    # Read the Script File into Powershell Memory
    $reader = New-Object System.IO.StreamReader($fullpath)
    $script = $reader.ReadToEnd()
    # Execute SQL
    Write-Host "Executing $SQLScript on $SQLDB...."
    try
    $ds = $db.ExecuteWithResults($script)
    Foreach ($t in $ds.Tables)
    Foreach ($r in $t.Rows)
    Foreach ($c in $t.Columns)
    Write-Host $c.ColumnName "=" $r.Item($c)
    Write-Host "Complete"
    catch [Exception]
    Write-Warning "SQL Script Failed"
    echo $_.Exception|format-list -force
    Write-Host " " -BackgroundColor DarkCyan

  • Running Oracle Scripts from Command Line

    Hi,
    How can i run Oracle scripts from command line.
    Actually i need to run these scripts from MSBuild before running Unit test projects

    C:\>sqlplus @myscript
    That would be the easiest variation
    C:\>sqlplus user/passwd@tns_alias @myscript
    would be an often used variation
    And then there is of course the version with parameter passing:
    C:\>sqlplus user/passwd@tns_alias @myscript param1 ... paramx
    Dunno about MSBuild

  • Execute .sql scripts from a remote login

    Hello,
    1) How do I execute a remote sql script from sqlplus?
    SQL>@remote_server:$HOME/test_sql.sql ...this did not work, which would work?
    2) Another question, in sqlplus I can do...! echo testing123>$HOME/test123.txt.
    How do I do this within a store procedure?
    This does not work, which would work?
    declare
    v_test varchar2(300) := '! echo testing123>$HOME/test123.txt';
    begin
    execute immediate v_test;
    end;
    /

    Re Q2.
    I take it that's an sqlplus feature on unix as it doesn't work on windows:
    SQL> ! echo testing123>$HOME/test123.txt
    SP2-0734: unknown command beginning "! echo tes..." - rest of line ignored.
    SQL>Also the reason this isn't working from within PL/SQL is that the execute immediate statement is used to send SQL statements to the SQL engine. What you are attempting to do is to send sqlplus commands to the SQL engine which obviously knows nothing about sqlplus commands. Those commands are very specific to the sqlplus executable and will only work in that environment.
    ;)

  • Executing sql scripts from url

    A nice feature of isqlplus was that we could execute a sql script stored on a
    server from a browser on a client, using dynamic. Is ther any comparable
    facility in APEX for executing a sql script from a browser?

    Hi!
    Here are some other threads to look at. Make sure to also look at the blog at the bottom of the 2nd thread. In the forum search set the date range to "all" and search on "run_cmd". You might have to look thru a few pages but there are several threads.
    How to execute sqlplus command in html_db
    Re: Returning dbms_output.putline type output to apex page
    Re: RUN A DOS BATCH FILE FROM PLSQL...
    Also go to ASKTOM (Tom Kyte) and search on "run_cmd":
    http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:3361193268672
    This will give you several ideas!
    Let us know if you can't get it working.
    Dave Venus

  • How to execute IDC services from command line

    Hey Guys,
    is there some way we can execute IDC Services from command prompt.
    your any pointers will be highly appriciated.
    regards,
    sapan
    Edited by: sapan on Mar 9, 2009 7:26 AM

    Hey sapan,
    You can use IdcCommand to execute services from the command line. The process is as follows:
    1. Create a text file with the services calls you want to make, the definitions are in hda format:
    @Properties LocalData
    IdcService=UPDATE_DOCINFO
    dID=1
    dDocName=000001
    dDocType=MyType
    dSecurityGroup=Public
    dRevLabel=1
    dDocAuthor=sysadmin
    dDocTitle=My Title
    @end
    <<EOD>>
    (Note: for multiple entries in the file <<EOD>> is very important)
    2. Execute IdcCommand from the <content server install>/bin directory:
    IdcCommand -f image_update.hda -u sysadmin -l c:\idccommand.log
    Options:
    -f = file with service definitions
    -u = user to run as
    -l (lowercase L) = location for log of execution
    More detailed documentation can be found in the Idc Command Reference (idc_command_reference_10en.pdf).
    Hope that helps,
    Andy Weaver - Software Consultant
    Fishbowl Solutions < http://www.fishbowlsolutions.com?WT.mc_id=L_Oracle_Consulting_amw >

  • Executing sql script from file, with multiple queries

    Hello,
    I am trying to load an SQL script from a file, parse the script into separate SQL statements, and execute each of them. The final statement will always be a query, and thus will return a result.
    Three problems arise:
    1. I don't know what TYPE of statement each one is (i.e. whether it is an UPDATE or a QUERY), which seems to be required in order to execute it in java (via executeQuery and executeUpdate).
    2. I am not sure of the best way to execute a series of statements (the Statement object has some "batch" functionality, but I'm not sure if there is a better way, or even of the proper way to use this).
    3. I need to be able to make sure the final statement is a QUERY, and thus will return a ResultSet. Otherwise I need to be able to throw an exception.
    This has been causing me a lot of trouble. Any help would be much appreciated.
    Thanks,
    Kevin

    Hi Kevin,
    Have you got any solution for your mentioned problem????
    I am facing almost the same kind of problem like I have some sql files containg simple sql statements as well as code for writting Procs , triggeres, index...functions..and so on. I need to execute this XYZ.sql file from Java side.
    Can you guide me about my problem?????
    Thanks in advance.............
    Mak

  • Batch/script from command line and crontab

    Is possible to create a batch from adobe photoshop 5.5 and use a command line to execute? I need easy batch like "open and save in another kind of extension" but can't find the solution to automate the process from command line.
    Any1 can help me?
    Thank u all

    It sounds like droplets are exactly what you need.  Droplets turn any action into an executable that can be run from the command line passing files to process as arguments.  Just make the action you described, and go to go to file > automate > create droplet in photoshop to make the droplet.
    P.S. this has nothing to do with bridge

  • How to execute sql script from linux command line

    Hello everyone !
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?
    sqlplus user/pass ... and then what ?
    thanks
    dlugasx

    user10064952 wrote:
    Just short question. On my server I must install script in crontab which will eexecute some sql statements.
    How can I write command which will execute script from file without asking about password ?Crontab does not run your local shell profile - which means no valid Oracle environment for SQL*Plus to execute in.
    On newer cron versions, you can add an environment to the crontab file itself that needs to be set before executing the scheduled command.
    Whatever method - make sure you have ORACLE_HOME set, that the path includes ORACLE_HOME/bin, that ORACLE_SID is set (if not using a TNS alias) and so on.
    But I agree with Sybrand... crontab is not the best place for running SQL or PL/SQL code. That should reside in the database as named code (e.g. stored procs) and be executed via DBMS_JOB or DBMS_SCHEDULE.
    Less moving parts that way. No external dependancies. And will work on any Oracle server, irrespective of the o/s used and whether or not the relevant o/s user has batch/cron/etc privs to do the deed.

  • Execute sql script from apex

    hi all
    i have dir /usr/tmp which there i have script in sql that creats a report
    in the command line i'm running the script like this :
    sqlplus user/passwd@db @name_of_script
    my goal is to run this script thru the apex
    i tried to create some process
    before header like this
    :p116 := sqlplus user/passwd@db @/usr/tmp/name_of_script ;
    doesn't work!!
    i even try to put this action in table but then i don't know how to run this ?
    can it executed in apex ? if yes then how ?
    thanks a lot

    I checked the link and it did not work, so I am reposting my original reply below.
    had a requirement to run a Fortran program against some data that woudl be extracted from the database after the user set up their filtering criteria and made some additional input. SInce the program was to complex to conver to PL/SQL, we decided to try and invoke it from Apex. This is how I did it.
    1. I followed the steps in Tim Archer's excellent article "Oracle External Procedure to Run Host Commands" (http://www.timarcher.com/?q=node/9). If the link does nto work, google the article's title.
    Using this steps I created a function which accepts any OS command, including calling my own shell scripts, and runs them. I called my PL/SQL function "shell" instead of "USF_RUN_HOST_CMD " as Tim did in his example (step 9).
    2. In Apex,
    a. I created a button to run my shell command. (I named it P2_RUN_SHELL)
    b. I created a PL/SQL process whose source looks as follows:
    shell('/home/ackness/scripts/cr_xcf_file.sh > /tmp/cr_scfp_file.log');
    and which was conditioned on the the button P2_RUN_SHELL.
    It works like a charm.
    Note: since you can run your own scripts using this method, you can encapsulate a series of commands in a UNIX shell script and invoke that script from Apex. This allows you to be able to test or run you commands from the command line as well as Apex and makes it easier to develop/debug/enhance the scripts in the future.
    Ackness

  • File Ownership while executing sql script from stored procedure

    We have a test_command.sql script which is spooling the result into a file. From database we have one Store Procedure(run_sql) which is
    calling and executing the .sql script.
    When we are calling the sql script directly from the database, i e SQL > @/dccops/test_command.sql it is creating the
    file under the Ownership of OS user which is connected to the system.
    The problem we are facing is when we are executing the stored procedure i e exec run_sql(), the file is creating under
    Oracle User.
    Could u please suggest me a solution inorder to create the output file under the user who is logged to the OS.

    First of all, your usage of IM speak is NOT appreciated. Please do not address anyone as if they were a 12-year old.
    'Our Applcation is in C. So we have to call the procedure to run the sql script.'
    This is just utter nonsense!
    Oracle has Pro*C which allows Embedded SQL in C. There is also OCI (Oracle Call Interface) to call Oracle directly in C, and there is OCCI, to do the same in C++.
    Apart from that, Oracle has Ole DB for Windows platforms, to allow for a .NET compatible interface to Oracle.
    There is NO NEED AT ALL to call PL/SQL to run a SQL script.
    Sybrand Bakker
    Senior Oracle DBA

  • How to run executable Java app from command line: No Main( ) method

    This is the opposite question from what most users ask. I have the Java source code and a running Java executable version of the program in a windows environment. I don't want to run it in the normal way by double-clicking on it or using the executable. I need to be able to run the same application from the command line. If I can do this, I can then compile and run the code on my Mac, too, which is what I am ultimately trying to accomplish.
    Normally, this would be easy. I would look for a Main method, normally public static void main (String[] args ) or some variation. I cannot find a main() anything, anywhere when searching the files. There must be some windows executable that links to the Java classes. It's very clever, no doubt, but that's not helping me.
    I am trying to run what I can determine as the Main class, with a standard command line call, but that is not working either.
    It is a Java graphics program, so mostly Swing container stuff.
    I am not finding a manifest.txt file, telling me where a main method is, nor anything about the Main Class. There is no readme file for the program.
    Any insight that would point me in the right direction? What should I be looking for?
    Thanks in advance, Bloozman

    It's possible there's a clever Windows executable that runs the class. But if it's a plain old Java class then there's a good chance there's a constructor. Look for that; it's possible you may be able to start by writing another Java class that creates an instance of your mystery class.
    When you have that done, try running it. It's possible that just creating an instance might be sufficient to run it. Swing programs are sometimes written like that. If not, then start looking for methods with names like "run" or "go" or "start" that your little controller program can call.

  • Executing Tcl Script from Command Prompt

    Hello All
    Can someone please show me how to execute a tcl script from the command prompt on a cisco router?
    Cheers
    Carlton

    Hi,
    Assume that you have tcl script to ping 3 ip address as below.
    foreach address {
    1.1.1.1
    2.2.2.2
    3.3.3.3
    } {ping $address}
    Use "tclsh" command and copy the script. That should do the job. Please find below example.
    R1#tclsh
    R1(tcl)#foreach address {
    +>(tcl)#1.1.1.1
    +>(tcl)#2.2.2.2
    +>(tcl)#3.3.3.3
    +>(tcl)#} {ping $address}
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/2/4 ms
    Type escape sequence to abort.
    Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
    Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/1 ms
    R1(tcl)#
    Hope this helps.
    Regards
    Najaf
    Please rate when applicable or helpful !!!

  • How to execute ODI scenarios from command line in Unix

    Hi Friends,
    I am using ODI 11g.
    I want to execute ODI senarios using the command line argument in Unix.
    Please let me know how to proceed with this.
    Thanks,
    Lony

    Hi,
    unser the /your_ODI_HOME/agent/bin folder.
    Excute this
    sh startscen.sh REFRESH_ID 001 GLOBAL 5 -NAME=agent_ODI
    REFRESH_ID=Your Scenario name
    001:Version
    GLOBAL:Context name
    5=Log Level
    agent_ODI=Your agent name
    Regards

Maybe you are looking for