Run SQL from UNIX

How could I run sqlplus from an Unix machine?

If want to Install
1. Need to Install Oracle Client
2. Use SQL *PLUS
or
If dont want to install
1. Use iSQLPLUS

Similar Messages

  • How to run import from Unix Oracle 8.0.5 database with Windows Oracle client?

    How to run import from Unix Oracle 8.0.5 database via network with Windows Oracle client? Is it possible? When I try to do it Oracle client just hangs... If not which ones are compatible Aix or Solaris to Unix or it must be a Unix client to connect to Unix Oracle database. Thank's for any help.

    Hi,
    In our project we are using this type. Since in this project server in UNIX(DEC) and client is running on windows. We have created a listener which always listen requests from client and doing the according to the request.
    Step1. create a request table, where u are inserting ur request.
    step2. create PRO*C proram, which is listening request on the table. If there is any request, call the imp (executable). This is happening on server side.
    Benifit. U can make a request from cleint and ftp the file client sit.
    Are u interested in more details and code, pls send a mail to me
    ---- Boby Jose Thekkanath
    [email protected]
    Dharma Computers(p) Ltd. Bangalore.
    null

  • Run PL/SQL from Unix

    Can anybody tell me how to run PL/SQL Procedure from unix prompt.

    You can start a sqlplus script from unix prompt, e.g.
    sqlplus <youruser>/<yourpassword>@<yourdb> @yourscript.sqlEdited by: hm on 01.01.2011 02:33

  • Scripting pl/sql from unix

    I am wondering if there is a way to do this with certain restrictions. If not, I can do it another way.
    1. I have a list of values in a unix .txt file of the form
    VALUEA
    VALUEB
    VALUEC
    I know how to read a list in unix using a loop.
    2. I want to call a pl/sql anonymous block that I have in a .sql file 1 time for every value in this script and pass the value.
    I do know how to read a value and then pass it to a pl/sql parameter and then call the pl/sql parameter.
    What I don't know how to do is
    Do this with only logging into sqlplus one time. I dont want to do the following
    unix runs in a loop
    reads 1 record from file
    logs into sqlplus
    runs the procedure and passes the value
    log out of sqlplus
    end loop
    I want to
    1. read all the values from the file
    2. store it somehow in memory (variable of some sort)
    3. pass this value to the pl/sql procedure
    I do not want to make any objects in the database such as a global temporary table.
    Yes I can actually do this, but wondering if it is possible to avoid. Makes it easier to deploy to alot of different databases. If I have to make a database object, then i have to make an object in alot of databases. If I can run it all from unix, all I have to do is change the target and the password. So it is easier to deploy.

    I don't need to put this in an Oracle Directory. I am not calling anything from pl/sql stored in the database. It is going to all be done with unix scripts and anonymous block sql in .sql statements in the OS. This allows me to take advantage of clustered storage (I can have alot of databases servers mounted on 1 directory). So the unix script will log into oracle and call the .sql script.
    I can build the pl/sql dynamically. I'd rather not do that. The thing is I have alot of databases I want to deploy code to. So I am trying to come up with a pattern I can follow. So if I add a new database or what to deploy somewhere else, I can just use add a line to a file.
    Adding database objects every time I need to deploy to a new database is a pain. It is far more scaleable to handle all of this in unix.
    Edited by: Guess2 on Jan 12, 2010 7:43 AM

  • Remotely running SQL from PowerShell

    Hi
    I work for a Software House where checking files versions, running SQL to check tables is becoming run-of-the mill :)
    I'm very new to PowerShell so far and have just been playing about to find that I can remotely check file-versions ok. Now onto the other side of the coin....running SQL to check tables is the next thing I need to learn.
    Just for a heads-up. Most of the servers I connect to are running MS SQL Server 2003 (unfortanately) which is why I want to remotely check the servers without connecting in via Remote Desktop Session. With MS Server 2003, if I use a Remote Desktop
    Session, I've found that I would have to download PowerShell (v1) and then have to configure it to allow it to run my .ps1 scripts which would also become cumbersome.
    Can anyone give me a start and say how to remotely connect to and SQL database and then run a simple SELECT statement from PowerShell please. I can then build my powershell scripts up from there.
    Kind Regards
    Matt

    Hi
    I've tried this script but get the error below if anyone can help.
    # Get SQL rows if they exist
    $SqlConnection = New-Object System.Data.SqlClient.SqlConnection
    $SqlConnection.ConnectionString = "Server=\\10.1.2.3;Database=THEHOUSE;Integrated Security=True;User Id=Joe123;Password=password123"
    $SqlConnection.Open()
    $SqlCmd = New-Object System.Data.SqlClient.SqlCommand
    $SqlCmd.CommandText = "SELECT * FROM TABLEX WHERE TRANS_TYPE='ACG'"
    $SqlCmd.Connection = $SqlConnection
    $dbname = $SqlCmd.ExecuteScalar()
    $SqlConnection.Close()
    Write-output "Database is " $dbname
    The error I get is:
    Exception calling "Open" with "0" argument(s): "A network-related or instance-specific error occurred while
    establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the
    instance name is correct and that SQL Server is configured to allow remote connections. (provider: SQL
    Network Interfaces, error: 25 - Connection string is not valid)"
    At C:\PS1scripts\Get SQL table data.ps1:5 char:1
    + $SqlConnection.Open()
    + ~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : SqlException
    Exception calling "ExecuteScalar" with "0" argument(s): "ExecuteScalar requires an open and available
    Connection. The connection's current state is closed."
    At C:\PS1scripts\Get SQL table data.ps1:9 char:1
    + $dbname = $SqlCmd.ExecuteScalar()
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
        + FullyQualifiedErrorId : InvalidOperationException

  • How to run SQL from PL/SQL?

    hi,
    i want to run sql script from PL/SQL,
    in my PL/SQL,i have given the path within the double quotes,
    @"/usr/local/pbiace/current/bin/handle.sql" but while running the script im getting some exception.
    pls guide me.....

    What is your OS.
    First example, divide three part scritps and then
    cat beforepart.sql account.sql afterpart.sql | sqlplus user/password@connectstring
    type beforepart.sql+account.sql+afterpart.sql | sqlplus user/password@connectstring
    Second example, divide two part scripts.
    acc2.sql
    declare HandleN varchar(20);
    begin
    select pbhandlenamelower INTO HandleN from pb_handle where pbhandleid in(select max(pbhandleid)
    from pb_handle where ha_customerentityid in (select acct_customerentityid from account
    where acct_accountid = &1 )) AND pbmainhandleflag=1 ;
    do.pl('==============================') ;
    do.pl('Handle Name: ' || HandleN ) ;
    do.pl('==============================') ;
    EXCEPTION
    WHEN OTHERS THEN
    do.pl('No rows selected');
    END;
    exit
    main.sql
    set serveroutput on
    varaiable variable1 NUMBER
    DECLARE
    data varchar2(20);
    BEGIN
    data:='&1';
    select BI_ACCOUNTID into :variable1 from pb_bill_info where PBBTN=data;
    do.pl('BI_ACCOUNTID');
    do.pl('------------');
    do.pl(:variable1);
    end;
    @acc2 :variabl1
    Third Example
    create or replace directory SCRIPTS_DIR as 'path name'
    acc3.sql (Only 1 statement, don't include into-clause and ';')
    select pbhandlenamelower from pb_handle where pbhandleid in(select max(pbhandleid)
    from pb_handle where ha_customerentityid in (select acct_customerentityid from account
    where acct_accountid = :variable1 )) AND pbmainhandleflag=1
    main.sql
    set serveroutput on
    DECLARE
    data varchar2(20);
    variable1 NUMBER;
    HandleN varchar(20);
    p_sql varchar2(32000) := '';
    File_Handle UTL_FILE.FILE_TYPE;
    Read_line varchar2(4000);
    BEGIN
    data:='&1';
    select BI_ACCOUNTID into variable1 from pb_bill_info where PBBTN=data;
    do.pl('BI_ACCOUNTID');
    do.pl('------------');
    do.pl(variable1);
    File_Handle := UTL_FILE.FOPEN('SCRIPTS_DIR','acc3.sql','r');
    loop
    UTL_FILE.GET_LINE(File_Handle, Read_line);
    exit when no_data_found;
    p_sql := p_sql || Read_line || chr(32) ;
    end loop;
    UTL_FILE.FCLOSE(File_Handle);
    execute imediate p_sql into HandleN using varaiable1;
    do.pl('==============================') ;
    do.pl('Handle Name: ' || HandleN ) ;
    do.pl('==============================') ;
    EXCEPTION
    WHEN OTHERS THEN
    do.pl('No rows selected');
    END;
    Or Some many other Examples and those are maybe more simple, only if you would analyze your business requirements.

  • Getting Error when running sql from concurrent program in R12

    Hi All,
    I created concurrent program and attached EXECUTABLE which executable method as SQL plus .
    Using this program I am running one SQL file in R12 when I am running I am getting below error .
    Same king of program I have define in 11i and running it is running can anyone please help me if I need to do any set ups or security thing to resave this problem.
    ERROR:
    ORA-01017: invalid username/password; logon denied
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_identifier>] | /
    SP2-0306: Invalid option.
    Usage: CONN[ECT] [logon] [AS {SYSDBA|SYSOPER}]
    where <logon> ::= <username>[<password>][@<connect_identifier>] | /
    SP2-0157: unable to CONNECT to ORACLE after 3 attempts, exiting SQL*Plus
    Concurrent Manager encountered an error while running SQL*Plus for your concurrent request 3162719.
    Review your concurrent request log and/or report output file for more detailed information.
    Executing request completion options...
    Finished executing request completion options.
    Regrds,
    Sridhar.

    user12000862 wrote:
    Hi all,
    Thanks a lot giving replay below simple code I have put in my SQL file for testing Eventhough it is giving error .
    Table which i am using in Apps schema only.
    declare
    BEGIN
    insert into BRCD_HZ_DNB_XTBL_TEST values (666,'Y','547','Y','12254','TESTING','N','Y');
    commit;
    END;
    /Try this instead
    WHENEVER SQLERROR EXIT FAILURE ROLLBACK;
    WHENEVER OSERROR EXIT FAILURE ROLLBACK;
    insert into BRCD_HZ_DNB_XTBL_TEST values (666,'Y','547','Y','12254','TESTING','N','Y');
    commit;
    exit;HTH
    Srini

  • Run report from Unix prompt

    Hi,
    for audit reasons we need to run a report again. Therefore a changed the where-clause of the report. Since the report needs to run on our production system and the prodcution-version of the report can not be changed, I need to run the report from the unix prompt. Can anyone tell me how to run an Oracle reports 2.5 from the uni prompt. We are using Oracle Applications and therefor still on reports 2.5....
    I tried to run the report from the client, but since the report fetches alot of data, my harddrive with 1.7GB of free space ran out of resources. Therefore I can only run the report on the production system (a little bit more resources...).
    Thanks in advance, Roel.

    Hi Roel,
    Go to $ORACLE_HOME/bin directory. You can see the reports executables r25runm - Runtime, r25clim - Client.
    You can run your report like this:
    r25runm report=myreport.rdf userid=scott/tiger@mydb destype=file desformat=pdf desname=myreport.pdf
    (or)
    r25clim report=myreport.rdf userid=scott/tiger@mydb destype=file desformat=pdf desname=myreport.pdf server=myserver
    Please, Change the desformat and destype as per your requirement.
    -Siva B

  • How to run SQL from OMB+

    For any of you who wanted to be able to query the database from OMB+ in order to gather object metadata or whatever as part of your deployment scripts, you have no doubt noticed (to your frustration) that this functionality is not provided.
    Sure, you can trigger execution of a sql/plus script as an external process, but that's hardly interactive now is it?
    the good news is that OMB+ DOES provide access to the standard java package, which of course means that you can utilize the standard java.sql classes, which means - JDBC.
    Here is a very simple starting point for you that provides simple connect, disconnect, and run query abilities. There is no exception handling and you'd need to add other functionality to execute prepared statements like procedure calls, or do DML like insert/update statement.
    Still, I hope that you find it of use as a starting point - if you need it. For documentation on the java.sql interfaces, go to the Sun Java Docs page at: http://java.sun.com/j2se/1.3/docs/api/ and scroll down to the java.sql package in the top left pane.
    Cheers,
    Mike
    package require java
    proc oracleConnect { serverName databaseName portNumber username password } {
       # import required classes
       java::import java.sql.Connection
       java::import java.sql.DriverManager
       java::import java.sql.ResultSet
       java::import java.sql.SQLWarning
       java::import java.sql.Statement
       java::import java.sql.ResultSetMetaData
       java::import java.sql.DatabaseMetaData
       java::import oracle.jdbc.OracleDatabaseMetaData
       # load database driver .
       java::call Class forName oracle.jdbc.OracleDriver
       # set the connection url.
       append url jdbc:oracle:thin
       append url :
       append url $username
       append url /
       append url $password
       append url "@"
       append url $serverName
       append url :
       append url $portNumber
       append url :
       append url $databaseName
       set oraConnection [ java::call DriverManager getConnection $url ]
       set oraDatabaseMetaData [ $oraConnection getMetaData ]
       set oraDatabaseVersion [ $oraDatabaseMetaData getDatabaseProductVersion ]
       puts "Connected to: $url"
       puts "$oraDatabaseVersion"
       return $oraConnection
    proc oracleDisconnect { oraConnect } {
      $oraConnect close
    proc oraJDBCType { oraType } {
      #translation of JDBC types as defined in XOPEN interface
      set rv "NUMBER"
      switch $oraType {
         "0" {set rv "NULL"}
         "1" {set rv "CHAR"}
         "2" {set rv "NUMBER"}
         "3" {set rv "DECIMAL"}
         "4" {set rv "INTEGER"}
         "5" {set rv "SMALLINT"}
         "6" {set rv "FLOAT"}
         "7" {set rv "REAL"}
         "8" {set rv "DOUBLE"}
         "12" {set rv "VARCHAR"}
         "16" {set rv "BOOLEAN"}
         "91" {set rv "DATE"}
         "92" {set rv "TIME"}
         "93" {set rv "TIMESTAMP"}
         default {set rv "OBJECT"}
      return $rv
    proc oracleQuery { oraConnect oraQuery } {
       set oraStatement [ $oraConnect createStatement ]
       set oraResults [ $oraStatement executeQuery $oraQuery ]
       # The following metadata dump is not required, but will be a helpfull sort of thing
       # if ever want to really build an abstraction layer
       set oraResultsMetaData [ $oraResults getMetaData ]
       set columnCount        [ $oraResultsMetaData getColumnCount ]
       set i 1
       puts "ResultSet Metadata:"
       while { $i <= $columnCount} {
          set fname [ $oraResultsMetaData getColumnName $i]
          set ftype [oraJDBCType [ $oraResultsMetaData getColumnType $i]]
          puts "Output Field $i Name: $fname Type: $ftype"
          incr i
       # end of metadata dump
       return $oraResults
    #now to run a quick query and dump the results.
    set oraConn [oracleConnect myserver orcl 1555 scott tiger ]
    set oraRs [oracleQuery $oraConn "select name, count(*) numlines from user_source group by name" ]
    #for each row in the result set
    while {[$oraRs next]} {
      #grab the field values
      set procName [$oraRs getString name]
      set procCount [$oraRs getInt numlines]
      puts "Program unit $procName comprises $procCount lines"
    $oraRs close
    $oraConn close

    Oracle may indeed have used OraTCL as the starting point for OMB+, but if so then they have clearly wrapped their own interface around it and hidden the original commands. Now, I suppose that it should be possible to add OraTcl as an external library, however the Oratcl distribution makes use of the TCL "load" command to load their binaries.
    You will quickly find that Oracle has also disabled the standard TCL "load" command in OMB+, thus making very difficult to add third-party plug-in packages.
    If you can find a pure-TCL script db interface similar to OraTcl to manage SQL*Plus connections that doesn't use any of the TCL commands that ORacle has disabled - well then you could probably get those to load as packages.
    Or, like me, you could just use the supplied java interface and code your own as needed.
    Cheers,
    Mike

  • Running SQLPLUS from UNIX shell script

    I'm not sure if this is the right forum, but...
    How can I execute a sql file from inside the UNIX shell script, logging on to Oracle w/o supplying a UID/pwd? Normally, we log into UNIX using our own logon, then sudo as another user to login to Oracle. Now, I'm trying to create a UNIX shell script, where I'm already sudo'd as the UserID that logs into Oracle. I've tried the following, but can't get it to work. I'm a UNIX scripting noob. Any ideas?
    example:
    #! /usr/bin/ksh
    sqlplus / \@test.sql << EOF
    exit;
    EOF

    I'm a UNIX scripting noob.In which case I feel obligated to point you at William Robertson's excellent article Database Shellscripts Considered Harmful. Save yourself a world of pain.
    Cheers, APC

  • Run finder from UNIX?

    I was wondering if there is anyway that if I were to boot into unix I could then open the finder? I dont know too much about unix but is this possible? thank you

    hi sorry i didnt see the unix forum, ill post there next time.
    but what i am trying to do is my friends brother said his computer would only start up into unix asking for a name and password and then he didnt how to get it to boot into the finder. i can get around in unix but when it comes to the advanced things im totally useless. i was wondering if there is anyway to open the finder GUI from the unix CLI environment. thanks, hope that makes sense

  • Running sql from a text item

    Hi.
    I build record groups that display information for the user. These record groups are built on custom SQL that the user can add themselves. As this is open to errors I want to add a "Check Syntax" button.
    All it needs to do is run the query that the user types in and ensure it runs successfully and the required columns are in place. The entire SQL statement is held within a text item.
    If it errors i want to notify the user of the error that sql would produce,
    Any ideas on the best way to acheive this?
    Thanks

    i think with Dynamic SQL u can do this
    Set the query of Text item in a string and execute it using Dynamic query
    Execute immediate syntax
    Any error comes in Dynamic query return it to user
    Baig,
    http://baigsorcl.blogspot.com

  • Run SQL Loader script from Unix env

    Hi,
    We are using HP-UNIX server. The control file of SQL Loader is placed in oracle home\bin folder in the unix server. I created Executable for this SQL Loader control file in concurrent program and attached into a request group.
    Then I ran it from a responsibility, I am getting the below error.
    +-----------------------------
    | Starting concurrent program execution...
    +-----------------------------
    SQL*Loader-350: Syntax error at line 16.
    Expecting "," or ")", found "TIMESTAMP".
    GL_DATE TIMESTAMP 'yyyy MM dd hh:MI:SS:AM',
    ^
    SQL*Loader: Release 8.0.6.3.0 - Production on Sun Sep 5 15:28:45 2010
    (c) Copyright 1999 Oracle Corporation. All rights reserved.
    SQL*Loader-350: Syntax error at line 16.
    Expecting "," or ")", found "TIMESTAMP".
    GL_DATE TIMESTAMP 'yyyy MM dd hh:MI:SS:AM',
    ^
    My Actual Control file is,
    LOAD DATA
    INFILE '/usr/........xyz.txt'
    BADFILE '/usr/........xyz.bad'
    DISCARDFILE '/usr/........xyz.dsc
    APPEND
    INTO TABLE gl_interface_stg
    FIELDS TERMINATED BY "|" TRAILING NULLCOLS
    GL_DATE TIMESTAMP 'yyyy MM dd hh:MI:SS:AM',
    CATEGORY_NAME,
    JOURNAL_DESCRIPTION,
    JOURNAL_NAME,
    BATCH_NAME,
    BATCH_DESCRIPTION,
    ACCOUNT_CODE,
    PROCESSING_STATUS CONSTANT 'N'
    If I run the above control file from my local machine (windows) using SQLLDR username/pwd @servername control='c:/abc.ctl' from the command prompt, then all the records from xyz.txt file pushed into staging table.
    Where as, If I schedule the above control file and trying to run from a GL responsibility, I am getting the above error message.
    Do I need to modify the control file scripts in order to run from UNIX environment?
    Pls advice how to do it from UNIX environment.
    Thanks in advance.

    Hi,
    SQL*Loader-350: Syntax error at line 16.Please see if these docs help.
    SQL*LOADER-350 SYNTAX ERROR [ID 1019271.102]
    LDR-00350 TOKEN LONGER THAN MAX ALLOWABLE LENGTH ERROR WHEN LOADING ASCII FILE [ID 1020091.6]
    Do I need to modify the control file scripts in order to run from UNIX environment?
    Pls advice how to do it from UNIX environment.See these docs.
    How to Use 9i or 10g Features in SQL*Loader for Apps? [ID 423035.1]
    11i FND:How to specify Record Terminator In Sql*Loader type of concurrent program [ID 252850.1]
    Thanks,
    Hussein

  • Script fails when passing values from pl/sql to unix variable

    Script fails when passing values from pl/sql to unix variable
    Dear All,
    I am Automating STATSPACK reporting by modifying the sprepins.sql script.
    Using DBMS_JOB I take the snap of the database and at the end of the day the cron job creates the statspack report and emails it to me.
    I am storing the snapshot ids in the database and when running the report picking up the recent ids(begin snap and end snap).
    From the sprepins.sql script
    variable bid number;
    variable eid number;
    begin
    select begin_snap into :bid from db_snap;
    select end_snap into :eid from db_snap;
    end;
    This fails with the following error:
    DB Name DB Id Instance Inst Num Release Cluster Host
    RDMDEVL 3576140228 RDMDEVL 1 9.2.0.4.0 NO ibm-rdm
    :ela := ;
    ERROR at line 4:
    ORA-06550: line 4, column 17:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev sum variance
    execute forall merge time timestamp interval date
    &lt;a string literal with character set specification&gt;
    &lt;a number&gt; &lt;a single-quoted SQL string&gt; pipe
    The symbol "null" was substituted for ";" to continue.
    ORA-06550: line 6, column 16:
    PLS-00103: Encountered the symbol ";" when expecting one of the following:
    ( - + case mod new not null &lt;an identifier&gt;
    &lt;a double-quoted delimited-identifier&gt; &lt;a bind variable&gt; avg
    count current exists max min prior sql stddev su
    But when I change the select statements below the report runs successfully.
    variable bid number;
    variable eid number;
    begin
    select '46' into :bid from db_snap;
    select '47' into :eid from db_snap;
    end;
    Even changing the select statements to:
    select TO_CHAR(begin_snap) into :bid from db_snap;
    select TO_CHAR(end_snap) into :eid from db_snap;
    Does not help.
    Please Help.
    TIA,
    Nischal

    Hi,
    could it be the begin_ and end_ Colums of your query?
    Seems SQL*PLUS hs parsing problems?
    try to fetch another column from that table
    and see if the error raises again.
    Karl

  • Unable to run reports from the unix command line

    hi
    all of a sudden i am unable to run reports ( on App server 10g) either from the unix scripts or from the unix command line. But i can run them from the forms.
    Any one have any idead about this.
    Thank you

    thanks all for replying
    i have set the env variables for the session and it worked. Looks like i have to set the oracle_home and ld_library_path every time ( opening a new putty session) i call sqlldr.
    But in a whole i am trying to run sql loader from the forms. Right now we have Oracle app server 10g which forms 10g version. As oracle app server 10g didnt come with sqlldr, we are copied the sqlldr of database on to app server with different home. after this we can run sqlldr ( on app server ) from unix scripts but not from Forms. Then we opened a qurey with oracle about app server 10g not commig with sqlldr and its remedy . But they said that they dont have specific remedy for that and suggested the same what we did.
    So we came up with java package which does the same funtion as host command and trying to run sqlldr which is on the database( ie replacing the host command in the forms with the database funtion). By using that funtion i am able to run the sqlldr from sql plus but not from forms. I couldnt easily debug it as i wont through any error messages.
    Any one have any idea of this ...
    Thank you

Maybe you are looking for