Running sql scripts from different directory
Hi
I have sql scripts in different directories as follows:
D:\myapp\sql
- load.sql
- init.sql
D:\myapp\sql\schema
-users.sql
-structure.sql
D:\myapp\sql\populate\
- data1.sql
- data2/sql
load.sql call all the other scripts as below:
@init.sql
@schema\users.sql
@schema\structure.sql
@populate\data1.sql
@populate\data2.sql
All my scripts run correctly when I run load.sql from D:\myapp\sql on comand prompt.
I need a way to run this script from a different directory say D:\ or C:\
I am writing a installer which will execute from a different directory.
Right now I get a file not found error for scripts within schema an populate folder.
Please let me know how can I make this work from a different directory.
Thanks
kelvin
Hi peter. i think you cannot run files spread across different locations.
--the method which u specified always looks to the defined path
Similar Messages
-
Running SQL scripts from a unix directory
DB version: 11.2
os Version : Solaris 5.10
We have a set of scripts used by DBAs for displaying Tablespace free space info, file size info...etc
Currently these .sql files (say free_Space.sql) are stored in directory /u02/dba_scripts/ . To execute these scripts a dba has to navigate to this directory and then login to sql* plus and from there execute it like
SQL > @free_Space.sqlI've recently come across an environment where you can login to SQL*Plus from any directory and you can execute scripts like above from any directory . How is this possible? What settings should i set for this?Herbaceous wrote:
DB version: 11.2
os Version : Solaris 5.10
We have a set of scripts used by DBAs for displaying Tablespace free space info, file size info...etc
Currently these .sql files (say free_Space.sql) are stored in directory /u02/dba_scripts/ . To execute these scripts a dba has to navigate to this directory and then login to sql* plus and from there execute it like
SQL > @free_Space.sqlI've recently come across an environment where you can login to SQL*Plus from any directory and you can execute scripts like above from any directory . How is this possible? What settings should i set for this?environmental variable SQLPATH -
Running sql script from pl/sql
Is there any standard way to run an external sql script from pl/sql
I really appreciate any assistance.If you want, I did start writing a function reading and executing statements out of sql script with utl_file.
can I issue this command in PL/SQL: EXECUTE IMMEDIATE '@filename.sql';
the function could be extended for DDL, session setting, etc...
Regards
Laurent -
Is it Possible to Run SQL Script from Java prog
Hello
Is there any API by which we can run SQl Script file ,
Just by giving database configration parameters and SQL Script file Path ,it will execute that script automaticallyYou can excute SQL statemetns throught JDBC, but that doesn't have a facility to read those statements from a file. You'd have to write code to read the file and create and execute statements through JDBC. That should be pretty straightforward though.
It's conceivable that there's a third party library out there that does it, if you know what to look for.
If you're not familiar with JDBC, check out http://java.sun.com/developer/onlineTraining/Database/JDBC20Intro/ -
Need command to run sql script from sql prompt
Hi,
I am beginner in sql i need a command to run sql file from sql prompt.In notepad i have write 10 to 15 tables creation and saved as .sql i want to run this file from sql promp pls some one help.I am very great full to all users in this forum.You can also use the 'start' command.
You may also want to look in the SQLPlus User Guide and Reference (for your release) at the set command for commands to set the number of lines per page, turn headings on or off, and so on:
http://download.oracle.com/docs/cd/E11882_01/server.112/e10823/toc.htm
HTH -- Mark D Powell -- -
Running SQL scripts from CF server
Hi,
I'm new to ColdFusion, but not to database or web
development. I'm wondering if there's anyway I can run a SQL script
on a database from my CF server. I'm running CF 5 on a 2003 Windows
server with a couple Oracle 9i DBs on the backend. I want to move
data from one DB to the other, but can't use a DB link between the
two, so a colleague suggested using CF to migrate the data. Is this
possible?
ThanksIt's possible. For each db, cold fusion needs a connection
and sufficient permissions. -
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 -
Run SQL Script from a a Batch File
I'm trying to schedulling a SQL Script by Windows Scheduler:
START
"C:\Program Files\Microsoft SQL Server\100\DTS\Binn\dtexec.exe" /FILE "C:\Users\tstjs\TESTESTESTES.sql" /MAXCONCURRENT " -1 " /CHECKPOINTING OFF /REPORTING EWCDI
PAUSE
However, when I run the batch file it giving the error below:
...sql" due to error 0xC00CE556 "Invalid at the top level of the document. Line 1, Column 1". This happens when loading a package and the file cannot be opened o r loaded correctly into an XML document. This can be the result of either provid
ing an incorrect file name to the LoadPackage method or the XML file specified h aving an incorrect format. End Error
How can I solve that problem?
Thanks!Hi SaQvl,
As Scott metioned, you shall use sqlcmd to execute a tsql script. You can reference the below link
Use the sqlcmd Utility
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Is this possible in some form?
<cfquery name="name" datasource="dsn">
#query.sqlstatement#</cfquery>Yes, if you mean creating a query as a string, then using
that in a cfquery. Usually you would need to enclose the query text
within a PreserveSingleQuotes() function if you have parameters
that are enclosed within single quotes, something like this
<cfquery name="name" datasource="dsn">
#PreserveSingleQuotes(sqlstatement)#
</cfquery>
Phil -
Running a java application from different directory
I have the file in my
c:/Folder/Program.java
I want to compile and run it from D:/ (drive)i.e from different directory.
Thanks in advance,
Praveen.javac -cp c:\Folder c:\Folder\Program.java
java -cp c:\Folder Program -
Getting windows error during running the sql scripts from form 6i
I made a little form application. The purpose of this application is to generate explain plan for a particular SQL. Some sql scripts run internally in order to populate the result on forms screen after pressing the forms button but I am getting windows error during running the sql scripts from form 6i.
I am using forms 6i with patch 17 with Oracle 10G database on windows 2000 professional on same computer.
This application runs fine with 8i.
Please inform me where the problem is and how to overcome it.
Zafri.I am using Text_IO in my form's when button press trigger , inorder to create the
text file, then in the same when button press triger
I am calling RMAN via host command in order to run the script which was created by text_IO.
Below you find some of the code. I will appreciate if you solve the problem.
when button press trigger:
Declare
in_file3 Text_IO.File_Type;
linebuf3 VARCHAR2(1800);
output11 varchar2(1000);
BEGIN
output11:='C:\EXPLAIN_PLUS\misc\rm_file.bat ';
Host(output11,no_screen);
:sql.execution_plan:= 'Working........................';
synchronize;
in_file3 := Text_IO.Fopen('c:\explain_plus\misc\create_table.txt', 'w');
Text_IO.Put_Line(in_file3, linebuf3);
Text_IO.put_line(in_file3,' ');
Text_IO.put_line(in_file3,' run { sql "create table PLAN_TABLE (statement_id,...object_name varchar2(30),object_instance numeric,object_type varchar2(30),optimizer varchar2(255),search_columns number,id .....partition_start varchar2(255),partition_stop varchar2(255),partition_id numeric,other long,distribution varchar2(30)) "; } ');
Text_IO.put_line(in_file3,' ');
Text_IO.put_line(in_file3,' ');
Text_IO.FCLOSE(in_file3)
Declare
un VARCHAR2(80);
pw VARCHAR2(80);
cn VARCHAR2(80);
output VARCHAR2(1000);
output2 VARCHAR2(1000);
dummy varchar2(40);
in_file Text_IO.File_Type;
linebuf VARCHAR2(1800);
BEGIN
Get_Connect_Info(un,pw,cn);
/* for Plan_table Begg. Second INNER BLOCK */
declare
dummy2 varchar2(40);
begin
select table_name into dummy2 from all_tables where table_name='PLAN_TABLE';
if dummy2 = 'PLAN_TABLE' then
output2:='rman target/ nocatalog @C:\EXPLAIN_PLUS\MISC\TRUNC2.txt ' ;
Host(output2,no_screen);
end if;
exception
when no_data_found then
output2:='rman target/ nocatalog @C:\EXPLAIN_PLUS\misc\create_table.txt ';
Host(output2,no_screen);
end; -- -
Running a sql script from stored procedure
Hi everyone!
Has anybody tell me how to execute a sql script from a stored
procedure!
Thanks in advance!
Sasa>
Hi everyone!
Has anybody tell me how to execute a .sql file from a stored
procedure!
Thanks in advance!
Sasa Sorry, a .sql file!! -
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 -
How to load SQL scripts from a text file.
Hi, i tried several time to load a text file/SQL script with 10 different tables and data, but 10g Express doesen't allows me to do that, any one can direct me or point out to me what i should do or do i need to adopt any special method to to get this done. i am sure there must be some thing where you can upload SQL scripts from a text file (in SQL command editor!). thanks
Hi,
see my other answer here:
SQL command editor doesn't take more than 1 insert command
This seems to be a duplicate question, right? Or am I missing something?
Regards,
~Dietmar. -
How to run a script from Oracle Form (Beside using HOST command)
I would like to run a script from Forms 6.0. I know that we can actually issue this command :
host('plus80.exe' username/password@connect_string @c:\scriptname);
BUT, is there any other alternative ?Sqlplus is a different program, so one way or the other you have to leave Forms to run sqlplus. What is you objection against HOST?
You can also run sqlplus from the database, but again you need a stored java procedure to call sqlplus (sort of HOST command that runs in the database).
Francois' solution works if your script just has a query to run, but if you have specific sqlplus commands (spool etc.) forms_ddl is probably not a solution.
Maybe you are looking for
-
How do I set up multiple Airport Expresses to connect over ethernet for Airtunes only?
I am trying to set up an Airtunes network using an Airport Extreme and three Airport Expresses connected together via ethernet (CAT5 cable). At each Airport Express there will be a speaker setup. I don't need/want internet connectivity on the network
-
Photoshop CC crashing on Mac 10.8.4 - tried other suggestions to no avail
My Photoshop CC on my Mac (10.8.4) started acting up yesterday. I have tried to validate fonts, reset fonts to default, remove preferences file, restarting, signing out and quitting CC then signing back in, uninstalling the new fonts I installed yest
-
Problem connecting to SAP R/3 in CPIC with 6.20 library
Hi, Any help or suggestion on this problem is highly appreciated. I'm currently facing a problem in connecting to SAP R/3 in CPIC with 6.20 library. The code return error at the call to CMINIT. Below is the code and error message: ============ Source
-
How to create transparent text on a solid color background?
I want to create a transparent text on a solid color backround, and I need text transparency to go all the way to through the image (i.e. do not show the solid color background). I have the transparent background layer, the solid rectangle layer that
-
Indesign CS6 just started crashing when exporting to pdf - help?
I just got Indesign CS6 a few weeks ago and I'm using it on a new macbook pro. I had exported to pdf a few times with no problem. Today, I tried the same thing and Indesign began quitting for no apparent reason. I already tried restarting my computer