Load sql statement in .bat file
Hi
I need to execute a simple sql command eg: +"truncate table tab1"+ from a DOS batch file...
my bat file contains following statement
sqlplus dilanjan/dilanjan@XE @trun.sql
my trun.sql file contains following statement
truncate tabe base
once I save the .bat file and double click it. It connects to database but the table is not getting truncated...
Some one please help me with this!
What does your screen output show you.
Did you try to execute the statement in the batch file manually?
Are the files in the same directory?
Please post some screen output
Thanks
FJFranken
Similar Messages
-
How to execute sql statement under bat file?
I want to execute following statement
C:\>sqlplus /nolog
SQL> conn scott/tiger
SQL> select * from tab;
I know I can realize it as following test.bat and testdb.sql file
test.bat is follows:
sqlplus /nolog @testdb.sql
testdb.sql is follows:
conn scott/tiger
select * from tab;
Now I don't want to use sql file,I only want to use bat file,like follows:
test.bat is follows:
sqlplus /nolog
conn scott/tiger
select * from tab;
when I run test.bat,I find only sqlplus /nolog statement execute,the other statements don't execute.
1)I want to know whether there is a method to execute sql statement only by bat file without a sql file? How to realize it?
2)If I call sql file,how to hide passord of user? Because I don't want to other persons know scott password,if I use conn scott/tiger in testdb.sql,other person can see testdb.sql and know the password. Is there a good method to avoid?
Thanks!I'm running *NIX, but works the same on Windows
bcm@bcm-laptop:~$ cat here.sh
sqlplus dbadmin/admindb << EOF
select count(*) from user_objects;
exit
EOF
bcm@bcm-laptop:~$ sh here.sh
SQL*Plus: Release 11.2.0.1.0 Production on Mon May 17 18:14:09 2010
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
COUNT(*)
9
SQL> Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
bcm@bcm-laptop:~$ Edited by: sb92075 on May 17, 2010 6:15 PM -
Run sql statement from batch file
How can we execute SQL Statement using Batch file???
I did a test.
create batch file test.bat
sqlplus "username@db /pass" @\script.sql
script.sql file has following statement
select sysdate from dual;
exit
it is working but I want to call sql statement in the same batch file instead of calling .sql script file. how can I do that any idea..This is very easy in unix shell scripting, but AFAIK, not available with Windows. It's a function of how the shell/command processor handles input redirection.
-
How to export the result from executing sql statement to excel file ?
HI all,
Great with Oracle SQL Developer, but I have have a trouble as follwing :
I want to export the result from executing sql statement to excel file . I do easily like that in TOAD ,
anyone can help me to do that ? Thanks so much
SigmasvnHello Sue,
I just tried to export to excel with the esdev extension and got java.lang.NumberFormatException. I found the workaround at Re: Windows Multi-language env, - how do I set English for application lang?
open the file sqldeveloper\jdev\bin\sqldeveloper.conf and add the following two lines:
AddVMOption -Duser.language=en
AddVMOption -Duser.country=USyet now my date formats in excel are 'american-style' instead of german. For example 01-DEC-01 so excel does not recognize it as date and therefore I can not simply change the format.
When export to excel will be native to 1.1 perhaps someone can have a look at this 'feature'
Regards
Marcus -
Tkprof : 0 user SQL statement in trace file
Hello!
Please explain , what is difference of tkprof-converting of user session trace file and an internal/background process ?
Get I message "0 user SQL statement in trace file" cause this difference?
In my target session I issued :
begin
sys.dbms_system.set_ev(...., .., 10046, 12, '');
end;
begin
sys.dbms_system.set_ev(..., .., 10053, 1, '');
end;
/Thanks and regards,
PavelDid you try to tkprof a 10053 trace ?
That is not going to show anything. 10053 traces are meant to be read as they are. tkprof is there to deal with 10046 traces. -
High-load sql statement using v$sql
Hi,
Can any one please tell me, how do we find high load sql statement and it's user from v$SQL view.
what is the query to find it.
Thank you!Hello,
You can run ADDM report and check its findings it will tell you tome stuff like the following:
Finding
67 SQL statements consuming significant database time were found.
40.7 Time spent on the CPU by the instance was responsible for a substantial part of database time.
20.7 Individual SQL statements responsible for significant user I/O wait were found.
13.7 Individual database segments responsible for significant user I/O wait were found.Kind regards
Mohamed Elazab -
How to store data into database by reading sql statements from text file
how to write java program for storing data into database by reading sql statements from text file
Step 1: Create a property file to add various queries.
Step 2: Read the properties file using ResourceBundle
Step 3: Use the jdbc to execute the query read from the property file.
So in future if you need to change query no need do any modifications in java program. But depends on how you use the property file. -
FDM-generated SQL statement in log file?
Hello all, hopefully a simple question:
When you perform an import using FDM, I know that behind the scenes a SQL SELECT statement is composed and executed against the database server. My question: is the actual SQL statement kept in a log somewhere (so that we can see it?) In our case it's an Oracle DB server and we're using the ERPI Adapter; not sure if that's relevant. We would like to grab that SQL statement and use it as a jumping-off point for some other things.
Thanks in advance for anything you can offer.The SQL Statement is not written to the log for the adapter. The only things that are logged are what show in the adapter log file if you enable loggin for the ERPi source adapter in the "Get Data" action.
-
How to run sql query in bat file in task schedular at every 10 seconds
This is my sql script :
DECLARE @countRows INT,
@currDate DATE,
@checkForTasks INT,
@created_by_id INT,
@gst_ID int;
SET @currDate = Getdate()
SET @countRows = (SELECT Count(*)
FROM [dbo].[sd_gst_effective_table]
WHERE isapplied = 0)
IF @countRows > 0
-- Check for those GST''s who are not applied yet : if they are greater than 0 then perform next task
BEGIN
SET @checkForTasks = (SELECT Count(*)
-- Check is current date equals to task date or not
FROM [dbo].[sd_gst_effective_table]
WHERE effect_date = @currDate AND isapplied = 0)
IF @checkForTasks > 0
-- If current date = task date then perform this task
BEGIN
SET @created_by_id = (SELECT TOP 1 createdby FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
SET @gst_ID = (SELECT gst_id FROM [dbo].[sd_gst_effective_table] WHERE effect_date = @currDate AND isapplied = 0)
-- STEP 1 :: InActivate the existing GST according to createdbyID
UPDATE sd_gst_rate
SET isactive = 0,
inactivedate = Getdate()
WHERE isactive = 1
AND createdby = @created_by_id
-- STEP 2 :: Activate the New GST according to implementation date and gstID
UPDATE sd_gst_rate
SET isactive = 1,
activedate = Getdate()
WHERE id = @gst_ID
-- STEP 3 :: Inactivate the applied GST from sd_gst_effective_table
UPDATE [dbo].[sd_gst_effective_table] SET isApplied = 1 WHERE gst_id = @gst_ID
END
END
DECLARE @Text AS VARCHAR(100)
DECLARE @Cmd AS VARCHAR(100)
DECLARE @value nvarchar(1000);
SET @value = (SELECT CONVERT(TIME,GETDATE()) AS HourMinuteSeconds);
SET @Text = 'File Writed ' + @value
SET @Cmd ='echo ' + @Text + ' > E:\AppTextFile.txt'
EXECUTE Master.dbo.xp_CmdShell @Cmd
This is resided in videos folder of windows , i have created a task schedular in windows 8.1 to run daily at every 10 seconds , but it is not working ... Please tell me how to deal with it.
Please note : This sql query is running perfectly in sql server. Query have no errors. Please check whats wrong with my time schedular. I just want my schedular to run every 10 seconds regardless of date.Hi Emad,
Is your script in a ".sql" file? May I know how you configure the schedule task action?
Since you didn't mention how you configure the schedule task, can you confirm you have followed the below step correctly?
Save your script in a ".sql" file.
Create a ".bat" file and call the sql file above inside with
sqlcmd.exe, you can reference
here.
Configure a schedule task to run the ".bat" file in a certain interval.
Have you tried to run the script in you bat file in a standalone commandline window? Please post the script in your bat file, It can help to diagnose the issue.
If you have any question, feel free to let me know.
Eric Zhang
TechNet Community Support -
Folks
I need to separate SQL statements from Java Code, How do i put these SQL Statements in an XML file and how to access these SQL statements from a Java code,
Any help with sample code is greatful,The use of entities as kstc_jyu may help. It really depends on how you design the XML vocabulary based on the expected usage (e.g., if the SQL statements change very often).
Back to the original question, I am right to interpret "how to use SQL statements in XML ?" as how to design an XML vocabulary to store SQL statements?
If not, you can simply use the scheme proposed by DrClap. Reading and extracting the SQL statement would be just as you would with any other XML document. Google for a Java XML tutorial. -
Spooling Extracts from Multiple SQL statements in 1 File
Hi all,
I am trying to spool extract results of 3 separate SQL statements into one single file. I wrote a SQL block similar to the one below. However, the result of the statements overwrite each other: 3 overwrote 2 and overwrote 1. Any suggestion how to combined there extracted results in one file?
spool c:\test.txt
<SQL statement 1>
<SQL statement 2>
<SQL statement 3>
/spool OFF
Thanks in advance
JasonPlease paste you SQL file here. These is no way one should overwrite another.
Eric -
Suppressing sql statement in spool file
I am trying to run a report in sql and I am spooling the output to a file. I cannot seem to figure out what set command will suppress the sql statement.
Hi,
It is "set echo off"
Deepak -
Correct the PL/SQL statement to open file in MS Word?
Hi Friends,
I use this command in when button press trigger , to open the MS Word file. But it gives some compilation errors.
word.fileopen (oshook.filespec('c:\user1.rtf'));
kindly solve this problem on urgent.
Best regards,
ShahzadThis works for me on Forms v6:
out_file := "your_file_pathname"
-- Call Word to edit the new document output.
host ('c:\program files\microsoft office\office\winword.exe '||out_file); -
Batch executing SQL Statements stored in a file in SAP DB
hi,
I am using SAP DB as database in my j2ee application. As a part of the application purpose, i need to insert a large no. of records in to the database directly. I have created the SQL file which contains the insert statements for the records
Now i need to execute this file sothat the insert statement which are inside the file get executed. I am using SQL Studio to access to the Database.
I would like to know whether any options are available in SQL Studio to for executing a SQL File.
Kindly help
Best regards,
Sudheesh...Hi,
I believe that the solution to your problem lies in creating sql studio objects.Please refer to the link below.Select the link "sql dialog" on the page.
The following options are available for sql dialog.
The following options are available in the SQL dialog:
· Creating and executing SQL statements
· Setting parameters for SQL statements
· Importing and exporting SQL statements
Select the "Importing and exporting sql statements" link on this page to know more about it.This will tell you how to import sql statements from ascii files.
Basically,what you need to do is From the context menu for the SQL dialog, choose Import File or Export File.
The link I have provided,gives a lot of other information as well.
http://help.sap.com/saphelp_nw04s/helpdata/en/ee/1c5bdfeba711d4aa2800a0c9430730/frameset.htm
Hope this helps.
Regards,
Harish
(Please award points for helpful answers)
Message was edited by: HARISH SUBRAMANIAN -
How to retrieve SQL statement in the CR 2008
I'm using Crystal Reports 2008 in MS Visual Studio 2008, how can i retrieve SQL statement from *.rpt file, i have tried this code, but it doesn't work:
ReportDocument rdReport = new ReportDocument();
rdReport.Load("Reports/EmployeeTest.rpt", OpenReportMethod.OpenReportByTempCopy);
CrystalDecisions.ReportAppServer.Controllers.RowsetController rsController;
CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument rdClient = rdReport.ReportClientDocument; // on this line it throws an exception "The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."
CrystalDecisions.ReportAppServer.DataDefModel.ISCRGroupPath rdGroupPath = new CrystalDecisions.ReportAppServer.DataDefModel.GroupPath();
string temp;
string sql;
rsController = rdClient.RowsetController;
sql = rsController.GetSQLStatement(rdGroupPath, out temp);
maybe i'm doing something wrong ?
thanksHello Ludek,
when I try to get the report from the session I got an error like this (I am using State Server Session mode i.e out proc in my application)
ReportClientDocument 'reportDocument.ReportClientDocument' threw an exception of type 'System.InvalidOperationException' CrystalDecisions.ReportAppServer.ClientDoc.ISCDReportClientDocument {System.InvalidOperationException}
+base {"The ReportClientDocument property can only be accessed when the report is opened using a Report Application Server."} System.SystemException {System.InvalidOperationException}
StackTrace " at CrystalDecisions.CrystalReports.Engine.ReportDocument.get_ReportClientDocument()" string
so is it the problem of not opened with RAS. Does installation of RAS solves the problem, If so Is it a free-ware or needs to be purchased.
Ashok
Maybe you are looking for
-
Transfer of GL a/cs manually from legacy system to SAP
How do you transfer GL a/cs manually from Legacy system to SAP, what offset a/c would you use. Also how would you open AR and AP transactions manually in SAP. Please help my email id is [email protected] Thanks
-
Can't get playlists from one one computer to another. Confident Home Sharing is turned on correctly. Have imac and macbook Air and Lion. Using smart lists.
-
Hi, I have a Creative Nomad Jukebox Zen NX 30gb version .0.02. Is it possible to connect the player to any PC and automatically get the new hardware detected in the explorer eventhough the PC does not have Creative Mediasource installed? I now that w
-
Classpath setting in Windows 98
Hi All, How can we set the classpath in Windows 98 OS ? Thanks in Advance
-
TS3212 If I re-download itunes will i lose all my songs?
When ever I hook up my iphone to my computer it will not pop up on itunes. I thought about re-downloading itunes but im scared to lose all my songs and apps. So if i re-download itunes will I lose all my songs? -Amanda