Posts

Showing posts with the label plsql

Extract Data Guard Commands

Image
Hi, I found a great code for extracting data guard commands (reverse engineering) I adjusted it to oracle 12.1 with far sync and it working fine. Just remember to run on Primary & Far Sync instances the following command: 1. SQL> ALTER SYSTEM SET LOG_ARCHIVE_DEST_n='' scope=both sid='*'; (where n is 2 or above) 2. DGMGRL> disable configuration; 3. DGMGRL> remove configuration; and then run the script: displayconfig.sql SET SERVEROUTPUT ON SET LINESIZE 300 SET FEEDBACK OFF DECLARE rid INTEGER; indoc VARCHAR2 ( 4000 ); outdoc VARCHAR2 ( 4000 ); p INTEGER; z XMLTYPE; y CLOB; v_xml XMLTYPE; tout VARCHAR2 ( 4000 ); db_type VARCHAR2 ( 10 ); db_headers_commands clob; db_commands clob; db_commands_RedoRoutes clob; BEGIN indoc := ' '; y := NULL; rid := dbms_drs.do_control ( indoc ); outdoc := NULL; p := 1; WHILE ( outdoc IS NULL ) LOOP outdoc := dbms_drs.get_respons...

Export in Pl/Sql via DBMS_DATAPUMP

Image
CREATE OR REPLACE PACKAGE maintenance AS    PROCEDURE export_myschema;    PROCEDURE stop_job (job_name VARCHAR2, schema_name VARCHAR2);    PROCEDURE stop_all_jobs;    PROCEDURE import_schema (file_name VARCHAR2); END maintenance; /  CREATE OR REPLACE PACKAGE BODY maintenance AS    PROCEDURE export_myschema    AS       handle        NUMBER;       file_name     VARCHAR2 (200);       log_name      VARCHAR2 (200);       JOBNAME       VARCHAR2 (200);       file_prefix   VARCHAR2 (30);       dir_name      VARCHAR2 (4000);       l_fexists BOOLEAN;   ...

Sending Mail from the database

Image
You should have an outgoing SMTP server IP to configure sending mail from the database. I already put it in the database server /etc/hosts as mailhost sqlplus / as sysdba @?/rdbms/admin/utlmail.sql @?/rdbms/admin/prvtmail.plb grant execute on UTL_MAIL to public; ALTER SYSTEM SET smtp_out_server = 'mailhost' scope=both; a simple example BEGIN UTL_MAIL.send(sender => 'Yossi@NixonIT.com', recipients => 'you@address.com', subject => 'Test Mail', message => 'Hello World', mime_type => 'text; charset=us-ascii'); END; / For further advanced options such as attachments see in this wiki