Help on procedures

Oracle DB10gR2
Win 2 k 3

I am creating a procedure to send a few people when 1 or more jobs. I think I'm almost there; I can't seem to be able to list all of the work that has no names.

That's what I've got so far...
create or replace
PROCEDURE emailtest AS
   v_count number;
   V_MESSAGE VARCHAR2(500);  
   CURSOR jobs IS
   select job_name from dba_scheduler_job_log where owner = 'XYZ'
    and status='FAILED' and log_date between TO_CHAR(sysdate - 1440/1440,'DD-MON-YY HH:MI:SS pm') and
    to_char(sysdate,'DD-MON-YY HH:MI:SS pm');

  BEGIN
   select count(*) into v_count
    from dba_scheduler_job_log where owner = 'XYZ'
    and status='FAILED' and log_date between TO_CHAR(sysdate - 1440/1440,'DD-MON-YY HH:MI:SS pm') and
    to_char(sysdate,'DD-MON-YY HH:MI:SS pm');
   
   if v_count > 0 then
      UTL_MAIL.SEND
      (sender=>'[email protected]',
       recipients=>'[email protected];[email protected]',
       subject=>'Oracle Jobs Failed',
      
        message => );

  end if;
   EXCEPTION
   WHEN OTHERS THEN
     dbms_output.put_line('The following error has occured: ' || sqlerrm);
     null;
   END;
In the UTL_MAIL. SEND; Message... I'm trying to get something like this in the email:

job one
job b
c job

How can I get the job_name failed on the message / content of the email?

Thank you.

