I was trying to get a job run every business day (MON to SAT) at 6:30am which the Oracle scheduler refused with
ORA-27419 "unable to determine valid execution date from repeat
interval"
I started losing my mind when i discovered the following behaviour:
First, create a dummy job. Note that it has no schedule and is not enabled.
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => '"TMP_DUMMY"',
job_type => 'PLSQL_BLOCK',
job_action => 'begin
dbms_lock.sleep(5);
end;',
number_of_arguments => 0,
start_date => NULL,
end_date => NULL,
enabled => FALSE,
auto_drop => FALSE,
comments => 'Test Job');
DBMS_SCHEDULER.SET_ATTRIBUTE(
name => '"TMP_DUMMY"', attribute => 'store_output', value => TRUE);
DBMS_SCHEDULER.SET_ATTRIBUTE( name => '"TMP_DUMMY"', attribute => 'logging_level', value => DBMS_SCHEDULER.LOGGING_OFF);
END;
/
Next step, set a repeat_interval using BYTIME with any execution time which is equal to or less than 02:55 (MI:SS) after the full hour. It does not matter whether this is done with or without the Hour part and for the former option the exact hour does not matter as well.
BEGIN
DBMS_SCHEDULER.set_attribute( name => '"TMP_DUMMY"', attribute => 'repeat_interval', value => 'FREQ=DAILY;BYTIME=010255');
DBMS_SCHEDULER.enable(name=>'"TMP_DUMMY"');
END;
/
This works perfectly fine for me.
Now i want to increase the BYTIME by 1 second to 02:56 (MI:SS)
BEGIN
DBMS_SCHEDULER.set_attribute( name => '"TMP_DUMMY"', attribute => 'repeat_interval', value => 'FREQ=DAILY;BYTIME=010256');
END;
/
Running this attribute change i get
ORA-27470: failed to re-enable "[schema]"."TMP_DUMMY" after making requested change
ORA-27419: unable to determined valid execution date from repeat interval
I have verified this behaviour for all MI:SS combinations:
set serveroutput on
DECLARE
l_rep_interval VARCHAR2(50 CHAR);
BEGIN
FOR mi IN 0..59
LOOP
FOR ss IN 0..59
LOOP
l_rep_interval := 'FREQ=DAILY;BYTIME='||lpad(to_char(mi*100+ss),4,'0');
DBMS_SCHEDULER.set_attribute( name => '"TMP_DUMMY"', attribute => 'repeat_interval', value => l_rep_interval);
DBMS_SCHEDULER.enable(name=>'"TMP_DUMMY"');
DBMS_OUTPUT.PUT_LINE(l_rep_interval);
END LOOP; --end ss
END LOOP; --end mi
EXCEPTION WHEN OTHERS THEN NULL;
END;
/
It is working properly from 00:00 until 02:55 and fails for all other times.
For me this looks like the MI:SS part is treated as a tinyint and higher values cause a type overflow.
Is this a Bug in the scheduler or am i missing something here?
Oracle version is 12c.
I just ran into this same issue. It looks like (from the documentation) that BYTIME is not recognised (even though SQLDeveloper uses it if you look at the SQL tab of the job GUI)
I found that the following works using BYMinute and ByHour
DBMS_SCHEDULER.set_attribute( name => '"TEST"."JOB"', attribute => 'repeat_interval', value => 'FREQ=DAILY;BYHOUR=9;BYMINUTE=30;BYDAY=MON,TUE,WED,THU,FRI,SAT,SUN');
Hope this helps someone.
Related
I'm following the example Class::DBI.
I create the cd table like that in my MariaDB database:
CREATE TABLE cd (
cdid INTEGER PRIMARY KEY,
artist INTEGER, # references 'artist'
title VARCHAR(255),
year CHAR(4)
);
The primary key cdid is not set to auto-incremental. I want to use a sequence in MariaDB. So, I configured the sequence:
mysql> CREATE SEQUENCE cd_seq START WITH 100 INCREMENT BY 10;
Query OK, 0 rows affected (0.01 sec)
mysql> SELECT NEXTVAL(cd_seq);
+-----------------+
| NEXTVAL(cd_seq) |
+-----------------+
| 100 |
+-----------------+
1 row in set (0.00 sec)
And set-up the Music::CD class to use it:
Music::CD->columns(Primary => qw/cdid/);
Music::CD->sequence('cd_seq');
Music::CD->columns(Others => qw/artist title year/);
After that, I try this inserts:
# NORMAL INSERT
my $cd = Music::CD->insert({
cdid => 4,
artist => 2,
title => 'October',
year => 1980,
});
# SEQUENCE INSERT
my $cd = Music::CD->insert({
artist => 2,
title => 'October',
year => 1980,
});
The "normal insert" succeed, but the "sequence insert" give me this error:
DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that
corresponds to your MariaDB server version for the right syntax to use near ''cd_seq')' at line
1 [for Statement "SELECT NEXTVAL ('cd_seq')
"] at /usr/local/share/perl5/site_perl/DBIx/ContextualFetch.pm line 52.
I think the quotation marks ('') are provoking the error, because when I put the command "SELECT NEXTVAL (cd_seq)" (without quotations) in mysql client it works (see above). I proved all combinations (', ", `, no quotation), but still...
Any idea?
My versions: perl 5.30.3, 10.5.4-MariaDB
The documentation for sequence() says this:
If you are using a database with AUTO_INCREMENT (e.g. MySQL) then you do not need this, and any call to insert() without a primary key specified will fill this in automagically.
MariaDB is based on MySQL. Therefore you do not need the call to sequence(). Use the AUTO_INCREMENT keyword in your table definition instead.
In a testing.psql file have the following script.
do
$$
BEGIN
UPDATE confi set val = 'YES' Where Name ='ISVALIDCUST';
--savepoint 1 here;
perform testUpdateAdjust1(
tname => 'Test1',
custnumber => 'custno1121',
custid => 61,
regid => 'F');
--rollback to 1 here;
--savepoint 2 here;
perform testUpdateAdjust2(
tname => 'Test2',
custnumber => 'custno1122',
custid => 34,
regid => 'T'
);
--rollback to 2 here;
--savepoint 3 here;
perform testUpdateAdjust3(
tname => 'Test3',
custnumber => 'custno1123',
custid => 54,
regid => 'F'
);
--rollback to 3 here;
end $$ language plpgsql;
The requirement is
First update "confi" table.
Then testUpdateAdjust1 execution is completed then Rollback the operations done by testUpdateAdjust1 only.
After testUpdateAdjust2 execution is completed then Rollback the operations done by testUpdateAdjust2 only.
After testUpdateAdjust3 execution is completed then Rollback the operations done by testUpdateAdjust3 only.
After all three functions executed then the UPDATE statement should be rollbacked.
Please help me.
Thanks in advance.
You cannot roll back some of the statements in a transaction and commit the others. It is “all or nothing”.
You can issue a second UPDATE statement that undoes the effect of the first one.
In my Event model, I have the following function to retrieve all the events with status = 1 with a 12 limit and order according to event created DESC:
public function latestEvents() {
$this->Behaviors->load('Containable');
$result = $this->find('all' ,array('recursive' => -1, 'conditions'=> array('Event.status' => 1), 'limit' => 12, 'order' => array('Event.created DESC')));
debug($result); die();
return $result;
}
This function is not returning any data. When I change my limit to 6 and debug it returns six records but when I change my limit to more than 6 it returns (empty) this :
I even checked in my database by doing this query :
SELECT * FROM `events` WHERE `status` = 1 ORDER BY `created` DESC LIMIT 12
and this returns the desired data that I want. I even tried :
$result = $this->query('SELECT * FROM `events` WHERE `status` = 1 ORDER BY `created` DESC LIMIT 12');
but the same thing is happening with the limit (6 returns the data but more than 6 does not).
I found out that the data I was trying to debug had special characters and I had to include 'encoding' => 'utf8' in my database.php and worked like a charm. This post helped me.
msa6#outlook.com
postArray ( [zip] => 81007 [st] => co [dist] => 13 [email] => msa6#outlook.com [pw] => msa12345 [sq] => hot [sa] => dog [comment] => 8/8 original )
INSERT INTO mbr (zip,st,dist,email,pw,sq,sa) VALUES (81007,co,13,msa6#outlook.com,msa12345,hot,dog)
Problem in recording your member data. Please try again later. You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '#outlook.com,msa12345,hot,dog)' at line 1
varchars or characters should be enclosed in single quotes
Example:
'msa6#outlook.com'
I'm stuck with the following problem. In my product table i've two columns
Date_start and Date_end (both of them are a DATE datatype in my table).
I want to check if the current date is between the Date_start and Date_end then the status must be 'not available', else it must have the status 'available'.
How can I fix that in Zend_Db_Expr?
I've now the following query.
$getProducts = $this->oSelect
->from(array('p'=>'producten'))
->columns(array('link' => "CONCAT('/t/', p.titel_key)"))
->joinLeft(array('c'=>'categorie'),'p.categorie_id = c.id',array('cat_titel'=>'c.titel'))
->joinLeft(array('sc'=>'subcategorie'),'p.subcategorie_id = sc.id', array('subcat_titel'=>'sc.titel'))
->where('p.online = 1');
In your columns:
->columns(array('link' => "CONCAT('/t/', p.titel_key)",
'status' => new Zend_Db_Expr("...")))
The 'CASE' should look something like this (i split it out for readability);
CASE WHEN p.Date_end < NOW() AND p.Date_start > NOW()
THEN 'not available' ELSE 'available' END
Zend_Db_Expr will take anything you give it and use it literally. Just remember that any DB specific commands might break if for some reason you switch systems.