Running SQL files in UNIX

Hi,
I have following files
1. SQL file which is created from shell script with same functionality.
2. SQL file which is a Procedure.
Both these SQLs are running successfully on Windows server. Will these SQLs run on UNIX server also?
Do I have to make any change in code so that they will run in UNIX?
Please let me know.
Thanks in advance.
Aditya

Troll35 wrote:
Hello,
The SQL language is exactly the same between UNIX and windows. You only have to check none of your SQL files are refering to OS filenames with path included, because of course, OS path will not be the same between Unix and windows.
You might want to check character encoding and newlines before trying to run the script on a unix-box (especially in production... :-) )
If you can open and read the contents of the file, with say vi or less, you ought to be fine.
Brgds
Johan

Similar Messages

  • How to run .sql file in tsql or powershell

    Hi All,
    HOw to run .sql file inside the TSQL or powershell using with IF else condition. This below query works fine but when i executing through the SQL Agent it's geeting an error.Please could help how to run through the SQL agent already using execution type
    in agent as 'Operating system(CmdExec)'
    Declare @computerName varchar(100), @InstanceName varchar(50)                             
    SET @ComputerName = REPLACE(CAST(SERVERPROPERTY('ComputerNamePhysicalNetBIOS') AS varchar),'\','$')  
    SET @InstanceName = REPLACE(CAST(SERVERPROPERTY('instancename') AS varchar),'\','$')
    IF (@InstanceName = 'SQL2008R2')
    Begin  
    :r C:\BackupFolder\Test1.sql    
    :r C:\BackupFolder\Test2.sql    
    End
    IF (@InstanceName = 'SQLINS2')
    BEGIN
    :r C:\BackupFolder\Test3.sql
    END
    IF (@InstanceName = 'SQL2012')
    BEGIN
    :r C:\BackupFolder\Test4.sql
    END
    Thansk in Advance
    A-ZSQL

    In T-SQL, you can try using sqlcmd to invoke sql file
    if @@SERVERNAME='abcd'
    begin
    Master..xp_cmdshell 'sqlcmd -S <ServerName> -i BackupDetails.sql -E'
    end
    OR 
     PowerShell 
    Load the snapins
    Add-PSSnapin SqlServerCmdletSnapin100
    Add-PSSnapin SqlServerProviderSnapin100
    Function Get-SqlInstances {
    Param($ServerName = '.')
    $localInstances = @()
    [array]$captions = gwmi win32_service -computerName $ServerName | ?{$_.Name -match "mssql*" -and $_.PathName -match "sqlservr.exe"} | %{$_.Caption}
    foreach ($caption in $captions) {
    if ($caption -like "MSSQLSERVER") {
    $localInstances += $ServerName
    } else {
    $temp = $caption | %{$_.split(" ")[-1]} | %{$_.trimStart("(")} | %{$_.trimEnd(")")}
    $localInstances += "$ServerName\$temp"
    $localInstances
    $instance=Get-SqlInstances -ServerName HQDBSP17
    foreach($i in $instance)
    if($i -like 'CRM2011')
    write-host 'CRM Database'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    if( $i -like 'SQL2012')
    write-host 'SQL 2012 instance'
    invoke-sqlcmd -inputfile 'F:\PowerSQL\test.sql' -ServerInstance 'abcd'
    --Prashanth

  • How to run SQL files from Java?

    Hi,
    Can someone point me towards a link on how to run sql files in Java? Thanks.
    P.S...if I've been completely blind please go easy on me!

    Sorry forgot the formating code thingy
    public static boolean executeScript(File script, Connection conn){
        boolean success = true;
        success = script.exists();
        if(success){
          DEBUG.print("ES::READING SCRIPT:" + script.getAbsolutePath());
          StringBuffer buffer = new StringBuffer();
          success=readScript(script,buffer);
          if(success){
            try{
              String creationScript = buffer.toString();
              Statement st = conn.createStatement();
              int start = 0;
              int end = 0;
              while (end != -1 && start < creationScript.length()) {
                end = creationScript.indexOf("GO", start);
                if (end != -1) {
                  DEBUG.print(creationScript.substring(start, end));
                  st.executeUpdate(creationScript.substring(start, end));
                  start = end + 2; //2 is the length of "GO"
              st.close();
            }catch(Exception e){
              success=false;
              DEBUG.printStackTrace(e);
        }else{
          DEBUG.print("ES::SCRIPT FILE DOES NOT EXISTS");
          success=false;
        return success;
      public static boolean readScript(File script, StringBuffer buffer){
        boolean success = true;
        DEBUG.print("RS:: reading file :" + script.getAbsolutePath());
        try{
          InputStreamReader isr = new InputStreamReader(new FileInputStream(script),"UTF16");
          int ch;
          while ( (ch = isr.read()) > -1) {
            buffer.append( (char) ch);
          if (isr != null)
            isr.close();
        }catch(Exception e){
          success=false;
          DEBUG.printStackTrace(e);
        return success;
      }

  • Sqlldr: run ctl file in unix

    Hi,
    I'm new to Unix.
    How can I execute a control file in unix.
    my control file is in /home/r226124/split/ctl folder
    when trying to execute the command
    sqlldr USERID=username/password@host CONTROL=Split.ctl LOG=Split.log
    this is the error i'm getting
    ksh: sqlldr: not found
    Any help?
    Thanks.

    sqlldr is in /opt/oracle/product/client/102/bin/sqlldr
    but when i run, i'm getting this error
    r226124@host:/opt/oracle/product/client/102/bin> ls -ltr sql*
    -rw-rw-r--  1 admgwldv securedv   2865 2008-08-18 15:06 sqlnet.log
    -rwxr-xr-x  1 oracle   dba       10166 2009-01-06 17:46 sqlj
    -rwxr-xr-x  1 oracle   dba           0 2009-01-06 17:53 sqlldrO
    -rwxr-xr-x  1 oracle   dba           0 2009-01-06 17:53 sqlplusO
    -rwxr-xr-x  1 oracle   dba      744359 2009-01-06 17:57 sqlldr
    -rwxr-xr-x  1 oracle   dba       12767 2009-01-06 18:01 sqlplus
    r226124@host:/opt/oracle/product/client/102/bin> sqlldr
    ksh: sqlldr: not found
    r226124@host:/opt/oracle/product/client/102/bin>

  • How to execute one sql file in unix

    Hi,
    I need to run the follwing script in a file in unix , then run the corresponding spooled file again
    SET echo OFF;
    SET sqlblanklines ON;
    SET feedback OFF;
    SET linesize 1500;
    SET trimspool ON;
    SET termout OFF;
    SET pagesize 0;
    spool updatedfix.sql;
    SELECT ' <update stmt>
    spool OFF;
    SET termout ON;
    SET echo ON;
    SET feedback ON;
    How can the above script in a file be executed in unix
    like
    ed script
    @ script
    then
    @ updatedfix.sql;
    plz help
    thanks

    I haven't got unix to hand but the principle is the same in windows batch files..
    c:\temp>type gen_update.sql
    set echo off
    set sqlblanklines on
    set feedback off
    set linesize 1500
    set trimspool on
    set termout off
    set pagesize 0
    spool updatedfix.sql
    select 'update emp set comm = -1 where comm is null;' from dual;
    select 'exit' from dual;
    spool off;
    set termout on
    set echo on
    set feedback on
    exit
    c:\temp>sqlplus user/pass@db @gen_update.sql
    SQL*Plus: Release 10.2.0.3.0 - Production on Wed May 6 12:25:10 2009
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    SQL> set feedback on
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    c:\temp>sqlplus user/pass@db @updatedfix.sql
    SQL*Plus: Release 10.2.0.3.0 - Production on Wed May 6 12:25:37 2009
    Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.
    Connected to:
    Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    10 rows updated.
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
    With the Partitioning, OLAP and Data Mining options
    c:\temp>Just run one after the other in the script file.

  • Running .sql file or insert statements

    I have a large .sql file compiled from SQL developer from a SQL Server database. Whatever I do, I cannot get the rows to be permanently committed to the oracle db. I tried copying the text directly from the file and running it as a script on the Oracle server which seemed to work but the rows did not actually commit, they weren't available in the program and when I restarted the SQL Developer program they disappeared.
    I also tried using SQL Plus and received the same results. I even tried copying just a single insert statement in with no success.
    A second problem I have is when copying the entire file over, somewhere around line 500 it starts asking for substation variables, which I have no idea what they are or why it's asking for them.
    Thanks for any help :)

    Daft question, but have you got "commit" in your script?
    Also, you'll need to "set define off" at the beginning of your script - & is the default prompt for SQLPLUS to ask for a variable, so if you're trying to insert "You & Me", it'll prompt you for a value for Me, unless you've got set define off.

  • Running SQL files in PL/SQL Cartdrige - OAS407

    Hai!
    I am unable to run the SQL file via a PL/SQL cartridge(without
    creating the Stored procedure). I am able to run the SQL file
    which is given in the sample&demos through the 'admin' listener
    (port 8889). When i doing it through some other listener i am
    getting error saying that URL not found.
    I think I have configured the virtual path correctly for my
    application and Cartridge.
    Is there any thing else I am missing?
    Thank you
    Phanesh
    null

    I am working on this too. I am sure that the problem is the
    procedures for the HTM are not install correctly. I read one
    part of the documentation, it said that you have to log in as
    SYS and grant some procedure to USER, but I forgot. If you
    found it, PLEASE let me know. Thanks.
    Phanesh (guest) wrote:
    : Hai!
    : I am unable to run the SQL file via a PL/SQL cartridge(without
    : creating the Stored procedure). I am able to run the SQL file
    : which is given in the sample&demos through the 'admin' listener
    : (port 8889). When i doing it through some other listener i am
    : getting error saying that URL not found.
    : I think I have configured the virtual path correctly for my
    : application and Cartridge.
    : Is there any thing else I am missing?
    : Thank you
    : Phanesh
    null

  • Is it possible to run .sql files in oracle

    Hi
    I have a .sql file which contains the scripts of the tables .Is it possible for me to run the .sql file in oracle or will i have to run the scripts of each tables separately becoz there is about 240 table scripts in that single .sql file. In mysql by giving " \.filename.sql " the whole scripts in the .sql file will get executed .Is there any thing like this in oracle9i.Also i want to know how to make a dump file in oracle and to run that?
    Thanking you in advance

    Hi
    I did the way u said the whole script file is running but the execution of the script is not happening. The below is a part of script but the table creation is not happening at the end of each table script
    5946 drop table lms_class_permission;
    5947 CREATE TABLE lms_class_permission (
    5948 pk_permission_id NUMBER(11) NOT NULL ,
    5949 fk_class_Id NUMBER(11) default NULL,
    5950 fkSysGroupId NUMBER(11) default NULL,
    5951 perm NUMBER(11) default '0',
    5952 CONSTRAINT pk_permission_id_lms_class PRIMARY KEY (pk_permission_id),
    5953 CONSTRAINT uk_lms_class_permission UNIQUE (fk_class_Id,fkSysGroupId),
    5954 CONSTRAINT fk_lms_Class_Permission_1 FOREIGN KEY (fk_class_Id) REFERENCES lms_class (pk_class
    5955 CONSTRAINT fk_lms_Class_Permission_2 FOREIGN KEY (fkSysGroupId) REFERENCES t_system_groups (g
    5956 );
    5957 create index fk_class_Id_lms_class_perm on lms_class_permission (fk_class_Id);
    5958 create index fkSysGroupId on lms_class_permission (fkSysGroupId);
    5959 CREATE SEQUENCE lms_class_permission_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NO
    5960 CREATE OR REPLACE TRIGGER TR_lms_class_permission_BI
    5961 BEFORE INSERT
    5962 ON lms_class_permission
    5963 REFERENCING NEW AS NEW OLD AS OLD
    5964 FOR EACH ROW
    5965 BEGIN
    5966 SELECT lms_class_permission_SEQ.NEXTVAL INTO :NEW.pk_permission_id FROM dual;
    5967 END ;
    5968 drop table lms_contact_us ;
    5969 CREATE TABLE lms_contact_us (
    5970 pkautoid NUMBER(10) not null ,
    5971 user_name VARCHAR2(255) default '0',
    5972 email VARCHAR2(255) default '0',
    5973 subject VARCHAR2(1000),
    5974 message VARCHAR2(1000),
    5975 loginId VARCHAR2(255) default NULL,
    5976 status NUMBER(11) default NULL,
    5977 classId NUMBER(11) default NULL,
    5978 CONSTRAINT pkautoid_lms_contact_us PRIMARY KEY (pkautoid)
    5979 );
    5980 CREATE SEQUENCE lms_contact_us_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NOCYCLE NO
    5981 CREATE OR REPLACE TRIGGER TR_lms_contact_us_BI
    5982 BEFORE INSERT
    5983 ON lms_contact_us
    5984 REFERENCING NEW AS NEW OLD AS OLD
    5985 FOR EACH ROW
    5986 BEGIN
    5987 SELECT lms_contact_us_SEQ.NEXTVAL INTO :NEW.pkautoid FROM dual;
    5988 END ;
    5989 drop table borland_feedback ;
    5990 CREATE TABLE borland_feedback (
    5991 pkautoid NUMBER(10) not null ,
    5992 FeedTitle VARCHAR2(1000),
    5993 FeedBody VARCHAR2(1000),
    5994 EnteredBy NUMBER(11) default '0',
    5995 FeedStatus NUMBER(11) default '0',
    5996 FeedEnteredDate TIMESTAMP,
    5997 CONSTRAINT pkautoid_borland_feedback PRIMARY KEY (pkautoid)
    5998 );
    5999 CREATE SEQUENCE borland_feedback_SEQ INCREMENT BY 1 START WITH 1 MAXVALUE 2147483647 NOCYCLE
    6000 CREATE OR REPLACE TRIGGER TR_borland_feedback_BI
    6001 BEFORE INSERT
    6002 ON borland_feedback
    6003 REFERENCING NEW AS NEW OLD AS OLD
    6004 FOR EACH ROW
    6005 BEGIN
    6006 SELECT borland_feedback_SEQ.NEXTVAL INTO :NEW.pkautoid FROM dual;
    6007 END ;
    Thanking you advance
    dinny

  • Can't run SQL files

    I have a Windows XP system and I'm running Sql Developer version 1.0.0.15.
    I open a sql file in Oracle Developer and choose Run SQLFile.sql from the Run menu and it gives and error that it can't be started because it isn't a runnable target. However, if I just copy out the text and paste it into a worksheet it runs fine.
    Why can't you run SQL when it is opened from a file?

    You need to associate it with a connection.
    There is drop down list of connections at the top right of each sql window. Pick a connection from there and the run action should be enabled.

  • Running .sql file from JDev9i???

    In JDev 3.2.3 I could just right click on the sql file and invoke SQL*Plus. This does not appear in JDev9i. Could someone please lend some aid?

    I think it is simply that the path to your
    SQL*Plus is not set (or is incorrect).
    Try menu Tools | Preferences
    Click on the SQL*Plus element on Left
    Enter the path to your SQL*Plus executable
    $(OracleHome)\bin\SQLPLUSW.EXE)
    and then it should work.
    -John
    null

  • Getting error while running .sql file

    Hi,
      I export a schema "schema1" with name export1.sql i am trying to run this .sql at
    schema2 i am getting an error  ' input is too long () 2499 charecters"
    even if put set buffersize 100000 and set define off i am getting same error file won't run.Any help

    Make the lines shorter?
    How are you producing the export1.sql script?

  • How to run .ksh file in unix from .jsp files

    Hi frnd,
    How to connect unix servers from .jsp file & I want to run unix scripts .ksh files from .jsp files
    Thanku
    bhupathipawan

    It is usually a bad idea to do any major processing directly within a JSP. It is better to create a helper class and invoke methods on that. This helper class can then be tested outside of the inhospitable JSP environment.
    To run the '.ksh' file you will need to use either Runtime.exec() or the more modern ProcessBuilder. You will save yourself a lot of grief if you read thoroughly the 4 sections of http://www.javaworld.com/javaworld/jw-12-2000/jw-1229-traps.html and then implement the recommendations.
    Note - although the 'traps' article is written around the use of Runtime.exec(), it's content is equally applicable to ProcessBuilder.

  • Running sql script from unix using

    Hello!
    When i run the following sql, it doesn't executes any statement after the 1st SQL.
    anyone know the reason?
    #!/bin/bash
    set -x
    echo test
    sqlplus /nolog << EOF
    set serveroutput on size 1000000
    conn userid/pwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=10.92.xxx.xxx)(Port=1521))(CONNECT_DATA=(SID=oradbid)))
    select '1st sql output' from dual;
    exit
    EOF.
    sqlplus /nolog << EOF
    set serveroutput on size 1000000
    conn userid/pwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(Host=10.92.xxx.xxx)(Port=1521))(CONNECT_DATA=(SID=oradbid)))
    select '2nd sqloutput' from dual;
    exit
    EOF
    --------------------------------

    You have to remove . (dot) after first EOF.
    Best regards
    Maxim

  • How to Run a .sql file from simple java class

    How to execute a .sql file consisting of Complex Queries,procedures through simple java class.
    The queries may have different delimiters,queries independant of each other.
    I am able to do with Specific De-limiter.But I need in such a way that there should not be any
    Constraints. Since My .sql may Contain different De-limiters.
    If any one can Suggest Some Solution.
    It will be Great Help.
    regards
    Anil

    Check out ibatis script runner, it' a third party library but quite handy for running sql files...
    m

  • How to use Sql Loader in Unix Environmant

    Hi All,
    Can anyone explain me please how to use sql Loader in unix environment.
    Actually i have one control file i want to run that file in Unix how can i achive please explain me
    Thank's

    Hi Kuljeet,
    Thank you for your replay
    I just put my control file into the Unix Environmant that's fime
    and when i trying to entering the following cmd in Unix environment i am getting this error
    sqlldr username/password@string control='unix_pathname'i am not sure about the path name my question is
    1) Do i need to give the Local file Path Or Unix Path
    This is  the error in Sql Loader:
    SQL*Loader: Release 10.2.0.4.0 - Production on Mon Sep 24 13:14:23 2012
    Copyright (c) 1982, 2007, Oracle. All rights reserved.
    SQL*Loader-500: Unable to open file (/bx167a/riskbatch/rdwdbat/sample_upl.upl)
    SQL*Loader-553: file not found
    SQL*Loader-509: System error: No such file or directory
    Could you please correct me
    Thank's

Maybe you are looking for

  • Problems with my online number from Mexico City

    Hello, My online number from Mexico 55 84 21 94 is not working correctly in Mexico City. When my family use a landline from MX to call me another person answer the phone call, but if they use a cellphone it works and I receive the phone call. That's

  • Pl/sql debugging with jdev9.0.5

    Hi, I'm trying to debug a pl/sql procedure within jdev implemented debugger. But the problem is that it isn't stopping on the breakpoints I set. peace Cyrill

  • No Audio with my touch Smart 600

    I have a touch smart 600, and have ran all the diagnostics and updates but it still does not have any sound to it!

  • Can't use the website of ebookers.at (only that site) as Mozilla always says "no response"

    I'm able to open the website of ebookers.at but when I click on the site Mozilla says "no response" right away. I've no problems with other sites only the above mentioned one and I've already tried several times. Mozilla always crashed. Is there any

  • ITunes shuts down when computer sleeps

    My computer falls asleep when I'm playing music on iTunes. I guess my computer thinks that there's no activity. I've tried tweaking with the energy saver settings, but it's still happening. It does the same thing when I'm watching videos on iTunes.