If you want that the names of work on separate lines, first determine your target line break character (for example just Chr (10), or Chr (13) |) 10.
That put it in a variable (let's call it "v_nl").

Just before your UTL_MAIL. SEND line, add:

FOR r_jobs IN jobs
LOOP
    v_message := v_message || r_jobs.jobs || v_nl;
END LOOP;

v_message now contains job failed, names separated by new lines. Switch v_message as long as your message parameter.

Tags: Database

Similar Questions

  • help the procedure...

    Hello world

    I created the following procedure to create a table and insert with select data, the procedure being executed very well but when I write a query using the table "mrsa_admit_date", and then he throws me an error with "table or view does not exist.

    Lost something here?

    With the help of oracle 11g

    create or replace PROCEDURE P_MRSA_STEP3 AS

    BEGIN

    run immediately 'truncate table mrsa_admit_date;

    insert into mrsa_admit_date

    Select A.pat_id, A.pat_enc_csn_id, P.hsp_account_id, min (A.effective_time) in the Admit_date

    of clarity_adt@clarprod A

    inner join mrsa_cms_units mcu

    On mcu.dept_id = A.department_id

    Join hsp_account@clarprod P internal

    On A.pat_enc_csn_id = P.prim_enc_csn_id

    -where

    -P.hsp_account_id = 12226392031

    -In (10610792118,41567152070)

    A.pat_id, A.pat_enc_csn_id, P.hsp_account_id group

    commit;

    END P_MRSA_STEP3;

    Thank you.

    Well it is because you have no code to create a table. You have a truncation, and then an insert.

  • Help please procedure:

    declare
    cursor emp_cur is select ename,empno,sal from emp where sal>1000;
    emp_record emp_cur%rowtype;
    begin
    open emp_cur;
    loop
    fetch emp_cur into emp_record;
    dbms_output.put_line(emp_record.ename||'  '||emp_record.empno||'  '||emp_record.sal);
    exit when emp_cur%rowcount>10 or emp_cur%notfound;
    end loop;
    close emp_cur;
    commit;
    end;
    /
    
    
    
    *In a procedure i want tp pass all these (emp_record.ename||'  '||emp_record.empno||'  '||emp_record.sal) columns* 
    *i want as out parameters how can i write a procedure*

    >
    I want to pass out parameters like this... Not like a cursor variable Ref can you please help me like that
    >
    No - if you use only THE settings for column values the procedure returns only ONE set of values so it would be pointless to have a LOOP in the process.

    If you want to return a result set with more than one line, you must return a cursor or to use a function in the pipeline.

     create or replace
        package pkg2
          as
            CURSOR emp_cur is (SELECT empno, ename, job, mgr, deptno FROM emp);
            type pkg_emp_table_type is table of emp_cur%rowtype;
            function get_emp(
                             p_deptno number
                            )
              return pkg_emp_table_type
              pipelined;
      end;
      / 
    
     create or replace
        package body pkg2
          as
            function get_emp(
                             p_deptno number
                            )
              return pkg_emp_table_type
              pipelined
              is
              begin
                  for v_emp_rec in (SELECT empno, ename, job, mgr, deptno
                                    FROM emp where deptno = p_deptno) loop
                    pipe row(v_emp_rec);
                  end loop;
              end;
      end;
      / 
    
     select * from table(pkg2.get_emp(20));
    
           EMPNO ENAME      JOB              MGR     DEPTNO
      ---------- ---------- --------- ---------- ----------
            7369 DALLAS     CLERK2          7902         20
            7566 DALLAS     MANAGER         7839         20
            7788 DALLAS     ANALYST         7566         20
            7876 DALLAS     CLERK           7788         20
            7902 DALLAS     ANALYST         7566         20
    
  • Help run procedure

    OK, so embarrassing enough, I've never had to perform the procedure.

    I need perform this procedure, and I don't really know how the syntax will be.

    Code of procedure...

    PROCEDURE Rollover_Tables

    -Controls the creation of new nrn_sites, nrn_strata, nrn_use_levels records.

    - and nrn_sampleyears save for a new cycle. Return value is to be

    -"SUCCESS" or "ERROR: msg > '"

    (p_forest IN nrn_sites.aforest_code%type

    p_from_round IN nrn_sites.round%type

    p_to_round IN nrn_sites.round%type

    p_fiscal_yr_todo IN varchar2

    p_return OUT varchar2) IS

    v_return varchar2 (300);

    number of v_count;

    BEGIN

    IF p_forest is null or

    p_from_round is null or

    p_to_round is null or

    p_fiscal_yr_todo is null

    THEN

    p_return: = ' ERROR: one or more input parameters is null';

    ON THE OTHER

    -ensure that the forest is active

    Select count (1)

    in v_count

    of nrn_adminforests

    where aforest_code = p_forest

    and in_use = 'Y ';

    IF v_count = 1

    THEN

    Rollover_Sites_and_Strata (p_forest

    p_from_round

    p_to_round

    p_fiscal_yr_todo

    v_return);

    IF v_return <>'SUCCESS'

    THEN

    p_return: = v_return;

    ON THE OTHER

    Rollover_Use_Levels (p_forest

    p_from_round

    p_to_round);

    p_return: = 'SUCCESS';

    COMMIT;

    END IF;

    ON THE OTHER

    p_return: = ' ERROR: this forest is inactive, it cannot be reversed ";

    END IF;

    END IF;

    END Rollover_Tables;

    I understand that there was once a variable input... but still, I don't know how to write sql or pl/sql.

    I need:

    p_forest = A01117

    p_from_round = 3

    p_to_round = 4

    p_fiscal_year = 2013

    Thank you.

    Read the documentation. You can not survive without knowledge. You can start here http://docs.oracle.com/cd/E11882_01/appdev.112/e25519/subprograms.htm#LNPLS008

    DECLARE

    v_return varchar2;

    BEGIN

    Rollover_Tables ('A01117'

    3

    4

    2013

    v_return);

    dbms_output.put_line (v_return);

    END;

  • Procedure runs package Help

    Hello

    I need to get familiar with the procedures and packages if I put in place the code below in a procedure to run a package, when to use the DBMS_OUTPUT procedure. Put_line to display that returns the package.

    Finally the package returns lines of our ColdFusion Oracle database.

    Could someone please help me get it going, and maybe I'll see where I am in foul territory? I think I'm close or across the universe.

    Thanks in advance for your help,

    Lou

    PROCEDURE
    create or replace
    PROCEDURE test2
    is
    TYPE my_cursor is REF CURSOR;


    BEGIN
    test1_pack.test1_proc(:my_cursor);
    LOOP
    NULL;
    -DBMS_OUTPUT. Put_line(my_c.col1 || my_c.col2);
    END LOOP;

    END test2;

    PACKAGE
    create or replace
    package test1_pack as

    TYPE test1_cursor IS REF CURSOR;

    PROCEDURE test1_proc)
    p_cursor in THE test1_cursor);

    end test1_pack;


    PACKAGE BODY
    create or replace
    package body test1_pack as

    PROCEDURE test1_proc)
    p_cursor in THE test1_cursor) as
    Start
    OPEN FOR P_cursor
    SELECT * FROM
    (SELECT 'Is' today AS "COL1", TO_CHAR (SYSDATE) AS 'COL2' FROM DUAL
    UNION ALL
    SELECT 'April', ' crazy! OF THE DOUBLE
    );
    end test1_proc;

    end test1_pack;

    Hello

    Try this:

    CREATE OR REPLACE PROCEDURE test2 IS
       TYPE my_cursor IS REF CURSOR;
       v_cursor my_cursor;
       v_col1   VARCHAR2(100);
       v_col2   VARCHAR2(100);
    BEGIN
       test1_pack.test1_proc(v_cursor);
    
       LOOP
          FETCH v_cursor
             INTO v_col1, v_col2;
          EXIT WHEN v_cursor%NOTFOUND;
          DBMS_OUTPUT.PUT_LINE(v_col1 || v_col2);
       END LOOP;
    
       CLOSE v_cursor;
    END test2;
    /
    

    Kind regards

  • Call a procedure in a package

    Hello

    I need help to call a procedure within a package.

    I have an ABC package in which I have 3 X Y and Z I procedures I need to call the procedure procedure Y X that belongs to the same package.

    Thanks in advance

    I have an ABC package in which I have 3 X Y and Z I procedures I need to call the procedure procedure Y X that belongs to the same package.

    This forum, as the title suggests, is for developer Sql questions only and NOT for questions of SQL or PL/SQL.

    If this is not related to Sql Developer then please mark ANSWERED and repost it in SQL and PL/SQL forum

    https://community.Oracle.com/community/Developer/English/oracle_database/sql_and_pl_sql

    During the validation you must provide your name and full version.

    You must also explain why even need help because procedure X can call just procedure Y directly since they are in the same package.

    For an Oracle DB, see documentation and examples of ' packages of PL/SQL to help "in the doc of the PL/SQL language

    http://docs.Oracle.com/CD/B28359_01/AppDev.111/b28370/packages.htm#CIHIJECJ

  • Cursor of procedure statement package

    Hi am facing these issues, I'm too close to the problem to understand. Pl help
    procedure addRox(p_reg_type_id in  number, p_offender_id in  number,p_sentence_end_date in  date,
                                p_registration_date in  date,p_end_registration_date in  date,
                                p_aggravated in  varchar2,p_habitual in  varchar2, p_comments  in varchar2, p_status  in varchar2 DEFAULT null  , p_OFFENSE_CODE in number) is
     
     
      cursor tierNum is
        select max(c.tier) from sor_offense o, sor_offense_code c
        where o.offender_id = p_offender_id
        and o.offense_code = c.CODE_ID
        and o.state = 30658
        and upper(o.status) = 'ACTIVE';
      tier number;
      vEndRegDate registration_offender_xref.END_REGISTRATION_DATE%type default null;
     begin
         open tierNum;
         Fetch tierNum into tier;
          if tierNum%NotFound then
            tier := Null;
          end if;
        Close tierNum;
        
      
        if tier is not null then 
          if(p_sentence_end_date is null) then -- sentenceEndDate is null 
              if tier = 1 then
              vEndRegDate := add_months(p_registration_date - 1,180);
              end if;
            if tier = 2 then
              vEndRegDate := add_months(p_registration_date - 1,300);
            end if;
            if tier = 3 then
                vEndRegDate := Null;
            end if;
          else -- sentence_end_date is not null 
            if tier = 1 then 
              vEndRegDate := add_months(p_sentence_end_date - 1,180);
            end if;
            if tier = 2 then
              vEndRegDate := add_months(p_sentence_end_date - 1,300);
            end if;
            if tier = 3 then
              vEndRegDate := Null;
            end if;
            
          end if; 
        end if; 
    
     
              insert into registration_offender_xref (reg_type_id, offender_id, status,sentence_end_date,
                                registration_date,end_registration_date,aggravated,habitual,status_date, comments)
                         values (p_reg_type_id, p_offender_id, 'Active',p_sentence_end_date,
                                p_registration_date,vEndRegDate,p_aggravated,p_habitual,sysdate, p_comments);
            
            -- commit;
    
     exception
      when others then
            
            DBMS_OUTPUT.PUT_LINE('ERR in  '||sqlerrm);
           
     end addRox;
    \

    Error:error (4.12): PLS-00323: subprogram or cursor "ADD_ABC" is declared in a package specification and must be defined in the package body

    Someone advised me two or three days back, the cursor is ineffective, you should try to do stuff in sql itself. This isn't the exact solution to the question above. But works for me.
    THUS, instead of cursor selects variables in the body of proc.

    Thank you

  • Attempting to exceed some default values in the procedure

    HI gurus,

    I'm trying to set the default values, but the test in the test window, I get them as null.
    Can you please help?

    Procedure get_total_refunds (p_start_date IN default, trunc (sysdate) DATE - 1,)
    P_end_date IN trunc (sysdate)) default DATE is

    Published by: Tina on July 2, 2012 13:06

    Add DBMS_OUTPUT to your SP of debugging:

    create or replace
      procedure test_ref(
                         p_start IN date default trunc(sysdate)-1,
                         p_end   IN date default trunc(sysdate)
                        )
        is
        begin
            dbms_output.put_line('Start date is ' || to_char(p_start,'mm/dd/yyyy'));
            dbms_output.put_line('End date is ' || to_char(p_end,'mm/dd/yyyy'));
            for rec in (select * from table a where a.date_created >= p_start and a.date_created < p_end ) loop
              insert
                into table1
                values(
                       rec.column1,
                       rec.column2,
                       rec.column3
                      );
            end loop;
            -- commit; -- commit in procedure is bad design
    end test_ref;
    /
    

    Now in SQL * more the question:

    SET SERVEROUTPUT ON
    EXEC test_ref;
    

    Display the results.

    SY.

  • Paviollion HP HPE 112Y - no video SIgnal from the computer - monitor works

    I have a desktop HP Pavilion HPE 112Y.  About two weeks, the video has stopped working.  I replaced the HDMI cable, we replaced a VGA cable, etc with no luck.  I plugged in the screen of my laptop and it works fine, then it is certainly the office.  All I get is a message "No. Sigmal video»

    I tried to connect the monitor directly on the edge of VGA video connection - without going through the video card.  No luck.

    .  I can not get the system starts from the CMOS or restore screen.  Hard drive runs, but goes into the cycle of continuous type "whiring.

    System is about 2 years old, running Windows 7 64 bit.

    Help!

    Hello

    Try this procedrue:

    Disconnect the PC and open it. Clean all the dust. Carefully, remove and replace all the cables towards the mother board one at a time. Do the same for memory DIMM and the video and the sound of cards if you have a.  You can buy a can of compressed air to blow the dust out of the heatsink from the CPU.  Plug your PC back in and give it a go.

    If the above does not help this procedure: power.  Do not skip steps.

    Finally, try to clear the CMOS memory.

  • Recently I have not been able to burn a CD with Windows Media Player: I get an error message: "Windows Media Player cannot find the file."

    Hello

    I recently haven't been able to burn a CD with Windows Media Player (he worked last week, but not now). I get an error message "Windows Media Player cannot find the file. The link between the library item and its digital media file associated with may be broken. "Try to fix the link or delete the item. There is a web help option which says that to fix a link, you click on the blue icon next to the item, then click "Browse this article. But the only icon I see is a little blue triangle next to individual songs in the library pane or list, there is no icon next to the name of the playlist. Although the click with the right button on the blue triangle gives me a few options, "Browse this point" is not one of them. Does anyone have any ideas what is wrong and how can I sort it please!

    Rick

    original title: burning a CD problems

    Hello


    (1) what version of Windows Media Player do you use?
    (2) what is the model of your CD burner?
    (3) you have the latest drivers for the CD burner?
    (4) what type of file you are trying to burn?
    (5) you receive error codes?
    (6) what version of the operating system is installed on the computer?
    (7) we get to a particular file?
     

    Method 1: You can try to update the drivers of your CD burner visit the manufactures Web site.
     
    Method 2: You can try to remove the CD, and then insert another CD and try to burn another file and check if the problem persists.
    I hope this information helps!
  • Installing ram in hp Pavilion p017tu

    Hello everyone

    I have a computer hp p017tu laptop preinstalled with 4 GB of ram. I want to install more than 4 GB of ram. Could someone help with procedures to enter the slot of ram on this laptop?

    Suv96 wrote:

    Hello everyone

    I have a computer hp p017tu laptop preinstalled with 4 GB of ram. I want to install more than 4 GB of ram. Could someone help with procedures to enter the slot of ram on this laptop?

    Through this Manual by Page 3, 116, 117

    You need to mother pto major dismantling to do this, contact nearby guys tech or HP

    Concerning

    Visruth

  • "please connect to the internet and try again.

    I have Windows 7. When trying to install Lightroom 6 I just buy new, he repeats to me "please connect to internet and try again" (as it did when I tried to do the trial version) but I am connected. I checked the firewall and it seems to be fine to let the program through. Clock is set correctly. Extremely frustrated because I don't have all day to go through the pages trying to find answers and to say the least, I'm NOT well versed in computer jargon, etc.

    Hi Thomasd40544814,

    Please refer to this document: Solutions to connect, activation and errors in connection with creative cloud and Creative Suite applications

    Also try the help below procedure:

    1 - Check if you have installed browser security extensions, please disable them. (For example: AD BLOCK, Advisor to McAfee website, toolbar of internet security etc.)

    2 disable the firewall to enable the firewall on or off - Windows Windows help , see your machine

    3 turn off the firewall of the security program installed on the computer Internet.

    4 - Please check if you have adobe entries in your HOSTS file, if there are all the entries in it, which means that adobe is getting stuck on your machine.

    See SOLUTION 3 in the following document to check and fix the HOSTS file: applications of Adobe Creative Cloud reverts after 2015 updated CC test

    Let us know if that helps.

  • When I print from Adobe it only prints double-sided. How can I select disable this option on my Mac?

    When I print from Adobe it only prints double-sided.  How can I select disable this option on my Mac?

    Hi lilar68711428,

    Refer to the help below procedure: -.

    • In Acrobat or Reader, choose file > print.

    • Click on properties.

    • Click the Layout tab. This dialog box varies with the printer. It is possible that your dialog box does not match the dialogs below.

      Please search for the Page layout option & select single side printing.

      Kind regards

      Nicos

  • Replace and restore hard drive

    I have a problem with my hard drive that went wrong by HP.  They sent me a replacement of the hard disk.

    Here's my dilemma.  I'm trying to figure out how I can do a restore to get back in my last backup (I backup every night using the backup) and restore the control panel Center.  I also created my backup disks, but it was before the upgrade to Vista Ultimate (64 bit) Vista Home Premium (64-bit).  Also, I backed up my computer using the centre of restoration and backup on an external hard drive this past weekend as I knew this day was coming.

    I want to know is what should be my methodology of restoration?  Should I restore disks, then restore my computer from the centre of restoration and backup, and then restore since my last incremental backup?  I think that should more update me.  The instructions that come with the replacement hard drive are not so large.  They tell you to restore it from the backup disks, then re - install all the applications you have on your machine.  I invested some money in external hard drives and have everything saved and want to use it.

    What should be my methodology of restoration?  Help for procedures would be greatly appreciated.

    If you get a new hard drive and want to have the operating system installed on the new drive hard, why don, t you buy acronis true image, I have and it works great-

    http://www.Acronis.com/homecomputing/

  • error in fetch

    Dear Sirs
    This code return only the last record and I would like that this return code all the record in the table
    the code is

    PROCEDURE TRANS IS
    v_connect EXEC_SQL. PORT;
    sqlstr varchar2 (1000);
    nRes PLS_INTEGER;
    page_id EXEC_SQL. CURSTYPE;
    number of v_deptno;
    v_dname varchar2 (100);
    v_loc varchar2 (100);
    BEGIN

    v_connect: = EXEC_SQL. OPEN_CONNECTION (' scott/tiger @orcl ' "); - definition connection
    -Opening cursor in Oracle
    page_id: = EXEC_SQL. OPEN_CURSOR (v_connect);
    -Analysis & execution non-Oracle query in Oracle
    BEGIN
    EXEC_SQL. PARSE (v_connect, Page_id, 'select to_char (deptno), dname, loc from dept');
    END;
    nRes: = EXEC_SQL. EXECUTE (v_connect, Page_id);
    -Defining the column sequence using Variables
    EXEC_SQL. DEFINE_COLUMN (v_connect, Page_id, 1, v_deptno);
    EXEC_SQL. DEFINE_COLUMN (v_connect, Page_id, 2, v_dname, 30);
    EXEC_SQL. DEFINE_COLUMN (v_connect, Page_id, v_loc, 3, 30);
    WHILE (EXEC_SQL. FETCH_ROWS (v_connect, Page_id) > 0) LOOP
    -Retrieving values of column in the Variables

    EXEC_SQL.column_value(v_connect,curID,1,v_deptno);
    EXEC_SQL.column_value(v_connect,curID,2,v_dname);
    EXEC_SQL.column_value(v_connect,curID,3,v_loc);
    END LOOP;
    : CONTROL.deptno: = v_deptno;
    : CONTROL.dname: = v_dname;
    : CONTROL.loc: = v_loc;

    END;

    pls help
    PROCEDURE TRANS IS
    v_connect EXEC_SQL.CONNTYPE;
    sqlstr varchar2(1000);
    nRes PLS_INTEGER;
    curid EXEC_SQL.CURSTYPE;
    v_deptno number;
    v_dname varchar2(100);
    v_loc varchar2(100);
    BEGIN
    
    v_connect := EXEC_SQL.OPEN_CONNECTION('scott/tiger@orcl');--Defining Connection
    --Opening Cursor in Oracle
    curid := EXEC_SQL.OPEN_CURSOR(v_connect);
    --Parsing & Executing Non-Oracle Query in Oracle
    BEGIN
    go_block('CONTROL');
    FIRST_RECORD;
    EXEC_SQL.PARSE(v_connect, curID,'select to_char(deptno),dname,loc from dept');
    END;
    nRes := EXEC_SQL.EXECUTE(v_connect, curID);
    --Defining Column Sequence using Variables
    EXEC_SQL.DEFINE_COLUMN(v_connect, curID, 1, v_deptno);
    EXEC_SQL.DEFINE_COLUMN(v_connect, curID, 2, v_dname ,30 );
    EXEC_SQL.DEFINE_COLUMN(v_connect, curID, 3, v_loc ,30 );
    WHILE (EXEC_SQL.FETCH_ROWS(v_connect, curID)>0) LOOP
    --Fetching Column Values in Variables
    
    EXEC_SQL.column_value(v_connect,curID,1,v_deptno);
    EXEC_SQL.column_value(v_connect,curID,2,v_dname);
    EXEC_SQL.column_value(v_connect,curID,3,v_loc);
    :CONTROL.deptno:=v_deptno;
    :CONTROL.dname:=v_dname;
    :CONTROL.loc := v_loc;
    NEXT_RECORD;
    END LOOP;
    :CONTROL.deptno:=v_deptno;
    :CONTROL.dname:=v_dname;
    :CONTROL.loc := v_loc;
    NEXT_RECORD;
    
    END;
    

Maybe you are looking for

  • What are the parameters of password?

    Can what characters I use in passwords?What is the limit of characters in maxim?

  • At the opening of the YouTube full Firefox get hang and its ask a script download or stop...

    Hi team, I have download 17.0.1 latest version of FireFox for Windows 7. Opening youtube.com its ask a script stop or restart I stop script and then complete firefox gets hang. Rest of Web sites work correctly, just for youtube.com why firefox gets h

  • Impossible to debug in Simulator

    When I try to run a simple Hello world app in the Simulator, I get following error: Deployment failed: 1Error: Unable to connect: connection to https://192.168.93.130 refused. You may need to restart the target. I restarted the Simulator several time

  • BCC shows the names on my computer?

    Created an email to send bcc:, but the names appear on my message, I'm afraid to hit send unless I do not know the names won't be visible. Windows 7, Windows Live Mail.

  • How can I completely remove Trend Micro of my computer?

    I bought trend micro antvirus I removed my antvirus norton through windows programs, there was always some files on my hard drive I used norton removel tool there site web removal tool of the tells me he can't continue until I have remove norton util