Planning a procedure

Hi guys,.

I have a procedure that retrieves data from database and send it as a table.

I'm not able to plan sound as there any name, can someone guide me how to plan the procedure below.

I'm using oracle 11g.

--

DECLARE

p_from VARCHAR2 (2000): = ' < [email protected] > ';

p_to VARCHAR2 (2000): = ' < [email protected] > ';

p_subject VARCHAR2 (2000): = 'Data Table ';

p_text_msg VARCHAR2 (2000);

p_smtp_host VARCHAR2 (2000): = 'mail.mycompany.com ';

p_smtp_port NUMBER: = 25;

p_html_msg VARCHAR2 (4000);

l_mail_conn UTL_SMTP.connection;

l_boundary VARCHAR2 (50): = '-= * #abc1234321cba #* =';

VC_TAB_DATA VARCHAR2 (4000);

VC_DYANMIC_BODY VARCHAR2 (4000);

TYPE T IS REF CURSOR;

REF_CUR T;

BEGIN

REF_CUR OPEN FOR ' WITH T (empno, dept, empname, desig) AS

(select empno, empname, dept, desig in empma where empmaid in (10540000044681,10491000035992,10631000035900,10461000067982))

Select "< tr > < td >" | EmpName | "< table > < td >" | EmpNo | "< table > < td >" | Dept | "< table > < td >" | desig | "< table > < /tr >"

of you;

LOOP

EXTRACT THE REF_CUR IN VC_TAB_DATA;

WHEN THE OUTPUT REF_CUR % NOTFOUND;

VC_DYANMIC_BODY: = VC_DYANMIC_BODY | » '|| VC_TAB_DATA | » ';

END LOOP;

CLOSE REF_CUR;

VC_DYANMIC_BODY: =' < table border = "1" width = "90%" align = "center" Summary = "output of Script" > < tr >

< scope = "col" th > < font color = "#701B7F" >

EMPLOYEE_NAME

< / make >

< /th >

< scope = "col" th >

< color = "#701B7F" >

EMPLOYEE_NO

< / make >

< /th >

< scope = "col" th >

< color = "#701B7F" >

DEPARTMENT

< / make >

< /th >

< scope = "col" th >

< color = "#701B7F" >

DESIGNATION

< / make >

< /th >

< /tr > ' | VC_DYANMIC_BODY | ' < /table > ';

DBMS_OUTPUT. PUT_LINE (VC_DYANMIC_BODY);

p_html_msg: = ' < html >

< body bgcolor = "#E0E2F8" >

< body > < br > < size = "2" face = "arial" color = "black" > Hi all, < / police > < p > < / p >

< font size = "2" face = "arial" color = "black" > data in the Table are as below: < / font >

'|| VC_DYANMIC_BODY | »

< br >

< br > < font size = "2" face = "CENTURY GOTHIC" color = "blue" > Best looks < / font > < br >

< font size = "2" = "CENTURY GOTHIC" color = "blue" police > Sagar K N < / make >

< /p >

< body / > < / html > ';

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.open_data (l_mail_conn);

UTL_SMTP.write_data (l_mail_conn, ' Date: ' |) TO_CHAR (SYSDATE, "HH24:MI:SS OF MON-DD-YYYY"). UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' from: ' | p_to |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' from: ' | p_from |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' subject: ' | p_subject |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Reply-To: ' | p_from |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, "MIME-Version: 1.0 ' |") UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Content-Type: multipart/alternative; limit = "" | ") l_boundary | '"' || UTL_TCP. CRLF. UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, '-' | l_boundary |) UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, ' Content-Type: text/html; charset = "iso-8859-1" ' |) UTL_TCP. CRLF. UTL_TCP. CRLF);

UTL_SMTP.write_data (l_mail_conn, p_text_msg);

UTL_SMTP.write_data (l_mail_conn, p_html_msg);

UTL_SMTP.write_data (l_mail_conn, UTL_TCP.crlf |) UTL_TCP. CRLF);

UTL_SMTP.close_data (l_mail_conn);

UTL_SMTP. Quit (l_mail_conn);

END;

/

Thanks in advance.

Yes GregV, the works of PL/SQL block very well, I tried to put all the code in the Task Scheduler, but it says that the code is too long.

so now, I joined with a procedure and can I use the Scheduler with the stored procedure.

Tags: Database

