Wednesday, December 27, 2017

ORA-29273: HTTP request failed , ORA-06512: at "SYS.UTL_HTTP", ORA-29273: HTTP request failed, ORA-24247: network access denied by access control list (ACL)

ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1525
ORA-29261: bad argument

ORA-29273: HTTP request failed
ORA-06512: at "SYS.UTL_HTTP", line 1130
ORA-24247: network access denied by access control list (ACL)

ORA-06512: at "SYS.DBMS_ISCHED", line 196
ORA-06512: at "SYS.DBMS_SCHEDULER", line 486
ORA-06512: at line 8
29273. 00000 -  "HTTP request failed"

Do this
grant execute on utl_http to username;
grant execute on utl_smtp to username;
grant execute on  utl_tcp to username;

Check ACL

SELECT host, lower_port, upper_port, acl FROM   dba_network_acls;

SELECT acl,
       principal,
       privilege,
       is_grant,
       TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date,
       TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date
FROM   dba_network_acl_privileges;

SELECT host, lower_port, upper_port, privilege, status
FROM   user_network_acl_privileges;


Create ACL

begin
   dbms_network_acl_admin.create_acl (
      acl          => 'utl_http.xml',
      description  => 'http acl',
      principal    => 'username',
      is_grant     => TRUE,
       privilege    => 'connect',
       start_date   => null,
      end_date     => null);
    commit;
  end;
  /

Add privs


 begin
     dbms_network_acl_admin.add_privilege (
       acl         => 'utl_http.xml',
      principal   => 'username',
       is_grant    => true,
      privilege   => 'connect',
      position    => null,
       start_date  => null,
       end_date    => null);

    commit;
   end;
   /
 
    begin
     dbms_network_acl_admin.add_privilege (
       acl         => 'utl_http.xml',
      principal   => 'username',
       is_grant    => true,
      privilege   => 'resolve',
      position    => null,
       start_date  => null,
       end_date    => null);

    commit;
   end;
   /
 
   IF want to delete

    begin
     dbms_network_acl_admin.delete_privilege (
      acl        => 'utl_http.xml',
      principal   => 'username',
      is_grant    => false,
      privilege   => 'connect');

    commit;
   end;
   /
 
Assign

BEGIN
 DBMS_NETWORK_ACL_ADMIN.ASSIGN_ACL (
  acl => 'utl_http.xml',
  host => '*.oraclecloud.com',
  lower_port => NULL,
  upper_port => NULL);
END;

BEGIN
 DBMS_NETWORK_ACL_ADMIN.unassign_ACL (
  acl => 'utl_http.xml',
  host => '*.oraclecloud.com',
  lower_port => 80,
  upper_port => 443);
END;


TEST
SELECT host, lower_port, upper_port, acl FROM   dba_network_acls;

SELECT acl,
       principal,
       privilege,
       is_grant,
       TO_CHAR(start_date, 'DD-MON-YYYY') AS start_date,
       TO_CHAR(end_date, 'DD-MON-YYYY') AS end_date
FROM   dba_network_acl_privileges;

SELECT host, lower_port, upper_port, privilege, status
FROM   user_network_acl_privileges;


select utl_http.request('https://oraclecloud.com') from dual;


Reference
https://oracle-base.com/articles/11g/fine-grained-access-to-network-services-11gr1
http://www.dba-oracle.com/t_11g_new_acls_plsql.htm
https://asktom.oracle.com/pls/apex/f?p=100:11:0::::P11_QUESTION_ID:9526497800346930725







How to check Oracle user privilege



SELECT * FROM USER_SYS_PRIVS;
SELECT * FROM USER_TAB_PRIVS;
SELECT * FROM USER_ROLE_PRIVS;

Tuesday, December 26, 2017

PLSQL oralce call shell script .sh issue

chown root $ORACLE_HOME/bin/extjob
chmod 4750 $ORACLE_HOME/bin/extjob

chown root $ORACLE_HOME/rdbms/admin/externaljob.ora
chmod 640 $ORACLE_HOME/rdbms/admin/externaljob.ora

chown root $ORACLE_HOME/bin/jssu
chmod 4750 $ORACLE_HOME/bin/jssu

vi $ORACLE_HOME/rdbms/admin/externaljob.ora


run_user = oracle


run_group = oinstall

PLSQL call Java ora_sqlerrm: ORA-29532: Java call terminated by uncaught Java exception: java.security.AccessControlException: the Permission


begin
dbms_java.grant_permission( 'username', 'SYS:java.io.FilePermission', '/home/abcd', 'read' );

end;

Friday, December 15, 2017

Oracle schedule job status and log

