I have this SQL query
SELECT TOALIAS, COUNT(*), TO_CHAR(TIMESTAMP,'DD/MM/YYYY HH12:MI') AS TIMESTAMP
FROM TABLE1
WHERE TIMESTAMP >= SYSDATE - 15/(24*60)
AND STATUS = 1
GROUP BY TOALIAS, TO_CHAR(TIMESTAMP,'DD/MM/YYYY HH12:MI');
I am using TOAD 12.9. I want to create a job and run this query every 15 minutes and insert the data into Table2(these records will be automatically pushed as an SMS message by an application).
I also have access to create a cron job. I found this one on Stack Overflow
0 0/15 * 1/1 * ? * /home/testdata/script/sample.sql
Can I create a cron job; let it connect to database and run a query from Table1 and insert into Table2 every 15 minutes?
*/15 * * * * command
this is the way to make cronjob to run every 15 mins.
I think you'd better to write a shell script to connect to your database. Other wise you may get authentication error.
Related
In adbtask_settings Oracle Table what is the meaning of INTERVAL and max_run_time column? This table is being used for AUTOTask job execution so I want to know the significance of these columns.
The column in table adbtask_settings.
Interval=180 -- it means every 180 seconds, Autotask will try to schedule your task.
max_run_time=900 -- it means if client task already run for 1800 seconds but not yet finish, a timeout error will be signaled to interrupt client task
which means that is the maximal runtime allowed.
If you want test these functionalities then you use below proc to change the value and check the job execution time in below SELECT query:
execute DBMS_ADBTASK_ADMIN.MODIFY_ADBTASK_SETTINGS ('Auto Compress','INTERVAL',180);
execute DBMS_ADBTASK_ADMIN.MODIFY_ADBTASK_SETTINGS ('Auto Compress','MAX RUN TIME',900);
select run_duration from DBA_SCHEDULER_JOB_RUN_DETAILS where job_name='ORA$_ATSK_AUTOCOMP' order by actual_start_date desc;
I have a job scheduler to run a chain daily but from USER_SCHEDULER_JOB_LOG it seems like operation: chain_start are still in running status while operation: chain_run shown completed. Why is that so?
Besides that, SELECT * FROM ALL_SCHEDULER_RUNNING_JOBS returns no rows.
What is wrong with the job that the chain_start did not complete?
Attached snippet from USER_SCHEDULER_JOB_LOG
Please, provide with output of the following queries:
SELECT * FROM ALL_SCHEDULER_JOBS WHERE OWNER NOT IN ('SYS');
and
SELECT * FROM ALL_SCHEDULER_JOB_RUN_DETAILS WHERE OWNER NOT IN ('SYS');
I have an app that requires a single instance of a task to be run. In order to check whether a current instance of the task is already running, i check the status of the task. If the task has a combination of one or more of those statuses, then it knows the task is already running and should skip the task for now. These tasks can be called from multiple places so i could have a hundred or so calls for the task to be run in a minute.
I have the following query on Oracle 11g.
The SQL:
INSERT INTO Log2 (LogID, Action, EventDateTime)
SELECT 102211, 2, SYSDATE FROM dual WHERE NOT EXISTS
(SELECT LogID FROM Log2 T3 WHERE T3.Param2 = 102 AND T3.Action = 34 AND T3.AuditLogID NOT IN
(SELECT T2.LogID FROM Log2 T1, Log2 T2 WHERE (T1.Action IN (1,2,3) AND T2.Action = 6 AND T1.Param3=T2.Param3 AND T1.Param2 = 102))
);
At the moment the above query will sometimes allow 2 records to be inserted at the same time (eventDateTime tells me that).How can i ensure that this does not happen ? Do i need to add some locking hints ? I thought the whole query was atomic. The JDBC connection is on auto commit.
There are several parts of the app that update this table. i only want this locking to happens for the tasks item as stated above. Other parts of the app that add records to this Log2 table only ever insert one record at a time, so this single instance behaviour is not required for those other parts.
Thanks
To test a scenario I have executed below in Hive and now any of my normal queries are not running and it returning same error even for all different query executions.
Command I executed at initial is
set dfs.block.size=1073741824;
select * from l_rate where CONVERSION_START_DATE='20160701'
Later I have executed below
set dfs.block.size=${hiveconf:test}
select * from ${hiveconf:test} limit 10
However I stop my above testing and came to my normal tasks. Now I can't able to run even normal queries
select * from country limit 10;
Now I getting below error for all executions on different tables
FAILED: RuntimeException java.lang.NumberFormatException: For input
string: "${hiveconf:test} select * from ${hiveconf:test} limit 10
Please help me to get rid from this error ! even I logout my session in Quoble and reconnected but doesn't help.
I have a query to run on oracle that gives output as sid,serial#,transaction start time,sql_id,transaction id.
What I need to do is, whenever a transaction's start time is more than 1 hour behind the system time, I need to run another query with that sql_id and send it as an email.
How do I compare this time output from ORACLE sql and compare it with the system time?
I need to automate this process and add it to the cron on UNIX.
Please help!
The function SYSDATE returns the current system date. When you subtract two dates, you get a difference measured in days. Multiply by 24 and you get a difference in terms of hours.
SELECT *
FROM v$transaction
WHERE (sysdate - start_date)*24 > 1
will give you the transactions that started more than 1 hour ago. You can also use interval arithmetic if you find that clearer.
SELECT *
FROM v$transaction
WHERE sysdate - interval '1' hour > start_date