Similar Questions

  • plan work procedure sotre with PLS-00103

    Hi friends,

    I have create a schedule the job to run a procedure in oracle 11.1... I got an error when I run the job. It is a daily work

    SQL > start

    2 dbms_scheduler.run_job ('test', TRUE);

    3 end;

    4.

    Start

    *

    ERROR on line 1:

    ORA-06550: line 1, column 765:

    PLS-00103: encountered the symbol "TEST_PERSON" when awaits an of the

    Next:

    := . (@ %; immediate)

    The symbol ': = ' was replaced by 'TEST_PERSON' continue.

    ORA-06512: at "SYS." DBMS_ISCHED", line 185

    ORA-06512: at "SYS." DBMS_SCHEDULER", line 486

    ORA-06512: at line 2

    as labour code

    Start

    DBMS_SCHEDULER. () CREATE_JOB

    job_name = > 'test ',.

    job_type = > 'PLSQL_BLOCK ',.

    job_action = > ' start RUN TEST_PERSON(); end;',

    start_date = > TRUNC (SYSDATE) + 23/24.

    repeat_interval = > ' FREQ = daily; RANGE = 30',

    / next night at 23:00 * /.

    "Comments = > ' explicit LOCKING");

    END;

    I can successfully run RUN TEST_PERSON(); sqlplus and works well. What is wrong setting in DBMS_SCHEDULER?

    Help thanks in advance

    newdba

    EXECUTE is a SQL * Plus command. Omit of in your PL/SQL block.

    job_action => ' begin TEST_PERSON; end;',

  • Reg: Mailing 'time of procedure then run ".

    Hi all

    I created a PL/SQL procedure that will send e-mail about password expiration of oracle user details.

    Here's my script

    declare
    crlf VARCHAR2(2)  := chr(13)||chr(10);
    CURSOR c1 IS SELECT 
    e.alternate_name,e.email,e.cc,u.expiry_date, round(u.expiry_date-sysdate) as date_diff 
    FROM dba_users u, email_address e 
    WHERE u.username=e.username;
    username VARCHAR2(50); 
    email VARCHAR2(250);
    expire_date varchar2(50);
    date_diff  varchar2(50);
    sender VARCHAR2(40) := '[email protected]';  
    message VARCHAR2(200);
    final_message varchar2(1000);
    mailhost VARCHAR2(30) := 'x.x.x.x';  
    mail_conn UTL_SMTP.connection; 
    BEGIN 
    message:=' user will expire in ';  
    OPEN c1; 
    LOOP 
    FETCH c1 INTO username,email,expire_date,date_diff; 
    EXIT WHEN c1%NOTFOUND;  
       final_message := final_message || 'user: '|| username ||')' || crlf || 'Password of ' || username||message||' '||date_diff||'days'||' (Expiry Date: ' || expire_date || '): ';
    END LOOP; 
    CLOSE c1;
    mail_conn := UTL_SMTP.open_connection(mailhost, 25); 
    UTL_SMTP.helo(mail_conn, mailhost);
    UTL_SMTP.mail(mail_conn, sender); 
    UTL_SMTP.rcpt(mail_conn, email);
    UTL_SMTP.DATA(mail_conn, 'To: ' || email || crlf || 'Subject: ' || '[Test Mail]: Oracle User Password Expiry Reminder('||final_message||')';
    UTL_SMTP.quit(mail_conn);
    END;
    /
    
    
    

    I have planned the procedure above using DBMS_SCHEDULER

    Schedule: Fridays at 10:00

    When I run the above procedure, I will get an email about the oracle user password expiration information.

    But I want to add the next execution of the procedure in the same mail by querying dba_scheduler_jobs.

    I could do this using nested cursors, but I get execution instead of the next pending execution date.

    Is it possible to get the next execution date of the method, either by pulling the trigger, either within the procedure that precedes itself?

    REF-> previous discussion: https://forums.oracle.com/thread/2612449

    Hi Madhu,

    Please check DBMS_SCHEDULER. EVALUATE_CALENDAR_STRING.

    http://docs.Oracle.com/CD/E11882_01/AppDev.112/e25788/d_sched.htm#ARPLS72367

    Example link above...

    > set SERVEROUTPUT ON

    > ALTER SESSION set NLS_DATE_FORMAT = 'DD-MON-YYYY HH24:MI:SS.

    session the changed VALUE.

    > DECLARE

    start_date TIMESTAMP;

    return_date_after TIMESTAMP;

    next_run_date TIMESTAMP;

    BEGIN

    start_date: =.

    TO_TIMESTAMP_TZ (sysdate, 'DD-MON-YYYY HH24:MI:SS');

    return_date_after: = start_date;

    FOR I IN 1.5 LOOP

    DBMS_SCHEDULER. () EVALUATE_CALENDAR_STRING

    "FREQ = ALL DAYS; BYHOUR = 9; BYMINUTE = 30; BYDAY = MON, FRI, MAR, SEA, GAME '.

    start_date, return_date_after, next_run_date);

    DBMS_OUTPUT. Put_line ('next_run_date: ' | next_run_date);

    return_date_after: = next_run_date;

    END LOOP;

    END;

    anonymous block filled

    next_run_date: December 16, 13 09.30.44.000000 AM

    next_run_date: 17 December 13 09.30.44.000000 AM

    next_run_date: December 18, 13 09.30.44.000000 AM

    next_run_date: December 19, 13 09.30.44.000000 AM

    next_run_date: 20 December 13 09.30.44.000000 AM

    I hope this helps.

    VR,

    Sudhakar

  • IPS Signature updates

    My client has not installed updates signature in 2011. It is now ready to begin a planned update procedure. My question is: are the cumulative updates, i.e., by upgrading today, am I get all the latest signatures by the most recent (s615 today).

    Yes the signature updates are cumulative, but they do not depend on a minimal version of the software. If you are already running any release of E4, you can access the end of the signature update and install S615.

    -Bob

  • How to create a local directory on the client and not on the database server?

    Hello

    First of all, thank you for taking the time to solve the problem.

    I apologize if there are errors in the format used for the display of this issue.

    I have a procedure that generates data in the csv file and is loaded into a directory.

    I have a requirement to plan this procedure should be performed every week.

    I did the above two steps successfully.

    but the problem am facing is that files are downloaded in the directory location for the oracle server. but I need the files to load to my own record of operating systems.

    IE my PC is not the database server, but I thought to create a directory on the operating system of my own PC C:\ drive.

    It is a frequently executed procedure then uses dbms_scheduler.

    Can we create a directory on our own PC operating system file. I use Windows 7 OS?

    Please find details of version below.

    Oracle Database 11 g Enterprise Edition Release 11.2.0.3.0 - 64 bit Production

    PL/SQL Release 11.2.0.3.0 - Production

    CORE Production 11.2.0.3.0

    AMT for Linux: Version 11.2.0.3.0 - Production

    NLSRTL Version 11.2.0.3.0 - Production

    Your time and your help is very appreciated.

    Thank you

    SQL and PL/SQL FAQ

  • How to limit the duration of a planner might work?

    I've scheduled A procedure with an HOURLY frequency. Normally, able to be completed within 20 minutes. However, there are exceptions that he could run longer than 60 minutes. In order to minimize the impact of A run, I want to kill/stop the process when it has run more than 50 minutes. There is no guarantee to stop the process immediately and completely when using a "alter system kill session...". ». How can I make the limitation.

    Thanks in advance!


    Best wishes
    Satine

    >
    I planned A procedure with a SCHEDULE frequency
    . . .
    In order to minimize the impact of A run, I want to kill/stop the process when it has run more than 50 minutes
    >
    Make sure you think it's thru. Is the next run of one will have to renew the work done the day-to-day delivery of A? If Yes, then you are not minimizing the impact of A you are probably worse.

    When you kill A it could be a lot of work to be rolled back and it uses resources. What is A is almost over, when you kill it.

    What happens if he is really going to take 1 hour and 5 minutes to do quite. You will just keep the work to kill the man who is almost done and then the following to try for more work, which can take 1 hour and 20 minutes so you kill after 50, undo the work that he did and run it again which actually take an hour and a half.

    When does this stop? I think you need to evaluate why takes if long before you come to kill him and start again. Otherwise, you're trying to treat the symptom rather than the problem.

    I suggest that you change the procedure to make some progress, logging and you can determine what stage the treatment is in (beginning, middle, end).

    Another commonly used approach is to use a control table that keeps track of the State of your procedures. When starting A Proc, it checks the table control to see if it is already running, and if so, stops. That will keep the proc running again when it is already running.

    The Proc password control state of IDLE RACE and then COMPLETED or IDLE AGAIN. There would usually be a log table that would have the start time, end time and the State, then you can follow how behaves the proc over time. Sometimes, this table will also be the number of rows processed.

  • Easy way to schedule a task to run for a specified period?

    Is there an easy way to schedule (dbms_scheduler) a job to run for a fixed period - say half an hour--and then stop.

    Currently, I plan a procedure to do the job (a bunch of inserts or updates, for example) and the first line of this procedure assigns sysdate to a variable when it starts. As the procedure loops through his work, I compare the current sysdate with that original one and if the new sysdate > original for more than 30 minutes, I get an application error. But it's messy, and I was wondering if there was a way nicer to do?

    See if it works for you.

    JOB_OVER_MAX_DUR

  • Here's the scenario of suppression

    Hello

    I wonder to manage this scenario...

    I have a table that stores the list of all telephone numbers, the owner of the phone in my database...


    the front end application is java...

    I was told that they (the java guy) download the csv file with the list of all the phone numbers are disconnected so far here at the end of the day they should remove all these numbers of the underlying table...

    they say that every day this deletion... If it happens to java performance may not be good... That's why I access my database file and delete the data in the table

    Every day

    Asked me to write a procedure for this, and they're going to call it simply the procedure of java...


    I did not handle this type of scenario before... can any of you shed some light on this...

    None. records to be deleted every day may be around 50 k... can I write a simple delete statement to delete the 50 k records?

    How to handle this scenario

    Thanks and greetings
    REDA

    Hello

    You can get here the topics of external tables:

    [http://download.oracle.com/docs/cd/B19306_01/server.102/b14215/part_et.htm#i436567]
    [http://blog.lishman.com/2008/03/oracle-external-tables.html]
    

    And sample DBMS_SCHEDULER:

    begin
    
      dbms_scheduler.create_job('ext_table_job',
    
        job_type=>'plsql_block',
    
        job_action=>'my_proc();',
    
        enabled=>true);
    
    end;
    

    First create the external table. Load data into the external Table. write a procedure to delete records based on a SELECT statement on the outdoor tables. Plan this procedure using DBMS_SCHEDULER

    Thank you

  • PL/SQL procedure to run an ODI load plan via the web service

    Someone at - it a procedure from PL/SQL to run a load of ODI Plan using a web service?

    These discussions helped:

    Run a scenario ODI of APEX

    Problems with UTL_HTTP and problems of access to the network

  • Recently ordered (and order confirmed) "Plan of creative photography of Cloud (one year). I want to cancel it, but during the procedure, I do not even the option "Cancel". How should I proceed?

    Recently ordered (and order confirmed) "Plan of creative photography of Cloud (one year). I want to cancel it, but during the procedure, I do not even the option "Cancel". How should I proceed?

    In order to cancel the order, please contact customer service

    You can use: http://helpx.adobe.com/x-productkb/global/phone-support-orders.html

    For more information on cancellation: cancel your creative cloud membership

  • What is the correct procedure of DMBS_XPLAN for the query execution plan

    Hello.

    We are on Oracle 11.2.0.3 on Linux. I am dev. DBA and we have about 80 developers Java development team. They want to question the execution plan of queries to resolve the sqls. Generally, they use the GUI tools like the toad to see execution plan. I always use the procedure for the following query execution plan:

    
    

    Select * from
    Table (dbms_xplan.display_cursor (null, null, 'allstats + cost'));

    I should suggest that they use this too rather than rely on tools like the toad - because they can show estimated plan and not the actual plan. And to provide a sql, it is best to use the real plan to work with. Do not take account of 'allstats + cost' part in the command above, but my point is: should I ask them of still rely on sqlplus and not the GUI tools and use the command display_cursor package DBMS_XPLAN?

    I will be grateful for suggestions.

    OrauserN

    You must use the DBMS_XPLAN package and functionality.

    The tool used to run the package doesn't matter. A raw request to DISPLAY_CURSOR will run the same server code in any tool including Toad.

    If you rely on other GUI features (for example a "explain plan" button or similar) then you know what this feature of actuall application running under-the-covers.

    My suggestion would be to assess and consider using Oracle free sql developer version 4 because it is not only FREE but also uses the DBMS_XPLAN correctly.

    http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/downloads/index.html?ssSourceSiteId=ocomen

  • explain plan/autotrace, stored procedure

    Hello

    I have a stored procedure executes a select statement. I would use autotrace or explain the plan or something to check how my select statement is executed.

    So far, I have done only for use autotrace on the statements that I write in sql * more. The problem here is that my select statement using some user-defined types (lists of numbers and dates). Also if possible I would like my request to call the procedure providing the parameters. I feel kind of lost here.

    My request is something like this:

    list_of_numbers int_list;
    int_list2 list_of_numbers;
    date_list list_of_dates;

    Select * from table1, table (int_list) i1, i2 table (int_list2) table (date_list) d1 where...

    Yes, or alternatively you can use:

    dbms_session.set_sql_trace(true); -- or false to end tracing.
    

    stored inside your procedure.

  • Plan does not show the local procedures/functions

    Hello

    SQLD 4.1

    I use the preview to a plsql procedure feature. The procedure provides a local procedure.

    In the window structure the local procedure does not at all. Declared variables and cursors in the local procedure are displayed, but as if they where in the main proceedings.

    Local procedures and functions should be displayed in the window structure. It would be nice if the declares the variables and cursors of a local proceeding would be arranged in suchs a means, it is visible that they belong to this local procedure, perhaps using an indentation.

    Best regards

    Joop

    Hey, Joop!

    A mysterious person, known only as "SF" for the purpose of this response, has also reported this to me. We have filed a bug on this subject, and it shows as 'fixed' in 4.1.1.

  • Can someone please tell me the correct procedure to install Planning 9.3.1?

    There are currently essbase installed on my machine. I read on the internet that we need to install shared services in order to set up the schedule. I installed shared services but am unable to configure it with SQL server 2005. Do not in the name of user and password in the Configuration of Hyperion utility. I'm stuck right there.
    I think I messed up the installation sequence and it would take the right steps to install Planning.

    Any help would be greatly appreciated... !!!
    Thanks a & all.

    Hello

    This usually means that you have SQL server running in Windows Authentication Mode, change in mixed mode and set up a new user with the correct privileges and try again.

    See you soon

    John
    http://John-Goodwin.blogspot.com/

  • HP50g - menu soft &amp; problem of local procedures

    Pls help!

    Below is a simple program to illustrate the problem with a menu soft & updated local procedures

    (-> and <-stand for left and right arrows)

    Program works great under debugger! (displayed correctly SALDO and TRANS in response to press the soft keys)

    But started him only gives error messages: "undefined local name.

    According to the manual update of local variables (here < s and <-T) must be visible in the module of the whole program, or I don't unerstand not something?

    Of course program works very well when the overall procedures are used instead of the premises.

    Thanks in advance for your advice

    < <

    < < "SALDO" > >

    < < "TRANS" > >

    --> < s < t

    < <

    {

    {"SALDO" < < < if EVAL > >}

    {"TRANS" < < < t EVAL > >}

    } MENU

    > >

    > >

    Hello

    A local variable has 1 main feature: a scope.

    This range means that the variable only exists in this scope...

    A scope is a 'physical' and time stretch (note the quotes around physics, it's because he's not real physics, but virtual physics).

    Expand the 'physical' is the length/area of the program where there is the local variable. This extension from the definition of the local variable until the closure of the program block is more deep where the local variable is defined.

    The measurement of time is the duration of execution of the execution of this program block.

    There is a secondary feature: this is the name and it is the recognition by the system.

    RPL, as in most languages, the basic rules of the gramar program allows a local variable to have a name any. Therefore, at first inseparable from a global variable. The compiler then uses his knowledge of the field of knowledge, when you type a name, if it is to create a local or global variable.

    Until then, there is no problems in the definitions...

    Now, let's look at your program (in essence)

    < < 1 2 - > V1 V2

    < <

    {{V1 'V1'} {'V2' V2}} MENU

    > >

    > >

    When the program runs, it creates 2 MENU items, and then OUTPUTS!

    At the time where your more intimate program stops, local variables are destroyed (normal, follow the rules)...

    HOWEVER, you left a temporary structure that is available to the user (in the menu) which contains references to these variables (which no longer exists)... When you press one of these keys to menu... KaBoom...

    But what that <-syntax stuff?

    Don't forget the 'physical' extension of the scope... It's all good and all... BUT it has some issues.

    Namely, you cannot split your program into small chuncks, stored in various global variables to facilitate programming.

    In most languages, and according to the rules defined above, you may not create a subroutine, using local variables that you plan to have exist in a "time extend" which covers the delivery of the subprogramme. This is true of most programming languages. The reason why you could not create this subroutine is that the compiler would not know/believe these variables are 'in the scope' during the compilation of the program (* see tip below).

    The <-syntax allows this. It allows to force a variable to be compiled as local even outside the physical measure of the scope. But at the time of this call to the local variable, the variable MUST be defined, otherwise... KaBoom!

    This is the heart of your misunderstanding...

    To do what you want, you have 2 possibilities:

    -Use global variables

    -Put a STOP after the MENU statement (you must use TMENU BTW) and a SUITE at the end of execution of each of the menu items.

    I hope this helps!

    Cyrille

    * trick below *.

    The 50 HP has an environment / planning of circuits integrated very neat that lets you do the following to avoid having to type those pesky arrows back.

    Create your top program with your local variable definitions (not necessary of arrows). Just after the definition of the local variable, place a STOP instruction. Run the program.

    Now you can create your SUP program! When you press ENTER and the system compiles your program, these variable EXIST local (you are in their scope of TIME!) and your program will contain local variable rather than global calls!

    However, this will not solve your problem.

Maybe you are looking for