Oracle schedule job status and log


select * from ALL_SCHEDULER_JOB_RUN_DETAILS order by log_date desc;

select * from ALL_SCHEDULER_JOBS

SELECT VALUE
FROM V$PARAMETER
WHERE NAME = '';

SELECT *
FROM DBA_SCHEDULER_JOB_RUN_DETAILS where job_name=''
ORDER BY LOG_DATE DESC;



Wednesday, December 13, 2017

APEX Interactive Report Checkbox Row Selection

APEX Interactive Report Checkbox Row Selection




Back in page designer click the Employees > Attributes in the rendering tree. Set Link Column to Exclude Link Column. Set Maximum Rows Per Page to 5 to make it easier to test that selection works across pages.
Add the page item that will hold the list of selected employees. Its value will be a string of bar (|) separated EMPNO values. From the item gallery drag a hidden item to the Employees region. Notice that the hidden item is not shown. This is to be expected because hidden items don’t take up any space in the layout grid. Look in the rendering tree and you will see it there. Select it and change the name to P1_SELECTED. Then add P1_SELECTED to the Interactive Report Page Items to Submit.
Next change the Interactive Report SQL Query to include a selected column. This will be used to determine if the checkbox should be checked initially.
select EMPNO,
    case when instr(:P1_SELECTED, '|' || EMPNO || '|') > 0 then 
      'checked' 
    else 
      '' 
    end as selected,
    ENAME,
    JOB,
    MGR,
    HIREDATE,
    SAL,
    COMM,
    DEPTNO
  from EMP
Expand the Columns node in the rendering tree and select the SELECTED column. Set the Type to Hidden Column.
We will use the EMPNO column as the checkbox column. Select it in the rendering tree. For the Heading property enter:

<input type="checkbox" value="all">
Set the Column Alignment to center. For the HTML Expression property enter:

<input type="checkbox" #SELECTED# value="#FILE_ID#" name="f40" id="f40_#FILE_ID#">


Create a Page Processing process with the following settings:
  • Type: PL/SQL
  • Name: Set ADMIN_USER flag
  • Sequence: 0 (Important: Has to be before all other processes)
  • Point: On Submit – Before Computation and Validations
  • Enter PL/SQL Page Process:
    BEGIN
        -- Reset the hidden ADMIN_USER flag for all visible records to N
        -- Note: g_f04 maps to the hidden ADMIN_USER column
       
    
        -- Set the hidden ADMIN_USER flag for those records where the
        -- checkbox has been set by the user to Y
       
        FOR ii IN 1 .. APEX_Application.g_f40.COUNT
        LOOP
            APEX_Application.g_f40(ii);
        END LOOP;
    END;


more
http://hardlikesoftware.com/weblog/2015/07/24/apex-interactive-report-checkbox-row-selection/
http://www.inside-oracle-apex.com/checkboxes-in-tabular-forms-the-easy-way/

Oracle Apex Interactive Grids APEX$ROW_SELECTOR APEX$ROW_STATUS

Oracle Apex Interactive Grids APEX$ROW_SELECTOR APEX$ROW_STATUS

begin

case :APEX$ROW_STATUS   --- I insert, U update, D delete , C
    when 'U' then
         insert into debug values (1);
  end;


end;



more


https://jeffkemponoracle.com/2016/06/interactive-grid-apex-5-1-ea/

https://community.oracle.com/message/13309213#13309213

Wednesday, December 6, 2017

Oracle Apex image issue after upgraded to 5.1

Apex image issue after upgrade to 5.1

Issue: After upgraded , can not use the old path   #WORKSPACE_IMAGES#Logo.png  or #APP_IMAGES#Logo.png

We can image directly into Tomcat server ORDS
/u01/app/oracle/product/ords/conf/ords/standalone/doc_root/i


Then from Oracle express application  we can use path /i/Logo.png

Hope it help!

Truncate table of another schema user

From schema A we need to call a procedure of B to truncate table of B


create or replace PROCEDURE DO_TRUNCATE_B AS
BEGIN

execute immediate 'truncate table B';

END DO_TRUNCATE_B;
/

grant execute on DO_TRUNCATE_B to A;
/


DBMS_SCHEDULER.run_job in PLSQL



begin


DBMS_LOCK.SLEEP(1);

DBMS_SCHEDULER.run_job(job_name =>'"DBschemaname"."run_upload_batch_program"');

DBMS_LOCK.SLEEP(1);

end;

AWS how to delete VPC when it has error with Network interface , Gateway decencies

   how to delete VPC when it has error with Network interface , Gateway decencies  in AWS 1. Check if it is running on EC2 instance then Sto...