Im trying to make a REST API call from db and for that i have tried to create a ACL first.Below are the query,I tried to execute via sysdba user.Im getting error.
Can someone help me.
BEGIN
DBMS_NETWORK_ACL_ADMIN.create_acl (
acl => 'test_sx_acl_file.xml',
description => 'A test of the ACL functionality',
principal => 'node',
is_grant => TRUE,
privilege => 'connect',
start_date => SYSTIMESTAMP,
end_date => NULL);
end;
/
PL/SQL procedure successfully completed.
2)
BEGIN
DBMS_NETWORK_ACL_ADMIN.assign_acl ( acl => 'test_sx_acl_file.xml ', host => '*.testapi.com', lower_port => NULL, upper_port => NULL);
END;
/
ERROR at line 1:
ORA-46059: Invalid ACL identifier specified
ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 70
ORA-06512: at "SYS.DBMS_NETWORK_ACL_ADMIN", line 484
ORA-06512: at line 2
Why is that? what could be the reason
Related
Job fails with:
ORA-29481: Implicit results cannot be returned to client.
ORA-06512: at "SYS.DBMS_SQL", line 2832
ORA-06512: at "SYS.DBMS_SQL", line 2826
ORA-06512: at "owner.SEND_TO_S3", line 8
ORA-06512: at line 1
I can run the procedure manually(BEGIN SEND_TO_S3; END;) without errors and the db exports
show up in the s3 bucket.
****Oracle Job
BEGIN
DBMS_SCHEDULER.CREATE_JOB (
job_name => 'SEND_EXP_TO_S3_JOB',
job_type => 'PLSQL_BLOCK',
job_action => 'BEGIN SEND_TO_S3; END;',
start_date => SYSTIMESTAMP,
enabled => TRUE,
repeat_interval => 'freq=weekly; byday=mon; byhour=20; byminute=40; bysecond=0;');
END;
****Oracle procedure
(If there some other way than to use a refcursor that might solve this issue as well)
CREATE OR REPLACE PROCEDURE send_to_s3
AS
rc sys_refcursor;
BEGIN
open rc for
SELECT
rdsadmin.rdsadmin_s3_tasks.upload_to_s3(
p_bucket_name => 'bucket/name',
p_prefix => 'EXP',
p_s3_prefix => '',
p_directory_name => 'DATA_PUMP_DIR') `your text`
AS TASK_ID FROM DUAL;
DBMS_SQL.RETURN_RESULT(rc);
END send_to_s3;
****The oracle error points to an outdated client but I have the latest client and I'm
not sure the scheduler uses a client.
Is there a way to get this job running correctly?
I have an Oracle 11g stored procedure that takes a text address and returns latitude and longitude using a Google API. This procedure uses oracle's utl_http feature.
Reading the Oracle documentation on using this feature, I saw that it is necessary to create a wallet and bind a Google HTTPS URL certificate. Already did that.
I also have to create ACL resources, add privileges and assign ACL. Already did that.
But when I execute the procedure it always presents the error ORA-24247
create or replace procedure test_procedure(p_address IN VARCHAR2, p_lat out number, p_long out number) is
l_http_request UTL_HTTP.req;
...
begin
l_address := REPLACE(TRIM('TRAV. JOAQUIM A. SILVA, 286 - ALVORADA - GUANHÃES/MG CEP: 39740-000'), ' ', '+');
...
UTL_HTTP.set_wallet('file:/MY_ORACLE_HOME/admin/MY_SCHEMA/wallet', NULL);
l_request := 'https://maps.googleapis.com/maps/api/geocode/json?address=' ||
l_address || chr(38) || 'language=pt-BR'||'&key=MyGoogleKey';
l_http_request := utl_http.begin_request(l_request,'GET','HTTP/1.1'); -- this line presents ORA-24247 error
...
My ACL commands
begin
DBMS_NETWORK_ACL_ADMIN.create_acl(
acl => 'www_google.xml',
description => 'Google Maps Access',
principal => 'MY_DB_USER',
is_grant => TRUE,
privilege => 'connect',
start_date => NULL,
end_date => NULL
);
dbms_network_acl_admin.add_privilege (
acl => 'www_google.xml',
principal => 'MY_DB_USER',
is_grant => TRUE,
privilege => 'connect',
start_date => null,
end_date => null
);
dbms_network_acl_admin.add_privilege (
acl => 'www_google.xml',
principal => 'MY_DB_USER',
is_grant => TRUE,
privilege => 'resolve',
start_date => null,
end_date => null
);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
acl => 'www_google.xml',
host => '*.google.com',
lower_port => 25,
upper_port => 8080
);
end;
The problem was wrong URL in host parameter in DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL block
i have done all the activity i.e mention below, please tell which step / activity i am missing.
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
acl => 'apex_user.xml',
description => 'access to apex email',
principal => 'DBUSER',
is_grant => TRUE,
privilege => 'connect',
start_date => SYSTIMESTAMP,
end_date =>Null
);
COMMIT;
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
acl => 'apex_user.xml',
principal => 'DBUSER',
is_grant => true,
privilege => 'resolve'
);
COMMIT;
END;
BEGIN
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
acl => 'apex_user.xml',
host => 'smtp.gmail.com',
lower_port =>587,
upper_port =>587
);
COMMIT;
END;
to make sure the user can access the smtp packages, Run as SYS
GRANT EXECUTE ON UTL_TCP TO DBUSER;
GRANT EXECUTE ON UTL_SMTP TO DBUSER;
GRANT EXECUTE ON UTL_MAIL TO DBUSER;
GRANT EXECUTE ON UTL_http TO DBUSER;
Enabling UTL_MAIL
alter system set smtp_out_server = 'smtp.gmail.com:587' scope = both;
Once i execute following query in Oracle since fistname.lastname#gmail.com having less secure app as true from google account
begin
utl_mail.send(
sender => 'fistname.lastname#gmail.com',
recipients => 'fistname.lastname#gmail.com',
message => 'Hello World'
);
end;
Error report -
ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first
and give error once call from apex as
APEX_MAIL.SEND(
p_to => 'fistname.lastname#gmail.com',
p_from => 'fistname.lastname#gmail.com',
p_subj => 'APEX_MAIL with attachment',
p_body => 'Please review the attachment.',
p_body_html => '<b>Please</b> review the attachment');
ORA-24247: network access denied by access control list (ACL)
however i tried using utl_smtp and again same error
create or replace PROCEDURE send_email(p_to IN VARCHAR2,
p_from IN VARCHAR2,
p_message IN VARCHAR2,
p_smtp_host IN VARCHAR2,
p_smtp_port IN NUMBER DEFAULT 587)
AS
l_mail_conn UTL_SMTP.connection;
BEGIN
l_mail_conn := UTL_SMTP.open_connection(p_smtp_host, p_smtp_port);
UTL_SMTP.helo(l_mail_conn, p_smtp_host);
UTL_SMTP.mail(l_mail_conn, p_from);
UTL_SMTP.rcpt(l_mail_conn, p_to);
UTL_SMTP.data(l_mail_conn, p_message || UTL_TCP.crlf || UTL_TCP.crlf);
UTL_SMTP.quit(l_mail_conn);
END;
ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first. c13sm6735648wrb.38 - gsmtp
please tell which command or anything misisng..
You don't need any commit, since explicit DML operations are not performed for these operations. And using begin..end blocks not needed for every method invoking, either.
Your issue stems from the fact the neccessity of invoking Dbms_Network_Acl_Admin.Add_Privilege method with privilege => 'connect' option also. So you can use the following :
BEGIN
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
acl => 'apex_user.xml',
description => 'access to apex email',
principal => 'DBUSER',
is_grant => TRUE,
privilege => 'connect',
start_date => SYSTIMESTAMP,
end_date =>Null
);
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
acl => 'apex_user.xml',
principal => 'DBUSER',
is_grant => true,
privilege => 'connect'
);
DBMS_NETWORK_ACL_ADMIN.ADD_PRIVILEGE(
acl => 'apex_user.xml',
principal => 'DBUSER',
is_grant => true,
privilege => 'resolve'
);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
acl => 'apex_user.xml',
host => 'smtp.gmail.com',
lower_port =>587,
upper_port =>587
);
END;
With the following query all privileged accesses could be checked ( through SYS or SYSTEM schemas ):
select a.host,p.*
from dba_network_acl_privileges p
join dba_network_acls a on a.aclid = p.aclid
order by a.host, p.principal, p.privilege;
1) IMHO smtp.gmail.com requires secured connection and authentication but package utl_mail is not supporting these functions. You can achieve this with utl_smtp.
2) The Apex_mail package run with the privileges of their definer (apex_scheama) and your acl list is defined for dbuser. Also here you have somehow do the smtp authentication .
Hi I'm creating a JOB CONTROLLER to run a procedure.
JOB CONTROLLER Procedure'
CREATE OR REPLACE PROCEDURE "GCCPMAINT"."JOB_CONTROLLER" as
programTotal number;
BEGIN
dbms_scheduler.create_program (
program_name => 'PGM_CLEANSE_BRNGB',
program_type => 'STORED_PROCEDURE',
program_action => 'OPT_SALES',
number_of_arguments => 1,
enabled => FALSE);
dbms_scheduler.DEFINE_PROGRAM_ARGUMENT(
program_name=>'PGM_CLEANSE_BRNGB',
argument_name=>'card_no',
argument_position=>1,
argument_type=>'varchar2');
dbms_scheduler.enable('PGM_CLEANSE_BRNGB');
DBMS_SCHEDULER.drop_job(job_name => 'JOB_Cleanse_BRNGB', force => true);
dbms_scheduler.create_job('JOB_Cleanse_BRNGB',program_name=>'PGM_CLEANSE_BRNGB',auto_drop=> true,start_date=>SYSDATE,job_style=> 'LIGHTWEIGHT');
dbms_scheduler.set_job_argument_value(
job_name=>'JOB_Cleanse_BRNGB',
argument_name=>'card_no',---> error says here
argument_value=>'1234');
dbms_scheduler.enable('JOB_Cleanse_BRNGB');
END;
here is my program action procedure
CREATE OR REPLACE PROCEDURE "OPT_SALES"(card_no VARCHAR2)
as
BEGIN
DBMS_OUTPUT.PUT_LINE ('card-Number is'||card_no);
END;
When i try to run the job controller procedure it says error as
17:42:28 [#CALL - 0 row(s), 0.000 secs] [Error Code: 27473, SQL
State: 99999] ORA-27473: argument CARD_NO does not exist ORA-06512:
at "SYS.DBMS_ISCHED", line 244 ORA-06512: at "SYS.DBMS_SCHEDULER",
line 716 ORA-06512: at "GCCPMAINT.JOB_CONTROLLER", line 27 ORA-06512:
at line 1
I have the right argument then why it says "argument CARD_NO does not exist"
Can anybody help me please.
You can also invoke a procedure without using a program. Please take a look at this. (Also, auto_drop is true by default)
DBMS_SCHEDULER.CREATE_JOB
(
job_name => 'JOB_Cleanse_BRNGB'
,job_class => 'DEFAULT_JOB_CLASS'
,job_type => 'STORED_PROCEDURE'
,start_date => SYSDATE
,job_style => 'LIGHTWEIGHT'
,job_action => 'OPT_SALES'
,number_of_arguments => 1
);
dbms_scheduler.set_job_argument_value(
job_name=>'JOB_Cleanse_BRNGB',
argument_name=>'CARD_NO',---> error says here
argument_value=>'1234');
dbms_scheduler.enable('JOB_Cleanse_BRNGB');
I have met a problem with my database (version is Oracle 11g).
What did I want to do?
i want to use procedures to upload a file to the ftp server.
How did i do?
first , i have download the ftp.pks and ftp.pkb files and I use #**.pks to import this packages.
and then i code the procedures like this:
DECLARE
l_conn UTL_TCP.connection;
BEGIN
l_conn := ftp.login('192.168.1.102', '21', 'tony', 'tony');
ftp.ascii(p_conn => l_conn);
ftp.put(p_conn => l_conn,
p_from_dir => 'MY_DOCS',
p_from_file => 'aaa.txt',
p_to_file => 'test_put.txt');
ftp.logout(l_conn);
END;
when I run it, the console give me this error information
ORA-24247: network access rejected by ACL
ORA-06512: at "SYS.UTL_TCP", line 17
ORA-06512: at "SYS.UTL_TCP", line 246
ORA-06512: at "SCOTT.FTP", line 76
ORA-06512: at line 4
and for this reason, I created the ACL rules with the following code:
begin
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
acl => 'ftp_conn.xml',
description => 'ftp connection',
principal => 'SCOTT',
is_grant => TRUE,
privilege => 'connect');
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
acl => 'ftp_conn.xml',
host => '192.168.1.102',
lower_port => 21,
upper_port => 21);
end;
But, when I run the ftp code again, it also shows that error, so I want know how to fix this.
ACL can allow TCP connection, but when i use ftp package and call 'ftp.put', The console output is
error at 1 line:
ORA-29260: network error:not connected
ORA-06512: at "SYS.UTL_TCP", line 212
ORA-06512: at "SYS.UTL_TCP", line 432
ORA-06512: at "SCOTT.FTP", line 413
ORA-24247: Network access rejected by acl
ORA-06512: at "SCOTT.FTP", line 491
ORA-06512: at line 6
Try to add the resolve privilege (though it sounds strange...):
begin
DBMS_NETWORK_ACL_ADMIN.CREATE_ACL(
acl => 'ftp_conn.xml',
description => 'ftp connection',
principal => 'SCOTT',
is_grant => TRUE,
privilege => 'connect');
DBMS_NETWORK_ACL_ADMIN.add_privilege (
acl => 'ftp_conn.xml',
principal => 'SCOTT',
is_grant => FALSE,
privilege => 'resolve',
position => NULL,
start_date => NULL,
end_date => NULL);
DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL(
acl => 'ftp_conn.xml',
host => '192.168.1.102',
lower_port => 21,
upper_port => 21);
end;
/
COMMIT;