Check a Pentaho result every 30 minutes and run other steps - pentaho

I am new to Pentaho. I currently has a job like this:
condition 1 -> condition 2 -> if successful then run this sql scripts, if failed then send email
I would like to have a loop that is more like:
(condition 1 -> condition -> 2) are run every 30 minutes
-> if successful then run the sql scripts and stop going back to conditions to check
-> if failed then loop back and run in the next interval
Is this possible to achieve?
Many thanks!

You can do it with a job. See screenshots.
You'll need to replace the simple evaluation step by your condition checking routine.

You could program a job to run every 30 minutes and add a step generating a file or inserting/updating a DB table that you could use to check if you need to run the conditions or not.

Related

How do I update the column value after 4 days?

I am looking for your assistant in understanding the way and the code to get the column value to be changed after 4 days.
Currently, whenever I am inserting a new row in the database, the value of the flag will be "Y" by default and I will capture the created date & time by storing the sysdate by default. Now, I want the flag to be changed to "N" after 4 days from the creation.
So, please guide and instruct me on the way to do the above.
You should look into creating a Trigger on INSERT/UPDATE/DELETE IF your table is frequently accessed for those operations.
If not, then you would have to schedule a job to run SQL daily or how frequent you'd like to check.
how to schedule a job for sql query to run daily?

Loop SQL Query For Specific Time

I have a sql query that I need to loop through the system views sys.dm_exec_requests and sys.dm_exec_sessions every 60 seconds to pull specific information and dump it into a separate table. After a specified time I would like it to kill the loop. How would the loop be formatted?
This sounds like a SQL Agent job. If so, the short form of the answer is:
Create the job with one step that runs the query
Add a Schedule that runs it once a minute, starting whenever you want it to start
Set the schedule to stop running it when the cut-off time is reached
The long form, of course, is all the detail work behind creating a SQL Agent job. Best to read up on them in Books Online (here)
Don't do this in a loop. Do it with a job.
Write a sproc that does the query and save the results and then call it from a job.
I think you should use a job as well. But some work environments that is not practical. So you could have something like:
WHILE #StopTime < getdate()
BEGIN
exec LogCurrentData
WAITFOR DELAY '00:01:00'; -- wait 1 minute
END
I think the best way is creating a Job
There is a post that explain how to create a job step by step (with images) in SQL Server.
You can visit the post here
If you prefer a video tutorial, you can visit this link

How to find out if scheduled sql job did not run

Let's say I have the following scenario:
In SQL Server Agent, there is a scheduled job that runs everyday at 6 AM and it works fine everyday. One day the server fails at 5 AM til 8 AM, but when the server is up again is 2 hours later than when the job that was scheduled to run.
How can I check that the job should have had run previously and indicate some kind of "Missed Schedule" status?
Approach:
Run EXEC MSDB.DBO.SP_GET_COMPOSITE_JOB_INFO #job_id and check that last_run_time & last_run_time exists in [msdb].[dbo].[sysjobhistory], if it doesn't exist it means that job was scheduled but it did not run. Is this approach correct?
Any suggestions/comments?
Thanks in advance.
I was just trying to figure this seemingly - had to already be solved problem - out. Seems like it isn't as common a need as one might think. Anyhow, I was about to embark on the journey of writing my own check when I found the below. It seems to work, in that it caught the job I wanted it to find on my server.
The issue with your approach is that if it is a fairly quickly recurring job or it runs every day but skipped Saturday and you check on Monday. It seemed to me to do this right, you needed to get into the frequency and build a table of when it ought to have run then go check history and see if it ran. The below is long and will take time to understand but it does seem to be doing that.
http://www.nuronconsulting.com/TemplateScripts_SQL_Agent_JobsJobScript_FindMissedJobs_sql.aspx

Jenkins Job - Build If SQL Condition True

We want to setup a hudson job that will execute a query every 10 minutes looking for a date column to equal current date. If this condition is false the job should just loop and run again in 10 minute intervals until the condition is true at which point we want the job to move on to a 2nd step which will execute another sql to update a table. Is it possible to set this up in a single job? I have been searching but have not found an example of this scenario anywhere.
Of course you can.It can be pretty simple actually.
Make a new job in Hudson which automatically runs every 10 minutes.As for the job content,write some shell script to do the sql search. Then if the code returns true, continue with the 2nd step,if not,just end the job.It will be started by Hudson 10 minutes later.

SQL plus running multiple queries

I have 12 queries to run, but can not run at the same time. I would like to start the first query, then as soon as it completes the next query begins, when it completes the third query starts and so on. Want this to be automatic. Each query writes a txt file. Thanks
Seems to me like you just have to create a script and call that script:
#query1.sql
#query2.sql
...
Or am I missing something?
Paste them all in 1 file with a GO statement between should do the trick.