Job Seekers   Employers
dbapool: Authors | Submissions | Contact Us
   Forgot password? | Sign up
  Home   Discussion Forum   Articles   Interview Questions   FAQs   Scripts   Rewards   Analyzer   White Papers   Blog   Certification   Downloads   Tools
 

Topic: Database Administration >> how to use sql commands using batch file

Disclaimer: The purpose of all dbapool forums including OCP and Other Oracle Certification forums is to help each other with specific issues but not to share dump and copyrighted exam content, materials or intellectual property. You may review the entire Oracle Certification Program Candidate Agreement online Here.



  


 Title: how to use sql commands using batch file
 Neeraj  Posted: Feb 26, 2008 04:06:57 AM

 Total Post: 228
 Joined: Jan, 2007






 hi,
anyone can tell me how to make batch file for using sql commands ?
thxs

 MOH_DBA
Posted: Feb 27, 2008 03:51:36 PM  

 Total Post: 123
 Joined: Nov, 2007






 
You first create the patch file(C:\file.bat) and put in this file the following:
conn username/password@database @C:\sqlfile.sql

then create the sql file and put what ever you want in it.

 MOH_DBA
Posted: Feb 27, 2008 03:53:59 PM  

 Total Post: 123
 Joined: Nov, 2007






 
Sorry: you put instead of the (conn) sqlplus to be as follow:

sqlplus username/password@database @C:\sqlfile.sql

 Neeraj
Posted: Feb 28, 2008 03:50:05 AM  

 Total Post: 228
 Joined: Jan, 2007






 
hi,
thxs but i want to know how to use sql command in this batch file ,like how to vreate a varable & want to store some value in it,
like i want to store date in a variable using batch file, tell me how to do it .
thxs

 MOH_DBA
Posted: Feb 28, 2008 02:54:17 PM  

 Total Post: 123
 Joined: Nov, 2007






 
download from the link below the file name (backup.zip)
this file has good example of what i understand you want.
Hope that will help.

http://ourworld.compuserve.com/homepages/Peter_Koletzke/tip.htm#expname

 Neeraj
Posted: Feb 29, 2008 03:31:30 AM  

 Total Post: 228
 Joined: Jan, 2007






 
thxs but it didnt help me a lot, i m still searching .

 MOH_DBA
Posted: Mar 01, 2008 03:19:21 PM  

 Total Post: 123
 Joined: Nov, 2007






 
help me to understand,
You want to store some variables that are taken from sql commands and use them in a batch file?

 Neeraj
Posted: Mar 03, 2008 12:14:07 AM  

 Total Post: 228
 Joined: Jan, 2007






 
as i told u i get backup of my database as i described above ,its stored as date wise like dubp_02032008
i cant store only 2 dump so i got to delete dump b4 2 days ,i want to do it automatcially when i get 2nd dump after that batch shud delete 2 days b4 dump itself.
i dont know how to do it useing dos command in batch file how to get date of 2 days back. so i though i careat a batch file in that i can hav a variable that can store date of 2 days back then ibatch file can use that date & delte dump of that date.
now suggest me how to perform it.
thxs

 MOH_DBA
Posted: Mar 03, 2008 03:59:34 PM  

 Total Post: 123
 Joined: Nov, 2007






 
I can give you this suggestion but it have limitation, it's limitation is, when a new month begin you need to delete the file manual but during the month it will work correctly. my suggestion is to convert date to number and substract 2 days from it. like this:

1) change the format of the date(from regional and language setting) to yyyy-mm-dd.

2) put the following in your batch file:
C:\>set today=%date:~-10%
C:\>SET today=%today: =%
C:\>SET today=%today:-=% or C:\>SET today=%today:/=% (depend on the seperator)

3) do the export : file=%today%.dmp

4)set /A today=%today:~-8% -2
del C:\%today%.dmp

but as i said hope to consider the limitation.

hope that will help you.

 Time Zone: EDT

  




Forum Rules & Description


Who Can Read The Forum? Any registered user or guest
Who Can Post New Topics? Any registered user
Who Can Post Replies? Any registered user




 








Get FREE Magazines

Top 10 Forum User

  Murtuja Khokhar814
  Mohammed Taj694
  Jayanta Sur479
  Vigyan Kaushik386
  positive fanatic361
  Gitesh Trivedi322
  Gopu Gopi239
  neeraj sharma228
  Ramesh Jois226
  snehalatha p169






oracle Mag



  About Us Advertise Terms of Use Privacy Newsletters Contact Us    

Home   Discussion Forum   FAQs  Articles  Jobs   Newsletters  Directory  Downloads 

Our Premium Sponsor
Confio Software