I am kind of new in DMBS_SCHEDULER and I face some problems.
I want to run an .exe
So I created a Job:
begin
sys.dbms_scheduler.create_job(job_name => 'FTREC.EXE_1',
job_type => 'EXECUTABLE',
job_action => 'C:\Windows\System32\calc.exe',
start_date => to_date(null),
repeat_interval => '',
end_date => to_date(null),
job_class => 'IRECS_JOB_CLASS',
enabled => false,
auto_drop => false,
comments => '');
end;
I have also created credentials :
DBMS_SCHEDULER.CREATE_CREDENTIAL('WWLSERVER','WWLSERVER','1234',null,null,null);
And I applied the credentials to my job
dbms_scheduler.set_attribute('FTREC.EXE_1', 'credential_name', 'WWLSERVER');
But when I try to run my Job I get this error:
EXTERNAL_LOG_ID="job_255737_183883",
ORA-27369: job of type EXECUTABLE failed with exit code: The extended attributes are inconsistent.
What I am doing wrong?
Credentials were not available in 10g. There are no mentions of the word "credential" in the
DBMS_SCHEDULER documentation.
I was able to run your code in 12c. But running calc.exe created an un-killable session, I had to restart the database. Things went much better when I used a simple .bat file for testing.
This thread on the Oracle Forums has methods for running an external program on 10g.
Related
Recently i start learning Oracle APEX and i have a question (i'm familiar with plsql):
Where is the source code for APEX located, in which schema ?
EG: For this piece of code where can i find APEX_COLLECTION.COLLECTION_EXISTS souce code :
IF :P9_HOW_MANY is NOT NULL and :P9_HOW_MANY > 0 then
IF NOT APEX_COLLECTION.COLLECTION_EXISTS (p_collection_name => 'CHILDREN') THEN
APEX_COLLECTION.CREATE_OR_TRUNCATE_COLLECTION(
p_collection_name => 'CHILDREN');
END IF;
APEX_COLLECTION.ADD_MEMBERS(
p_collection_name => 'CHILDREN',
p_c001 => apex_application.g_f01,
p_c002 => apex_application.g_f03,
p_c003 => apex_application.g_f04,
p_c004 => apex_application.g_f02
);
End IF;
Thank you.
I think i found the answer, i will leave this here in case it helps anyone:
APEX_COLLECTION
APEX_ITEM
ETC..
all are public synonyms located in SYS schema and the source code is in APEX_190200 schema on the WWV_FLOW_COLLECTION package.
I have a problem with registering BINARY XML schema using Oracle 12c version.
If I'm correct BINARY scheme registration option is available since Oracle 11g version? But using 12c it shows me an error that BINARY option is still not declared.
BEGIN
DBMS_XMLSCHEMA.REGISTERSCHEMA
(
SCHEMAURL => 'http://localhost:8080/public/leagues.xsd',
SCHEMADOC => bfilename('XMLDIR', 'LEAGUES.xsd'),
GENTYPES => FALSE,
OPTIONS => REGISTER_BINARYXML
);
END;
/
As a result of this, I receive an error :
PLS-00201: identifier 'REGISTER_BINARYXML' must be declared
Because that option (register_binaryxml) should be invoked through dbms_xmlschema package as dbms_xmlschema.register_binaryxml.
That is, replace options => register_binaryxml with options => dbms_xmlschema.register_binaryxml
I'm trying to get a file from a Windows Server to our Oracle Application Server directory named EXT_TAB_DATA.
I have followed the sample of a similar SO post (PL/SQL FTP API binary vs ascii mode), using Tim Hall's FTP Package.
Code Block
set serveroutput on
DECLARE
l_conn UTL_TCP.connection;
BEGIN
L_CONN := FTP.login (p_host => 'sample.corp.server' -- this is a sample, not the real IP address
p_user => 'corporate/user1', -- this is a sample, not the real User
p_port => '21',
p_pass => 'pwd');
ftp.binary(p_conn => l_conn);
ftp.get (p_conn => l_conn,
p_from_file => '101_Test.csv',
p_to_dir => 'EXT_TAB_DATA',
p_to_file => '101_Test_Trans.csv');
ftp.logout(l_conn);
END;
/
However, the file i'm trying to transfer is located in a subfolder named "Payroll_Folder" in "sample.corp.server.
Seems FTP.login only checks the main directory of the host, and not inside subfolders.
How can I get the the file '101_Test.csv' from the Server/Directory "sample.corp.server/Payroll_Folder"?
Change
p_from_file => '101_Test.csv'
to
p_from_file => 'Payroll_Folder/101_Test.csv'
Im not clear about this, here in DBMS_SCHEDULER we have CREATE_PROGRAM CREATE_JOB CREATE_SCHEDULE etc., after reading the oracle doc still im unclear what to use, On the Oracle side, i am going to use DBMS_SCHEDULER to insert a new message into the queue at the appropriate time, i planned to create scheduler to execute it on particular time and then create program to execute my PL/SQL block which will enqueue the message in the queue Or instead of using CREATE_SCHEDULE and CREATE_PROGRAM, CREATE_JOB does both the jobs, which to use? please guide me whether i am doing correctly, if not please correct me.
Thankyou
create_job is the basic call to schedule a call. you don't have to create a named program or schedule to do this. where creating a named program/schedule is useful, is if you have several jobs that want to use this call. you can just reference the named program schedule instead of having each job hold a copy of that.
e.g. if you had 5 jobs wanting to call your package MYPKG.ENTRY_PROG(param) and each job just used a different parameter value, i'd say you want to use create_program to define that pl/sql call and then create_job to reference that program name + set the parameter value of choice. that way, if you want to rename the API later or something, you don't have to change five seperate jobs to do this.
If your job is just a standalone job that calls a routine that won't be called by other jobs, then you don't have to use create_program/create_schedule, just use create_job directly.
one example where I used create_program was to call a test harness. my test harness package is called pkg_test_harness.queue_tests(p_set_name in varchar2) so I have a few jobs defined that enqueues various APIs to be run at 9AM, 12PM and 5PM. instead of defining each jobs call separately i just called create_program like:
dbms_output.put('Setting up TEST_HARNESS_ENQUEUE scheduler program...');
dbms_scheduler.create_program(program_name => 'TEST_HARNESS_ENQUEUE',
program_type => 'STORED_PROCEDURE',
program_action => 'pkg_test_harness.queue_tests',
number_of_arguments => 1,
enabled => false,
comments => 'Program to enqueue a set of API test for the test harness to run.');
dbms_scheduler.define_program_argument(program_name => 'TEST_HARNESS_ENQUEUE',
argument_name => 'p_set_name',
argument_position => 1,
argument_type => 'VARCHAR2',
default_value => '');
dbms_scheduler.enable (name => 'TEST_HARNESS_ENQUEUE');
dbms_output.put_line('done.');
and then each "job" was defined pointing to the program.
dbms_output.put('Setting up TEST_HARNESS_ENQUEUE_9AM scheduler job...');
dbms_scheduler.create_job(job_name => 'TEST_HARNESS_ENQUEUE_9AM',
program_name => 'TEST_HARNESS_ENQUEUE',
start_date => systimestamp,
end_date => null,
repeat_interval => 'freq=daily; byhour=9; byminute=0; bysecond=0;',
enabled => true,
auto_drop => false,
comments => 'Job to enqueue a set of API test for the test harness to run.');
dbms_scheduler.set_job_argument_value(job_name => 'TEST_HARNESS_ENQUEUE_9AM',
argument_position => 1,
argument_value => 'DAILY_9AM');
dbms_output.put_line('done.');
dbms_output.put('Setting up TEST_HARNESS_ENQUEUE_12PM scheduler job...');
dbms_scheduler.create_job(job_name => 'TEST_HARNESS_ENQUEUE_12PM',
program_name => 'TEST_HARNESS_ENQUEUE',
start_date => systimestamp,
end_date => null,
repeat_interval => 'freq=daily; byhour=12; byminute=0; bysecond=0;',
enabled => true,
auto_drop => false,
comments => 'Job to enqueue a set of API test for the test harness to run.');
i didn't create a named schedule, as these schedules are unique to the individual job.
The code is this:
Originally:(http://www.oracle-base.com/articles/misc/FTPFromPLSQL.php)
The approach uses a combination of the UTL_TCP and UTL_FILE packages to create a simple FTP API (ftp.pks, ftp.pkb). Once the API is loaded into the appropriate schema simple FTP commands can be initiated as follows:
CREATE OR REPLACE DIRECTORY my_docs AS '/u01/app/oracle/';
SET SERVEROUTPUT ON SIZE 1000000
#c:\ftp.pks
#c:\ftp.pkb
-- Send an ASCII file to a remote FTP server.
DECLARE
l_conn UTL_TCP.connection;
BEGIN
l_conn := ftp.login('ftp.company.com', '21', 'ftpuser', 'ftppassword');
ftp.ascii(p_conn => l_conn);
ftp.put(p_conn => l_conn,
p_from_dir => 'MY_DOCS',
p_from_file => 'test_get.txt',
p_to_file => '/u01/app/oracle/test_put.txt');
ftp.logout(l_conn);
END;
/
The problem is that when I try to create the directory object I get an error saying that Create symbol wasnt expected.
where this line should be created?
Is there anything preceding the create statement line in your script? It looks like there might be something you left off the post.