How to execute .sql file
hi,
i want to execute .sql files in sql plus from a fixed location whether it may be network location or from system drive. so that i can use it from other computers when i will be working on different pc.
so please tell me for network location solution and from drive. by default it fetch from BIN directory
i am using oracle 10g.
thanks
Hi FRNzzz!! wrote:
if the .sql files are placed on some network place then also i just need to put the path of that directory ? Sure. You can either set up a desktop shortcut for SQL*Plus using the remote folder as the "Start in" location, or (what I usually do) drag the script file into your SQL*Plus window.
Edited by: William Robertson on Feb 26, 2011 2:21 PM
Similar Messages
-
How to execute .sql file in Stored Procedure?
Hi,
I have an urgent requirement, where i have to execute .sql file form Stored Procedure.
This .sql file will have set of update statement. I need to pass value to this update statement.
Kindly please help me.
Regards,
IrfanThis is required as part of Data Migration where i have to do 100 of table's update. Each time update table will defer, so its better to have in separate script file (.sql). Can u paste some sample/syntax to exceute .sql file from stored procedure. I am new to this PL/SQL.
How have you determined that it's "better" to have seperate scripts? I assume you mean the table name will "differ" (and not "defer" - I assume that's just because English isn't your first language? no problem - I think I understand what you're asking).
So what I think you're asking is that you have dynamic table names but each table needs to be updated in the same way?
Question: Why do you have tables with different names that all need the same process doing to them?
Assuming it's a valid requirement (and 99% of the time doing dynamic coding implies it's not).... you could use dynamic code, rather than 'scripts'...
e.g.
create procedure update_table(tbl_name varchar2) is
begin
execute immediate 'update '||tbl_name||' set lastupdate = null';
end;
As you haven't bothered to provide a database version, any example code/data or explanation of what you're actually doing, you're not going to get any detailed answer. Please do take the time to read the FAQ and post appropriate details so people can help you. -
How to execute sql file from servlet
Hi,
I am using JSP, Servlets and Oracle 8i in my application. I want to execute .sql file from java code. Is it possible to do that,
as we execute .sql file from sql plus prompt.
Suppose I have abc.sql file and I want to execute it from java code.
If any body have the solution then pl. reply with sample code.
Thanks,
RajeshIf any body have the solution then pl. reply with
sample code.No, no, dec - s/he doesn't want the actual solution, but the full code!
/k1 -
How to execute .sql file using ODI
Hi All,
I need to execute .sql file using ODI.
I tried @{path}{file} command in ODI procedure selecting oracle technology.but it is failing.
Do any one have any other idea to execute .sql file.
Thanks in advanceOhk...I think you can try creating batch file(.bat) if its Windows & call that from ODIOSCommand.
The bat file should contain scripts which call .sql file using sqlplus & there you can use @{path}{file} format.
See if this helps.
Regards,
Santy -
How to execute sql files with windows path ?
Hi , here's my stupid question :
I have my parent SQL script say A.sql in directory C:\program files\my files\A.sql
A.sql has calls to multiple sql files like this
@@1.sql;
@@2.sql;
When I call A.sql using sqlplus as:
sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
A.sql gets executed but then while calling "1.sql" it fails with the error
SP2-0310: unable to open file "C:\program.sql"
This is happening because of the space, how can this be handled. thx in advance :)
Regards,
Neuronmy A.sql is:
@@1.sql
@@2.sql
1.sql and 2.sql are in the same directory as A.sql.
sqlplus <username> <connection_string> @"C:\program files\my files\A.sql"
VG2,
Yes. Specify the entire path/filename and put double quotes around itA.sql has the double quotes around it, however what additional things can be done so that 1.sql and 2.sql which are present in same directory as A.sql also runs.
Ashish,
Yes the assumption is correct. Although when I cd to this directory then this issue won't come for sure.
But the requirement is you can't 'cd' to the directory and want to execute with complete path.
There is no issues in Solaris as the space is not allowed. -
How to execute .sql file if it contains unicode characters?
DB version : 10.2.0.1
OS : Windwos XP
Today I got an .sql file which needs to be executed from sql*plus prompt.
When I am trying I got error as below
SP2-0042: unknown command " ■I" - rest of line ignored.
When I checked the .sql file, I found there are Urdu characters (I believe we treat them as unicode) because of which I am facing error.
Can anyone help me in finding the way to execute this .sql file which contains unicode characters?
Thanks in advanceThat sql file contains so many insert statements. Here is one such statement
INSERT INTO MAIN_LAND_TABLE_DEMO(OBJECTID, BLK_ARA_SER_SECTOR_ID, BLK_ARA_AREA_CODE, BLK_BLOCK_ID, PLOT_ID, DOCUMENT_NO, AREA_NAME, OWNER_NAME, PLOT_AREA_SQ_F, PLOT_AREA_SQ_M, PLAN_NUMBER, PLAN_DATE, OLD_BLOCK_ID, OLD_PLOT_ID, LAND_USE, PLOT_DESC, LAND_TYPE, REMARKS, IMAGE_FILE_NAME, PLOT_SIZE_S, PLOT_SIZE_N, PLOT_SIZE_E, PLOT_SIZE_W, BUILDING_HEIGHT, GROUND_LEVEL, NO_OF_FLOORS, REFERENCE_NO, OLD_DRAWING_NO, PERMIT_NO, CUR_CUSTOMER_COD, QC) VALUES(RAK_ISP_SEQ.nextval,1,0,7,71,'','الرمس - ضايه','وقف على مساجد راس الخيمه',10936,1016,'33/2000',TO_DATE('8/5/2000','mm/dd/yyyy'),'','161','سكني','خالية','ملك','','','','','','',0,0,0,'','2000/32','',0,1); -
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-ZSQLIn 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 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 execute SQL Query in Code behind Using infopath 2010?
Hi,
I've repeatable on infopath form, and want bind it throuth code behind from SQL table. My question is that how to execute SQL Query in code behind from infopath as well as how would get Query result to bind repeatable control?
Thanks In Advance
Shoeb AhmadHello,
You first need to add new SQL DB connection then you need execute connection from code behind.
See below link to create new connection
http://office.microsoft.com/en-in/infopath-help/add-a-data-connection-to-a-microsoft-sql-server-database-HP010092823.aspx:
http://www.bizsupportonline.net/infopath2010/connect-infopath-2010-sql-server-2008-table.htm
Then use below code to execute this connection:
AdoQueryConnection conn = (AdoQueryConnection)(this.DataConnections["Data connection name"]);
string origCommand = Select * from tablename;
conn.Command = origCommand;
conn.Execute();
Finally bind your table:
http://www.bizsupportonline.net/infopath2007/4-way-programmatically-add-row-repeating-table.htm
http://stevemannspath.blogspot.in/2010/09/infopath-20072010-populate-repeating.html
Hope it could help
Hemendra:Yesterday is just a memory,Tomorrow we may never see
Please remember to mark the replies as answers if they help and unmark them if they provide no help -
Hi All,
I am very new user of Oracle JDeveloper and BPEL. I am trying to develop a process flow in JDeveloper using BPEL and get stuck when I was trying to execute a SQL quiry in the flow.
How to execute SQL quiries using JDeveloper and BPEL?????????????
Possibilities might be..
1.Configring Database Adapter
2.Using Java Embedded activities of BPEL
However, any of the above mentioned way is not clear with me how to implement it to get the query run in the process flow.
It will be great if anyone could help me with this concept....
Thanks in advance
-Prabha
Edited by: user10259700 on Sep 15, 2008 3:48 AMHi,
though BPEL has its development environment in JDeveloper, it has its own forum
BPEL
Frank -
How to execute sql qurery in st05
how to execute sql qurery in st05
thanks in advanced.Hi,
do this....
1.create a small ABAP/4 program that contains only the select statement. Before proceeding, test it to ensure that it works.
2.Open that program in the editor so that it is ready and waiting to execute.
3.Open a new session using the menu path System->Create session.
4.Run transaction ST05 (enter /nst05-zero-five, not oh-five-in the Command field, or choose the menu path System->Utilities->SQL Trace). The Trace SQL Database Requests screen is displayed.
5.If the Trace SQL Status Information box reads Trace SQL is switched off, go to step 7.
6.At this point, the Trace SQL Status Information box contains Trace SQL switched on by, followed by the user id who turned on the trace and the date and time it was started. You must switch it off before you can proceed. If the trace was started within the past hour, it is possible that it is still being used. Contact the indicated user or try again later. If the trace was started hours or days ago, the user probably left it on by mistake and it can be safely turned off. To turn off the trace, press the Trace Off pushbutton. The message in the Trace SQL Status Information box should now read Trace SQL is switched off.
7.Press the Trace On pushbutton. The Trace SQL Database Requests dialog box is displayed. The DB-Trace for User field should contain your user ID. If your user ID is not in this field, enter it now.
8.Press the OK button. You are returned to the Trace SQL Database Requests screen and the status information reads Trace SQL switched on by, indicating that you turned on the trace.
9.Switch back to the window containing your editor session (the one with your program waiting to execute).
10.Press F8 to run your program. (Only press F8, do not do anything else, do not even press the Back button.)
11.When your program has run and the hourglass is no longer displayed, switch back to the trace window.
12.Press the Trace Off pushbutton. The status information reads Trace SQL is switched off.
13.Press the List Trace pushbutton. The Trace SQL Database Requests dialog box is displayed. The fields on this screen will already contain values.
14.Press the OK button. You might need to wait a little while, at most a couple of minutes. The Trace SQL: List Database Requests screen is displayed.
15.Type %sc in the Command field and press the Enter key. The Find dialog box is displayed.
16.Type the name of the table you are tracing in the Search For field. (This is the table named in the select statement in your ABAP/4 program.)
17.Press the Find button. A search results list should be displayed with your table name highlighted.
18.Click on the first highlighted table name. You are returned to the Trace SQL: List Database Requests screen. Your cursor is positioned on the first line containing your table name. To the right of it, in the Operation column, should be the word PREPARE, OPEN, or REOPEN.
19.Press the Explain SQL button on the Application toolbar. The Show Execution Plan for SQL Statement screen is displayed.
20.Scroll down to the execution plan. The index used will be displayed in blue. -
How to execute SQL Quiries in BPEL using JDeveloper
Hi All,
I am very new user of Oracle JDeveloper and BPEL. I am trying to develop a process flow in JDeveloper using BPEL and get stuck when I was trying to execute a SQL quiry in the flow.
How to execute SQL quiries using JDeveloper and BPEL?????????????
Possibilities might be..
1.Configring Database Adapter
2.Using Java Embedded activities of BPEL
However, any of the above mentioned way is not clear with me how to implement it to get the query run in the process flow.
It will be great if anyone could hepl me with this concept....
Thanks in advance
-Prabha... or perhaps just scan the last 5 posts before you post a new thread, in which case, you'd discover that someone else already asked Help needed in executing SQL query... and got the same answer
-
Hi,
I'm trying to execute sql files located in
unix environment using sqlplus from forms 6i
in windows Me environment. I give the full
directory like @/usr/users/oracle/toto.sql.
But an error occures telling me that file
cannot found (error SP2 0310).
I hpe deeply that you can help me, please.<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by dany:
Hi,
I'm trying to execute sql files located in
unix environment using sqlplus from forms 6i
in windows Me environment. I give the full
directory like @/usr/users/oracle/toto.sql.
But an error occures telling me that file
cannot found (error SP2 0310).
I hpe deeply that you can help me, please.<HR></BLOCKQUOTE>
Be carreful of upper/lower-case. Unix is case sensitive !! Maybe @/usr/users/oracle/toto.SQL or @/usr/users/oracle/Toto.Sql or ... -
APEX: How to execute Script file from APEX
Hello All,
Can anyone tell me how to execute script file from APEX?(Step by Step process)
Thanks & Regards,
Jiten Pansarahttp://docs.oracle.com/cd/E23903_01/doc/doc.41/e21677/sql_rep.htm#AEUTL193
Regards, -
How to execute sql-queries through shell scripting in linux?
How to execute sql-queries through shell scripting in linux?
http://www.oracle.com/technology/pub/articles/saternos_scripting.html
Two simple examples:
#!/usr/bin/env bash
set_orafra () {
orafra=`echo 'set heading off
select name from v$recovery_file_dest;
exit' | sqlplus -s / as sysdba`
set_orafra
echo $orafra
#!/usr/bin/env bash
export ORACLE_SID=instance_name
export ORACLE_HOME=/path_to_oracle_home_directory
export LD_LIBRARY_PATH=$ORACLE_HOME/lib
export PATH=/$ORACLE_HOME/bin/$PATH
$ORACLE_HOME/bin/sqlplus -s <<EOF
connect scott/tiger@my_instance_name
INSERT INTO table VALUES (sysdate);
exit
EOFEdited by: Markus Waldorf on Sep 17, 2010 12:19 AM
Maybe you are looking for
-
2 computers on the same network question
My comp is downstairs and my daughters is upstairs... We have a wired Linksys router... Is there a way that I can listen to her music and vice-versa?
-
Using srw to load graphics from file in different path
Hi all, I work with report 6i and I want to build a report with dynamic graphics. I stored the file name and directory in field of my data base. I want to know if it is possible to load graphics in report with package srw. If it is possible, can you
-
Camera Raw 6.2 on Lr3.2 download page
If Cs5 is NOT installed is this Camera Raw 6.2 not expected to be installed? After extracting the Camera Raw zip file a folder 'payloads', meta.inf and Adobe Patch Installer.exe resulted. Clicking on the Patch installer resulted in a pop up message '
-
Oracle client 9i and server 10g
Sorry for incovenience.. Edited by: Chanchal Wankhade on Oct 19, 2012 4:15 AM
-
Installing or updating an extension fails
Firefox version: 3.6.8 OS: Mandriva Linux 2010.1 After adding a new extension, or updating an existing one, Firefox asks for a restart. When Firefox restarts, the extension is not installed/updated and it requires a restart. When checking the extensi