Automating SQL scripts in Toad for Oracle - sql

I'm not a DBA, so bear with me.
I've scheduled tasks through Toad's automation designer, but this uses Windows task scheduler. It's using Oracle 12c.
How can I ensure my scripts execute on time without running a local machine with scheduled tasks? Can this be done without additional software? Thanks in advance.

I don't know what those scripts do.
However, if they can be rewritten into stored procedures, then you could schedule them as database jobs using either DBMS_SCHEDULER (or DBMS_JOB, which is simpler but still quite usable) package.
As a matter of fact, DBMS_SCHEDULER can even run your operating system scripts, using job_type => 'external_script'. Read documentation for more info.
See if it helps.

Related

How to automatically export stored procedures for a release SQL Server 2008

Our team was releasing a new version of our system yesterday and we came across some issues with stored procedures. To cut a long story short we had to upload the old stored procedures to fix the issues.
I have now been given the task to automatically back up the stored procedures for our database before we release a build. I have went through a lot of sites and I've looked at generating scripts, making batch files, doing whole backups and scheduling tasks etc but none of these solutions would automatically backup only the stored procedures.
Any help in this case would be greatly appreciated thanks in advance.
Best Regards
Ryan
In Management Studio, right click on your database in the Object Explorer window, go to Tasks -> Generate Scripts... and follow the wizard.
You need to use SMO libraries to create your scripts and use them in command line batch files. Read more in http://msdn.microsoft.com/en-us/library/ms162153.aspx
Before run de script generator, set Option Continue scripting on Error, otherwise script will not be gereated.
If option DROP and Create is chosen, set option Script Object-Levels permission for stored procedures
Is your software source code checked into source control? It might be of benefit if your database is as well. This is the method software has used to manage versions and releases for years, and its about time DB's joined the party.
I suggest you look into a database project (available in the current 2015 free version of SQL Server Data Tools), which is a way of checking your objects in and out of a repository etc. It's a more complete way of managing database objects and fits into the software lifecycle. You can release your database codebase in conjunction with your software codebase and manage it all in one.

Scheduled program VB.NET

I would like to ask for a recommendation for my project.
Basically, it's a scheduled program that shall run at a given period of time, for example,
6:00 pm daily, it includes importing an excel file and inserting it in a sql table.
I have my codes with me, but I dont know how to execute this program automatically.
can you give me some advice
I'm using MSSQL2005 server. And VB.NET language.
Build your application to an executable that just does the task once and use Windows task scheduler.
In my old shop, we occassionally forgot about the one-off tasks running under Task SCheduler, but we had lots of SQL Agent jobs running nightly or weekly. So, just to keep things all together, we created SQL Agent jobs for things like this. So my answer is the same as Bala's, but I would trigger the app through a job on SQL Server instead.
How? Take a look at this: http://bp0.blogger.com/_mDuWqJiJyXE/SB6fy1yBRfI/AAAAAAAAATc/bmdxxAfFTjc/s1600-h/JS_Steps1.png
You could use Visual Studio to create windows service which performs the timed actions...it's a steeper learning curve though.

how to connect mysql from hudson?

I am executing regression test created by selenium and triggered from hudson. After this test i need to clean up DB , so for this any option there in Hudson to connect DB and execute some script? Or what is the best way to do this one?
Thanks in advance
by Mani
There is no build-in plugin in Hudson/Jenkins that I'm aware of, but you can make the Hudson build process execute a shell script/bat file that in turn can do whatever you can do with a script:
Shell scripts and Windows Batch commands
Depending on your situation it might be preferable to add this step to an overall build script (as an <exec> task in ant for example).
You can do as stated above or if you connect to the databases using JPA or Hibernate you can set up those so the database is recreated each time. That's how I do it on my case. From the question is hard to tell which method you use to connect to the database.
My tests are being invoked through TestNG and before they run, I clean up the DB via JDBC.
Since you didn't say which DB you are using, I recommending Googling for "[DB] JDBC example", changing [DB] for whatever DBMS you are using :)

How to create and restore backups of the Oracle 10g database by using commanline scripts automatically?

I want to automate the periodic backup and restore of the Oracle 10g Database.Please, someone help me immediately.
and please note that I want the task to be performed from the command line scripts.
You can use the Oracle Recovery Manager (aka RMAN) from the command line.
Here is a good link that provides good instruction/tutorial on how to use RMAN and how to setup scripting files in order to do backups easily from the command line.
Also a very good kick-starter into RMAN backup/restore: http://www.orafusion.com/art_rman1.htm

Is it possible to automate MS SQL Server (2005) queries via SQL Server Management Studio?

I have two queries saved on my SQL Server 2005 and I would like to have them running at certain intervals, e.g. every 24 hours. Is there a way to automate these queries and schedule them via SQL Server Management Studio?
You need to use the SQL Server Agent, installed as part of SQL Server. This is the background service that's responsible for running scheduled maintenance and backup tasks.
Expand the SQL Server Agent node in SQL Server Management Studio, you should see a tree node called "Jobs"
Right-clicking this will give you the option to add a new job. Jobs consist of a series of steps to be executed in order, and when you add a new step to your job, you can choose various types of step, including "Transact-SQL Script"
Create a new job, add a single T-SQL step, put the queries that you want to run into the step properties, and then use the "Schedule" option in the Job properties to create a recurring schedule that'll run the job every 24 hours (or whenever).
You can use the SQL Server Agent, which will allow the server to run the script/stored procedure.
You can also use the Windows Task Scheduler, either on the server or on any other server or workstation to schedule isqlw/sqlcmd to execute your script/stored procedure.
Create a job with a step in which you execute your queries; the job can be scheduled at your needs.
At a previous employer the operations department had a task sheduling application. They prefered to use the command line tools that come with sql server to execute jobs (stored procedures) on a scheduled basis. This way the "task scheduling application" could recieve an exit status (pass/fail, ok/error) and hold up dependent jobs.
I'm sorry I don't remember the name of the command line tool, but it was part of the sql server distro. I also do not remember the name of the task scheduling application. It was not the windows task scheduler. It was something enterprise level used to manage the nightly cycle.
Not sure of the scale of your project, but this is another way to go.
SKapsal's comment on a command line tool for executing SQL commands is a reference to osql (for SQL2000) or sqlcmd (for SQL2005+). You could save your script a file and run it from that command line using Windows Task Scheduler or something similar.
SQL Agent is still the preferred solution, however, as it provides GUI controls for job creation, scheduling, logging and viewing job execution history/results.
how to schedule a job for sql query to run daily?
This is similar question with helpful answer.
Covering simple step by step manual.