Use of NOCOPY

Hi
i am using oracle 9i rel 2 on windows 2000 server
Can you explain me the use of NOCOPY mode in stored procedures
thanks in advance

See 'Passing Large Data Structures with the NOCOPY Compiler Hint' in the PL/SQL User's Guide and Reference
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96624/08_subs.htm#12813

Similar Messages

  • Using User Defined Function is SQL

    Hi
    I did the following test to see how expensive it is to use user defined functions in SQL queries, and found that it is really expensive.
    Calling SQRT in SQL costs less than calling a dummy function that just returns
    the parameter value; this has to do with context switchings, but how can we have
    a decent performance compared to Oracle provided functions?
    Any comments are welcome, specially regarding the performance of UDF in sql
    and for solutions.
    create or replace function f(i in number) return number is
    begin
      return i;
    end;
    declare
      l_start   number;
      l_elapsed number;
      n number;
    begin
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(rownum)
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('first: '||l_elapsed);
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(sqrt(rownum))
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('second: '||l_elapsed);
      select to_char(sysdate, 'sssssss')
        into l_start
        from dual;
      for i in 1 .. 20 loop
        select max(f(rownum))
          into n
          from t_tdz12_a0090;
      end loop;
      select to_char(sysdate, 'sssssss') - l_start
        into l_elapsed
        from dual;
      dbms_output.put_line('third: '||l_elapsed);
    end;
    Results:
       first: 303
       second: 1051
       third: 1515
    Kind regards
    Taoufik

    I find that inline SQL is bad for performance but
    good to simplify SQL. I keep thinking that it should
    be possible somehow to use a function to improve
    performance but have never seen that happen.inline SQL is only bad for performance if the database design (table structure, indexes etc.) is poor or the way the SQL is written is poor.
    Context switching between SQL and PL/SQL for a User defined function is definitely a way to slow down performance.
    Obviously built-in Oracle functions are going to be quicker than User-defined functions because they are written into the SQL and PL/SQL engines and are optimized for the internals of those engines.
    There are a few things you can do to improve function
    performance, shaving microseconds off execution time.
    Consider using the NOCOPY hints for your parameters
    to use pointers instead of copying values. NOCOPY
    is a hint rather than a directive so it may or may
    not work. Optimize any SQL in the called function.
    Don't do anything in loops that does not have to be
    done inside a loop.Well, yes, but it's even better to keep all processing in SQL where possible and only resort to PL/SQL when absolutely necessary.
    The on-line documentation has suggested that using a
    DETERMINISTIC function can improve performance but I
    have not been able to demonstrate this and there are
    notes in Metalink suggesting that this does not
    happen. My experience is that DETERMINISTIC
    functions always get executed. There's supposed to
    be a feature in 11g that acually caches function
    return values.Deterministic functions will work well if used in conjunction with a function based index. That can improve access times when querying data on the function results.
    You can use DBMS_PROFILER to get run-time statistics
    for each line of your function as it is executed to
    help tune it.Or code it as SQL. ;)

  • How to pass more number of parameters in procedure

    How can we send 1000 parametrs in a procedure?
    is there any other method to pass parameters without defning 1000 parametrs
    Any example really helpful

    I know it's a hint, but have you ever known it to be ignored? Can you provide a working example showing it being ignored?Well it is not hard to demonstrate it being ignored, but these restrictions, while not obvious, are relatively well documented.
    What does not appear to be documented is the behaviour when calling from 3GLs (or does this qualify as an external procedure call?) where I believe the hint is also ignored.
    http://download-uk.oracle.com/docs/cd/B19306_01/appdev.102/b14261/tuning.htm#sthref2261
    "The use of NOCOPY increases the likelihood of parameter aliasing. For more information, see "Understanding Subprogram Parameter Aliasing".
    Remember, NOCOPY is a hint, not a directive. In the following cases, the PL/SQL compiler ignores the NOCOPY hint and uses the by-value parameter-passing method; no error is generated:
    1. The actual parameter is an element of an associative array. This restriction does not apply if the parameter is an entire associative array.
    2. The actual parameter is constrained, such as by scale or NOT NULL. This restriction does not apply to size-constrained character strings. This restriction does not extend to constrained elements or attributes of composite types.
    3. The actual and formal parameters are records, one or both records were declared using %ROWTYPE or %TYPE, and constraints on corresponding fields in the records differ.
    4. The actual and formal parameters are records, the actual parameter was declared (implicitly) as the index of a cursor FOR loop, and constraints on corresponding fields in the records differ.
    5. Passing the actual parameter requires an implicit datatype conversion.
    6. The subprogram is called through a database link or as an external procedure."
    For example, consider rule #2 above and compare output of first block (with unconstrained NUMBER datatype) with second (with constrained NUMBER datatype).
    Oracle Database 10g Express Edition Release 10.2.0.1.0 - Production
    SQL> SET SERVEROUTPUT ON;
    SQL> <<anonymous_block>>
      2  DECLARE
      3     variable_name NUMBER := 0;
      4
      5     PROCEDURE procedure_name (
      6        parameter_name   IN OUT NOCOPY   NUMBER)
      7     IS
      8     BEGIN
      9        dbms_output.put_line ('#2 variable_name => ' || variable_name);
    10        parameter_name := parameter_name + 1;
    11        dbms_output.put_line ('#3 variable_name => ' || variable_name);
    12     END procedure_name;
    13  BEGIN
    14     dbms_output.put_line ('#1 variable_name => ' || variable_name);
    15     procedure_name (variable_name);
    16     dbms_output.put_line ('#4 variable_name => ' || variable_name);
    17  END anonymous_block;
    18  /
    #1 variable_name => 0
    #2 variable_name => 0
    #3 variable_name => 1
    #4 variable_name => 1
    PL/SQL procedure successfully completed.
    SQL> <<anonymous_block>>
      2  DECLARE
      3     variable_name NUMBER (10) := 0;
      4
      5     PROCEDURE procedure_name (
      6        parameter_name IN OUT NOCOPY NUMBER)
      7     IS
      8     BEGIN
      9        dbms_output.put_line ('#2 variable_name => ' || variable_name);
    10        parameter_name := parameter_name + 1;
    11        dbms_output.put_line ('#3 variable_name => ' || variable_name);
    12     END procedure_name;
    13  BEGIN
    14     dbms_output.put_line ('#1 variable_name => ' || variable_name);
    15     procedure_name (variable_name);
    16     dbms_output.put_line ('#4 variable_name => ' || variable_name);
    17  END anonymous_block;
    18  /
    #1 variable_name => 0
    #2 variable_name => 0
    #3 variable_name => 0
    #4 variable_name => 1
    PL/SQL procedure successfully completed.
    SQL>

  • Need a procedure with in, out, in out parameters - small example.

    Hi Masters,
    Need a small example with 3 parameters in a procedure. How to know call by value and call by reference with out and inout parameters.
    create or replace procedure sample(x in number, y out number, z in out number) is
    begin
         pass the x value into y and z as well. and display the 3 values.   Code requried..
    end;
    Thanks a lot in adv.
    AR

    Hi,
    874273 wrote:
    Hi Masters,
    Need a small example with 3 parameters in a procedure. How to know call by value and call by reference with out and inout parameters.
    create or replace procedure sample(x in number, y out number, z in out number) is
    begin
         pass the x value into y and z as well. and display the 3 values.   Code requried..
    end;
    Thanks a lot in adv.
    AR
    I'm not sure I understand the question.
    In PL/SQL, the way to pass the value of x to another variable v is:
    v := x;
    Here, v can be an OUT argument or an IN OUT argument.  (It can be any kind of variable except an IN argument or a CONSTANT.)
    PL/SQL doesn't really have any way to display values.  For debugging, people often use dbms_output, like this:
    dbms_output.put_line (y || ' = y inside sample procedure');
    Many front end tools (such as SQL*Plus) can display the text after PL/SQL finishes.
    By default, all arguments in PL/SQL are passed by value.  To call by reference, use the NOCOPY hint, as shown below:
    SET SERVEROUTPUT ON;
    CREATE OR REPLACE PROCEDURE sample ( x  IN              NUMBER
                                       , y  OUT             NUMBER
                                       , z  IN OUT  NOCOPY  NUMBER
    IS
    BEGIN
         y := x;
         z := x;
         dbms_output.put_line (y || ' = y inside sample procedure');
         dbms_output.put_line (z || ' = z');
    END sample;
    SHOW ERRORS

  • Call to pa_project_pub.add_task

    Dear Experts,
    I am Trying to Add Task ..That Procedure Runing Everything Fine..
    I am Trying to Assign the Attribute Value Through Add Task Program ..That Values are not Updated...
    Kindly Advice Me..
    Given Below The source Code
    Body {
    pa_project_pub.add_task (
    p_api_version_number => l_api_version_number,
    p_commit => l_commit,
    p_init_msg_list => l_init_msg_list,
    p_msg_count => l_msg_count,
    p_msg_data => l_msg_data,
    p_return_status => l_return_status,
    p_pm_product_code => l_pm_product_code,
    p_pm_project_reference => l_pm_project_reference,
    p_pa_project_id => l_pa_project_id,
    p_pm_task_reference => l_pm_task_reference,
    p_pa_task_number => l_pa_task_number,
    p_task_name => l_task_name,
    p_task_description => l_task_description,
    p_carrying_out_organization_id => l_carrying_out_organization_id,
    P_task_manager_person_id => l_task_manager_person_id,
    p_task_start_date => l_task_start_date ,--- SIXTY,
    p_attribute1 => l_attribute1,
    p_pa_project_id_out => l_pa_project_id_out,
    p_pa_project_number_out => l_pa_project_number_out,
    p_task_id => l_task_id_out);
    I am Struggle in this point - p_attribute1
    Thanks in Advance...
    Thanks and Regards,
    Kumar

    To update this thread, we found that the issue has appeared because the NOCOPY hint has been added to many parameters and we were using the same variable for p_pa_project_id and p_pa_project_id_out.
    In 11i, where the NOCOPY hint is not used, thre is no problem.
    In R12, where the NOCOPY hint is used, there is a problem due to the way the NOCOPY hint is processed. When the API is called and the same variable is used for p_pa_project_id and p_pa_project_id_out, the memory location of the variable is flushed. Since the same variable is passed, the memory location is the same. Thus, the procedure does not see the value supplied in the variable before calling the API.
    The solution for us was to use 2 different variables for the IN and OUT parameters. With this change, the value provided for p_pa_project_id is not wiped out and the task is added.
    This issue could present itself for any call to a function or procedure where the same variable is used as a parameter in the call, if the NOCOPY hint is used on one or more parameters that the variable is assigned to. This is not specific to EBSO, but applies to all Oracle PL/SQL. I was able to reproduce the situation on an earlier DB version using the NOCOPY hint

  • Values by copy vs. values by reference.....

    Hi ,
    Just a wonder ....!!!
    Since passing values as reference are considered to be quicker method than passing values as copy between the host program to procedures , i wonder why the in out/out parameters are passed as copy and not as reference.....whereas the in parameters are passed as reference , at least in Oracle 8i .....
    Thanks....
    Sim

    I think by default they passed as copiesNo , the in parameters are passed by reference... that's why if you try to pass a IN parameter as reference using the NOCOPY hint then an Oracle error is displayed....whereas the OUT / IN OUT parameters are passed by value ... and there is the capability to pass them as by reference using the NOCOPY hint....
    Greetings....
    Sim

  • Steve, please respond

    We have run dbms_profiler against xmlgen and noticed the bulk of the time is in the "return clb" statement within getxml(). I think you could improve this by making it a procedure and using the NOCOPY hint on the OUT parm.
    What performance improvements do you have planned for XSU?
    Thanks,
    Jason M Cohen

    The dbms_xmlquery package already has this enhancement. There is a procedure getXML where the user passes in the CLOB into which the XSU writes the XML doc. Please upgrade to a version 1.2.1 or later.
    PROCEDURE getXML(sqlQuery IN VARCHAR2, xDoc IN CLOB, metaType IN NUMBER := NONE);
    (note "xDoc in CLOB" will behave the same as "xDoc in/out nocopy CLOB"; in the next version we will use the later, correct, syntax)

  • Can give me examples and explantions on Using COPY and NOCOPY in pl-sql

    Can give me examples and explantions on Using COPY and NOCOPY in pl-sql

    If you use COPY then parameter is copied into procedure/function internal
    spae, so You can't modify parameter.
    If you use NOCOPY then parameter is not copied into procedure/function
    internal spae, so You can modify parameter.NOCOPY modifier serves the same purpose as "copy by value" and "copy by reference" concept (like in C++).
    Then you NOCOPY parameter you pass it's pointer in memory but not pass it's value into the stack.
    You can modify the value of this parameter in both cases. The essential difference is for NOCOPY not only the pointer copies much faster then the object itself but the semantic of exception processing is voilated because when the exception raises Oracle can't restore the initial state of parameter (because all changes where made using the memory pointer but not usual stack copie of parameter):
    SQL> create or replace package my_pkg
      2  is
      3   type t is table of number index by binary_integer;
      4   t1 t;
      5   procedure no_copy (a in out nocopy t);
      6   procedure with_copy(a in out t);
      7  end;
      8  /
    Package created.
    SQL> create or replace package body my_pkg
      2  is
      3 
      4   my_exc exception;
      5 
      6   procedure no_copy (a in out nocopy t)
      7   is
      8   begin
      9    for j in 1..10 loop
    10     a(j) := 1;
    11    end loop;
    12    raise my_exc;
    13   end;
    14 
    15   procedure with_copy (a in out t)
    16   is
    17   begin
    18    for j in 1..10 loop
    19     a(j) := 1;
    20    end loop;
    21    raise my_exc;
    22   end;
    23  
    24  end;
    25  /
    Package body created.
    SQL> declare
      2    t1 my_pkg.t;
      3  begin
      4    dbms_output.put_line('Count before ' || t1.count);
      5    begin
      6      my_pkg.no_copy(t1);
      7    exception
      8      when others then
      9        null;
    10    end;
    11    dbms_output.put_line('Count after ' || t1.count);
    12  end;
    13  /
    Count before 0
    Count after 10
    PL/SQL procedure successfully completed.
    SQL> declare
      2    t1 my_pkg.t;
      3  begin
      4    dbms_output.put_line('Count before ' || t1.count);
      5    begin
      6      my_pkg.with_copy(t1);
      7    exception
      8      when others then
      9        null;
    10    end;
    11    dbms_output.put_line('Count after ' || t1.count);
    12  end;
    13  /
    Count before 0
    Count after 0
    PL/SQL procedure successfully completed.Rgds.

  • When to use NOCOPY

    The NOCOPY hint seems very useful. But when to use it?
    As I see it you could use it all the time, but am I missing something? When should I use it and when should I not user it?

    if you ever coded in 3gl (i.e. Cobol, Fortran, etc.) you will recall that you can pass values to called programs as either pass by reference or pass by value. NOCOPY is pass by reference. PLSQL defauled some calls to pass by value which in certain cases had huge costs (specifically passing large arrays). Just remember the difference between pass by value and pass by reference and use NOCOPY when you want pass by reference for sure. This is all documented in the oracle documentation set.

  • HOW TO SEND A HEBREW EMAIL WITH ATTACHMENT USING DEMO_MAIL

    Hello All,
    This is Not a question , just attaching something I've implemented and might be interesting for few of us,
    This package I'm attaching allows to send Hebrew Language email + attaching files to it.
    This package is based on demo_mail package (combined here but you can search at google for more example information if needed).
    My Package is supplied as is , for any specific information regarding it , please contact me directly at : [email protected] or POST here.
    * Please also note , that this package allow file to be attach via URL (meaning you will have to define a link to this file, if you would like to implement a link to a local file , e.g : c:\temp\myfile , you will have to customize the package your self with database directories option etc ...)
    First I will attach an example of how to use it :
    ==================================
    begin
    demo_mail_heb.send_html_mail_attach(p_sender => '[email protected]',
    p_recipients => '[email protected]',
    p_subject => 'שלום וברכה עולם',
    p_data => '<hr><b>בוקר טוב</b><hr>',
    p_file_name => 'but_choose_file.gif',
    p_file_mime_type => 'application/pdf',
    p_file_URL => 'http://10.172.246.160:7777/i/but_choose_file.gif');
    end;
    Second Here is the Package (please note you will have to modify few settings in order to enable it , such as mail server address ..etc)
    ======================================================================================
    CREATE OR REPLACE PACKAGE demo_mail_heb IS
    ----------------------- Customizable Section -----------------------
    -- Customize the SMTP host, port and your domain name below.
    smtp_host VARCHAR2(256) := 'mail.oracle.com';
    smtp_port PLS_INTEGER := 25;
    smtp_domain VARCHAR2(256) := 'oracle.com';
    -- Customize the signature that will appear in the email's MIME header.
    -- Useful for versioning.
    MAILER_ID CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
    --------------------- End Customizable Section ---------------------
    -- A unique string that demarcates boundaries of parts in a multi-part email
    -- The string should not appear inside the body of any part of the email.
    -- Customize this if needed or generate this randomly dynamically.
    BOUNDARY CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
    FIRST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
    LAST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
    utl_tcp.CRLF;
    -- A MIME type that denotes multi-part email (MIME) messages.
    MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
    BOUNDARY || '"';
    MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER := 76 / 4 * 3;
    -- Sent clear Html Email
    procedure send_html_mail (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default null,
    p_mime_type in varchar2 default 'text/html; charset=windows-1255');
    -- Sent Html Email with Attachment
    procedure send_html_mail_attach (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
    p_mime_type in varchar2 default demo_mail_heb.MULTIPART_MIME_TYPE,
    p_file_name in varchar2 default 'but_choose_file.gif',
    p_file_mime_type in varchar2 default 'application/pdf',
    p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif');
    -- A simple email API for sending email in plain text in a single call.
    -- The format of an email address is one of these:
    -- someone@some-domain
    -- "Someone at some domain" <someone@some-domain>
    -- Someone at some domain <someone@some-domain>
    -- The recipients is a list of email addresses separated by
    -- either a "," or a ";"
    PROCEDURE mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              message IN VARCHAR2);
    -- Extended email API to send email in HTML or plain text with no size limit.
    -- First, begin the email by begin_mail(). Then, call write_text() repeatedly
    -- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
    -- email in non-ASCII or multi-byte character set. End the email with
    -- end_mail().
    FUNCTION begin_mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
              priority IN PLS_INTEGER DEFAULT NULL)
              RETURN utl_smtp.connection;
    -- Write email body in ASCII
    PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
              message IN VARCHAR2);
    -- Write email body in non-ASCII (including multi-byte). The email body
    -- will be sent in the database character set.
    PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
                   message IN VARCHAR2);
    -- Write email body in binary
    PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
              message IN RAW);
    -- APIs to send email with attachments. Attachments are sent by sending
    -- emails in "multipart/mixed" MIME format. Specify that MIME format when
    -- beginning an email with begin_mail().
    -- Send a single text attachment.
    PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN VARCHAR2,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
              last IN BOOLEAN DEFAULT FALSE);
    -- Send a binary attachment. The attachment will be encoded in Base-64
    -- encoding format.
    PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN RAW,
                   mime_type IN VARCHAR2 DEFAULT 'application/octet',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   last IN BOOLEAN DEFAULT FALSE);
    -- Send an attachment with no size limit. First, begin the attachment
    -- with begin_attachment(). Then, call write_text repeatedly to send
    -- the attachment piece-by-piece. If the attachment is text-based but
    -- in non-ASCII or multi-byte character set, use write_mb_text() instead.
    -- To send binary attachment, the binary content should first be
    -- encoded in Base-64 encoding format using the demo package for 8i,
    -- or the native one in 9i. End the attachment with end_attachment.
    PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   transfer_enc IN VARCHAR2 DEFAULT NULL);
    -- End the attachment.
    PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE);
    -- End the email.
    PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
    -- Extended email API to send multiple emails in a session for better
    -- performance. First, begin an email session with begin_session.
    -- Then, begin each email with a session by calling begin_mail_in_session
    -- instead of begin_mail. End the email with end_mail_in_session instead
    -- of end_mail. End the email session by end_session.
    FUNCTION begin_session RETURN utl_smtp.connection;
    -- Begin an email in a session.
    PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
                        sender IN VARCHAR2,
                        recipients IN VARCHAR2,
                        subject IN VARCHAR2,
    --                     mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
                        priority IN PLS_INTEGER DEFAULT NULL);
    -- End an email in a session.
    PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
    -- End an email session.
    PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
    END;
    CREATE OR REPLACE PACKAGE BODY demo_mail_heb IS
    -- Sent clear Html Email
    procedure send_html_mail (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default null,
    p_mime_type in varchar2 default 'text/html; charset=windows-1255')
    Is
    conn utl_smtp.connection;
    BEGIN
    conn := demo_mail_heb.begin_mail(
    sender => p_sender,
    recipients => p_recipients,
    subject => p_subject,
    mime_type => p_mime_type);
    demo_mail_heb.write_text(
    conn => conn,
    message => p_data);
    demo_mail_heb.end_mail( conn => conn );
    END;
    -- Sent Html Email with Attachment
    procedure send_html_mail_attach (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
    p_mime_type in varchar2 default demo_mail_heb.MULTIPART_MIME_TYPE,
    p_file_name in varchar2 default 'but_choose_file.gif',
    p_file_mime_type in varchar2 default 'application/pdf',
    p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif')
    is
    conn utl_smtp.connection;
    req utl_http.req;
    resp utl_http.resp;
    data RAW(200);
    begin
    conn := demo_mail_heb.begin_mail(
    sender => p_sender,
    recipients => p_recipients,
    subject => p_subject,
    mime_type => p_mime_type);
    demo_mail_heb.attach_text(
    conn => conn,
    data => p_data,
    mime_type => 'text/html');
    demo_mail_heb.begin_attachment(
    conn => conn,
    mime_type => p_file_mime_type,
    inline => TRUE,
    filename => p_file_name,
    transfer_enc => 'base64');
    -- In writing Base-64 encoded text following the MIME format below,
    -- the MIME format requires that a long piece of data must be splitted
    -- into multiple lines and each line of encoded data cannot exceed
    -- 80 characters, including the new-line characters. Also, when
    -- splitting the original data into pieces, the length of each chunk
    -- of data before encoding must be a multiple of 3, except for the
    -- last chunk. The constant demo_mail_heb.MAX_BASE64_LINE_WIDTH
    -- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
    -- of data before encoding.
    Utl_Http.set_proxy('www-proxy.us.oracle.com', 'oracle.com');
    req := utl_http.begin_request(p_file_URL);
    resp := utl_http.get_response(req);
    BEGIN
    LOOP
    utl_http.read_raw(resp, data, demo_mail_heb.MAX_BASE64_LINE_WIDTH);
    demo_mail_heb.write_raw(
    conn => conn,
    message => utl_encode.base64_encode(data));
    END LOOP;
    EXCEPTION
    WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    END;
    demo_mail_heb.end_attachment( conn => conn );
    demo_mail_heb.end_mail( conn => conn );
    end;
    -- Return the next email address in the list of email addresses, separated
    -- by either a "," or a ";". The format of mailbox may be in one of these:
    -- someone@some-domain
    -- "Someone at some domain" <someone@some-domain>
    -- Someone at some domain <someone@some-domain>
    FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
    addr VARCHAR2(256);
    i pls_integer;
    FUNCTION lookup_unquoted_char(str IN VARCHAR2,
                        chrs IN VARCHAR2) RETURN pls_integer AS
    c VARCHAR2(5);
    i pls_integer;
    len pls_integer;
    inside_quote BOOLEAN;
    BEGIN
    inside_quote := false;
    i := 1;
    len := length(str);
    WHILE (i <= len) LOOP
         c := substr(str, i, 1);
         IF (inside_quote) THEN
         IF (c = '"') THEN
         inside_quote := false;
         ELSIF (c = '\') THEN
         i := i + 1; -- Skip the quote character
         END IF;
         GOTO next_char;
         END IF;
         IF (c = '"') THEN
         inside_quote := true;
         GOTO next_char;
         END IF;
         IF (instr(chrs, c) >= 1) THEN
         RETURN i;
         END IF;
         <<next_char>>
         i := i + 1;
    END LOOP;
    RETURN 0;
    END;
    BEGIN
    addr_list := ltrim(addr_list);
    i := lookup_unquoted_char(addr_list, ',;');
    IF (i >= 1) THEN
    addr := substr(addr_list, 1, i - 1);
    addr_list := substr(addr_list, i + 1);
    ELSE
    addr := addr_list;
    addr_list := '';
    END IF;
    i := lookup_unquoted_char(addr, '<');
    IF (i >= 1) THEN
    addr := substr(addr, i + 1);
    i := instr(addr, '>');
    IF (i >= 1) THEN
         addr := substr(addr, 1, i - 1);
    END IF;
    END IF;
    RETURN addr;
    END;
    -- Write a MIME header
    PROCEDURE write_mime_header(conn IN OUT NOCOPY utl_smtp.connection,
                   name IN VARCHAR2,
                   value IN VARCHAR2) IS
    BEGIN
    -- utl_smtp.write_data(conn, name || ': ' || value || utl_tcp.CRLF);
    utl_smtp.write_raw_data(conn, UTL_RAW.CAST_TO_RAW(name || ': ' ||value || utl_tcp.CRLF));
    END;
    -- Mark a message-part boundary. Set <last> to TRUE for the last boundary.
    PROCEDURE write_boundary(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE) AS
    BEGIN
    IF (last) THEN
    utl_smtp.write_data(conn, LAST_BOUNDARY);
    ELSE
    utl_smtp.write_data(conn, FIRST_BOUNDARY);
    END IF;
    END;
    PROCEDURE mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              message IN VARCHAR2) IS
    conn utl_smtp.connection;
    BEGIN
    conn := begin_mail(sender, recipients, subject);
    write_text(conn, message);
    end_mail(conn);
    END;
    FUNCTION begin_mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
              priority IN PLS_INTEGER DEFAULT NULL)
              RETURN utl_smtp.connection IS
    conn utl_smtp.connection;
    BEGIN
    conn := begin_session;
    begin_mail_in_session(conn, sender, recipients, subject, mime_type,
    priority);
    RETURN conn;
    END;
    PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
              message IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(CONVERT(message,'IW8ISO8859P8')));
    END;
    PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
                   message IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
    END;
    PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
              message IN RAW) IS
    BEGIN
    utl_smtp.write_raw_data(conn, message);
    END;
    PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN VARCHAR2,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
              last IN BOOLEAN DEFAULT FALSE) IS
    BEGIN
    begin_attachment(conn, mime_type, inline, filename);
    write_text(conn, data);
    end_attachment(conn, last);
    END;
    PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN RAW,
                   mime_type IN VARCHAR2 DEFAULT 'application/octet',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   last IN BOOLEAN DEFAULT FALSE) IS
    i PLS_INTEGER;
    len PLS_INTEGER;
    BEGIN
    begin_attachment(conn, mime_type, inline, filename, 'base64');
    -- Split the Base64-encoded attachment into multiple lines
    i := 1;
    len := utl_raw.length(data);
    WHILE (i < len) LOOP
    IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
         utl_smtp.write_raw_data(conn,
         utl_encode.base64_encode(utl_raw.substr(data, i,
         MAX_BASE64_LINE_WIDTH)));
    ELSE
         utl_smtp.write_raw_data(conn,
         utl_encode.base64_encode(utl_raw.substr(data, i)));
    END IF;
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    i := i + MAX_BASE64_LINE_WIDTH;
    END LOOP;
    end_attachment(conn, last);
    END;
    PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   transfer_enc IN VARCHAR2 DEFAULT NULL) IS
    BEGIN
    write_boundary(conn);
    write_mime_header(conn, 'Content-Type', mime_type);
    IF (filename IS NOT NULL) THEN
    IF (inline) THEN
         write_mime_header(conn, 'Content-Disposition',
         'inline; filename="'||filename||'"');
    ELSE
         write_mime_header(conn, 'Content-Disposition',
         'attachment; filename="'||filename||'"');
    END IF;
    END IF;
    IF (transfer_enc IS NOT NULL) THEN
    write_mime_header(conn, 'Content-Transfer-Encoding', transfer_enc);
    END IF;
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    END;
    PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE) IS
    BEGIN
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    IF (last) THEN
    write_boundary(conn, last);
    END IF;
    END;
    PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    end_mail_in_session(conn);
    end_session(conn);
    END;
    FUNCTION begin_session RETURN utl_smtp.connection IS
    conn utl_smtp.connection;
    BEGIN
    -- open SMTP connection
    conn := utl_smtp.open_connection(smtp_host, smtp_port);
    utl_smtp.helo(conn, smtp_domain);
    RETURN conn;
    END;
    PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
                        sender IN VARCHAR2,
                        recipients IN VARCHAR2,
                        subject IN VARCHAR2,
                        mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   --     mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
                        priority IN PLS_INTEGER DEFAULT NULL) IS
    my_recipients VARCHAR2(32767) := recipients;
    my_sender VARCHAR2(32767) := sender;
    BEGIN
    -- Specify sender's address (our server allows bogus address
    -- as long as it is a full email address ([email protected]).
    utl_smtp.mail(conn, get_address(my_sender));
    -- Specify recipient(s) of the email.
    WHILE (my_recipients IS NOT NULL) LOOP
    utl_smtp.rcpt(conn, get_address(my_recipients));
    END LOOP;
    -- Start body of email
    utl_smtp.open_data(conn);
    -- Set "From" MIME header
    write_mime_header(conn, 'From', sender);
    -- Set "To" MIME header
    write_mime_header(conn, 'To', recipients);
    -- Set "Subject" MIME header
    write_mime_header(conn, 'Subject', subject);
    -- Set "Content-Type" MIME header
    write_mime_header(conn, 'Content-Type', mime_type);
    -- Set "X-Mailer" MIME header
    write_mime_header(conn, 'X-Mailer', MAILER_ID);
    -- Set priority:
    -- High Normal Low
    -- 1 2 3 4 5
    IF (priority IS NOT NULL) THEN
    write_mime_header(conn, 'X-Priority', priority);
    END IF;
    -- Send an empty line to denotes end of MIME headers and
    -- beginning of message body.
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    IF (mime_type LIKE 'multipart/mixed%') THEN
    write_text(conn, 'This is a multi-part message in MIME format.' ||
         utl_tcp.crlf);
    END IF;
    END;
    PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    utl_smtp.close_data(conn);
    END;
    PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    utl_smtp.quit(conn);
    END;
    END;

    Hello All,
    Small modification - use this package and not the above
    HERE IS A WORKING CODE FOR SENDING HEBREW MESSAGES (INCLUDING SUBJECT IN UTF-8 APPEAR IN ALL EMAIL CLIENTS I HAVE CHECKED) + ATTACHMENTS
    Code attached below is supplied as is with no support. anyhow if help is needed , please contact me via [email protected]
    ============================================================================
    CREATE OR REPLACE PACKAGE demo_mail_heb IS
    ----------------------- Customizable Section -----------------------
    -- Customize the SMTP host, port and your domain name below.
    smtp_host VARCHAR2(256) := pst_ajax.getParameter('EMAIL_SMTP_HOST');
    smtp_port PLS_INTEGER := pst_ajax.getParameter('EMAIL_SMTP_PORT');
    smtp_domain VARCHAR2(256) := pst_ajax.getParameter('EMAIL_SMTP_DOMAIN');
    -- Customize the signature that will appear in the email's MIME header.
    -- Useful for versioning.
    MAILER_ID CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
    --------------------- End Customizable Section ---------------------
    -- A unique string that demarcates boundaries of parts in a multi-part email
    -- The string should not appear inside the body of any part of the email.
    -- Customize this if needed or generate this randomly dynamically.
    BOUNDARY CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
    FIRST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
    LAST_BOUNDARY CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
    utl_tcp.CRLF;
    -- A MIME type that denotes multi-part email (MIME) messages.
    MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
    BOUNDARY || '"';
    MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER := 76 / 4 * 3;
    -- Sent clear Html Email
    procedure send_html_mail (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default null,
    p_mime_type in varchar2 default 'text/html; charset=windows-1255');
    -- Sent Html Email with Attachment
    procedure send_html_mail_attach (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
    p_mime_type in varchar2 default 'text/html; charset=windows-1255',
    p_file_name in varchar2 default 'but_choose_file.gif',
    p_file_mime_type in varchar2 default 'application/pdf',
    p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif');
    -- A simple email API for sending email in plain text in a single call.
    -- The format of an email address is one of these:
    -- someone@some-domain
    -- "Someone at some domain" <someone@some-domain>
    -- Someone at some domain <someone@some-domain>
    -- The recipients is a list of email addresses separated by
    -- either a "," or a ";"
    PROCEDURE mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              message IN VARCHAR2);
    -- Extended email API to send email in HTML or plain text with no size limit.
    -- First, begin the email by begin_mail(). Then, call write_text() repeatedly
    -- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
    -- email in non-ASCII or multi-byte character set. End the email with
    -- end_mail().
    FUNCTION begin_mail(sender IN VARCHAR2,
              recipients IN VARCHAR2,
              subject IN VARCHAR2,
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
              priority IN PLS_INTEGER DEFAULT NULL)
              RETURN utl_smtp.connection;
    -- Write email body in ASCII
    PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
              message IN VARCHAR2);
    -- Write email body in non-ASCII (including multi-byte). The email body
    -- will be sent in the database character set.
    PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
                   message IN VARCHAR2);
    -- Write email body in binary
    PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
              message IN RAW);
    -- APIs to send email with attachments. Attachments are sent by sending
    -- emails in "multipart/mixed" MIME format. Specify that MIME format when
    -- beginning an email with begin_mail().
    -- Send a single text attachment.
    PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN VARCHAR2,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
              last IN BOOLEAN DEFAULT FALSE);
    -- Send a binary attachment. The attachment will be encoded in Base-64
    -- encoding format.
    PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
                   data IN RAW,
                   mime_type IN VARCHAR2 DEFAULT 'application/octet',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   last IN BOOLEAN DEFAULT FALSE);
    -- Send an attachment with no size limit. First, begin the attachment
    -- with begin_attachment(). Then, call write_text repeatedly to send
    -- the attachment piece-by-piece. If the attachment is text-based but
    -- in non-ASCII or multi-byte character set, use write_mb_text() instead.
    -- To send binary attachment, the binary content should first be
    -- encoded in Base-64 encoding format using the demo package for 8i,
    -- or the native one in 9i. End the attachment with end_attachment.
    PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   mime_type IN VARCHAR2 DEFAULT 'text/plain',
                   inline IN BOOLEAN DEFAULT TRUE,
                   filename IN VARCHAR2 DEFAULT NULL,
                   transfer_enc IN VARCHAR2 DEFAULT NULL);
    -- End the attachment.
    PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE);
    -- End the email.
    PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
    -- Extended email API to send multiple emails in a session for better
    -- performance. First, begin an email session with begin_session.
    -- Then, begin each email with a session by calling begin_mail_in_session
    -- instead of begin_mail. End the email with end_mail_in_session instead
    -- of end_mail. End the email session by end_session.
    FUNCTION begin_session RETURN utl_smtp.connection;
    -- Handling the Email Subject Line
    function mimeheader_encode(
    p_str varchar2
    , p_charset varchar2 := 'UTF-8') return varchar2;
    -- Begin an email in a session.
    PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
                        sender IN VARCHAR2,
                        recipients IN VARCHAR2,
                        subject IN VARCHAR2,
    --                     mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
              mime_type IN VARCHAR2 DEFAULT 'text/plain',
                        priority IN PLS_INTEGER DEFAULT NULL);
    -- End an email in a session.
    PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
    -- End an email session.
    PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
    END;
    CREATE OR REPLACE PACKAGE BODY demo_mail_heb IS
    -- Sent clear Html Email
    procedure send_html_mail (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default null,
    p_mime_type in varchar2 default 'text/html; charset=windows-1255')
    Is
    conn utl_smtp.connection;
    BEGIN
    conn := demo_mail_heb.begin_mail(
    sender => p_sender,
    recipients => p_recipients,
    subject => p_subject,
    mime_type => 'text/html; charset=UTF-8');--p_mime_type);
    demo_mail_heb.write_text(
    conn => conn,
    message => p_data);
    demo_mail_heb.end_mail( conn => conn );
    END;
    -- Sent Html Email with Attachment
    procedure send_html_mail_attach (p_sender in varchar2 default null,
    p_recipients in varchar2 default null,
    p_subject in varchar2 default null,
    p_data in varchar2 default '<b>áå÷ø èåá òåìí - áãé÷ä</b',
    p_mime_type in varchar2 default 'text/html; charset=windows-1255',
    p_file_name in varchar2 default 'but_choose_file.gif',
    p_file_mime_type in varchar2 default 'application/pdf',
    p_file_URL in varchar2 default 'http://10.172.246.160:7777/i/but_choose_file.gif')
    is
    conn utl_smtp.connection;
    req utl_http.req;
    resp utl_http.resp;
    data RAW(200);
    v_mime_type varchar2(32767):=demo_mail.MULTIPART_MIME_TYPE;
    begin
    conn := demo_mail_heb.begin_mail(
    sender => p_sender,
    recipients => p_recipients,
    subject => p_subject,
    mime_type => v_mime_type);
    demo_mail_heb.attach_text(
    conn => conn,
    data => p_data,
    mime_type => 'text/html');
    demo_mail_heb.begin_attachment(
    conn => conn,
    mime_type => p_file_mime_type,
    inline => TRUE,
    filename => p_file_name,
    transfer_enc => 'base64');
    -- In writing Base-64 encoded text following the MIME format below,
    -- the MIME format requires that a long piece of data must be splitted
    -- into multiple lines and each line of encoded data cannot exceed
    -- 80 characters, including the new-line characters. Also, when
    -- splitting the original data into pieces, the length of each chunk
    -- of data before encoding must be a multiple of 3, except for the
    -- last chunk. The constant demo_mail_heb.MAX_BASE64_LINE_WIDTH
    -- (76 / 4 * 3 = 57) is the maximum length (in bytes) of each chunk
    -- of data before encoding.
    req := utl_http.begin_request(p_file_URL);
    resp := utl_http.get_response(req);
    BEGIN
    LOOP
    utl_http.read_raw(resp, data, demo_mail_heb.MAX_BASE64_LINE_WIDTH);
    demo_mail_heb.write_raw(
    conn => conn,
    message => utl_encode.base64_encode(data));
    END LOOP;
    EXCEPTION
    WHEN utl_http.end_of_body THEN
    utl_http.end_response(resp);
    END;
    demo_mail_heb.end_attachment( conn => conn );
    demo_mail_heb.end_mail( conn => conn );
    end;
    -- Return the next email address in the list of email addresses, separated
    -- by either a "," or a ";". The format of mailbox may be in one of these:
    -- someone@some-domain
    -- "Someone at some domain" <someone@some-domain>
    -- Someone at some domain <someone@some-domain>
    FUNCTION get_address(addr_list IN OUT VARCHAR2) RETURN VARCHAR2 IS
    addr VARCHAR2(256);
    i pls_integer;
    FUNCTION lookup_unquoted_char(str IN VARCHAR2,
    chrs IN VARCHAR2) RETURN pls_integer AS
    c VARCHAR2(5);
    i pls_integer;
    len pls_integer;
    inside_quote BOOLEAN;
    BEGIN
    inside_quote := false;
    i := 1;
    len := length(str);
    WHILE (i <= len) LOOP
    c := substr(str, i, 1);
    IF (inside_quote) THEN
    IF (c = '"') THEN
    inside_quote := false;
    ELSIF (c = '\') THEN
    i := i + 1; -- Skip the quote character
    END IF;
    GOTO next_char;
    END IF;
    IF (c = '"') THEN
    inside_quote := true;
    GOTO next_char;
    END IF;
    IF (instr(chrs, c) >= 1) THEN
    RETURN i;
    END IF;
    <<next_char>>
    i := i + 1;
    END LOOP;
    RETURN 0;
    END;
    BEGIN
    addr_list := ltrim(addr_list);
    i := lookup_unquoted_char(addr_list, ',;');
    IF (i >= 1) THEN
    addr := substr(addr_list, 1, i - 1);
    addr_list := substr(addr_list, i + 1);
    ELSE
    addr := addr_list;
    addr_list := '';
    END IF;
    i := lookup_unquoted_char(addr, '<');
    IF (i >= 1) THEN
    addr := substr(addr, i + 1);
    i := instr(addr, '>');
    IF (i >= 1) THEN
    addr := substr(addr, 1, i - 1);
    END IF;
    END IF;
    RETURN addr;
    END;
    -- Write a MIME header
    PROCEDURE write_mime_header(conn IN OUT NOCOPY utl_smtp.connection,
    name IN VARCHAR2,
    value IN VARCHAR2) IS
    BEGIN
    -- utl_smtp.write_data(conn, name || ': ' || value || utl_tcp.CRLF);
    utl_smtp.write_raw_data(conn, UTL_RAW.CAST_TO_RAW(name || ': ' ||value || utl_tcp.CRLF));
    END;
    -- Mark a message-part boundary. Set <last> to TRUE for the last boundary.
    PROCEDURE write_boundary(conn IN OUT NOCOPY utl_smtp.connection,
    last IN BOOLEAN DEFAULT FALSE) AS
    BEGIN
    IF (last) THEN
    utl_smtp.write_data(conn, LAST_BOUNDARY);
    ELSE
    utl_smtp.write_data(conn, FIRST_BOUNDARY);
    END IF;
    END;
    PROCEDURE mail(sender IN VARCHAR2,
    recipients IN VARCHAR2,
    subject IN VARCHAR2,
    message IN VARCHAR2) IS
    conn utl_smtp.connection;
    BEGIN
    conn := begin_mail(sender, recipients, subject);
    write_text(conn, message);
    end_mail(conn);
    END;
    FUNCTION begin_mail(sender IN VARCHAR2,
    recipients IN VARCHAR2,
    subject IN VARCHAR2,
    mime_type IN VARCHAR2 DEFAULT 'text/plain',
    priority IN PLS_INTEGER DEFAULT NULL)
    RETURN utl_smtp.connection IS
    conn utl_smtp.connection;
    BEGIN
    conn := begin_session;
    begin_mail_in_session(conn, sender, recipients, subject, mime_type,
    priority);
    RETURN conn;
    END;
    PROCEDURE write_text(conn IN OUT NOCOPY utl_smtp.connection,
    message IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(CONVERT(message,'IW8ISO8859P8')));
    -- utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
    END;
    PROCEDURE write_mb_text(conn IN OUT NOCOPY utl_smtp.connection,
    message IN VARCHAR2) IS
    BEGIN
    utl_smtp.write_raw_data(conn, utl_raw.cast_to_raw(message));
    END;
    PROCEDURE write_raw(conn IN OUT NOCOPY utl_smtp.connection,
    message IN RAW) IS
    BEGIN
    utl_smtp.write_raw_data(conn, message);
    END;
    PROCEDURE attach_text(conn IN OUT NOCOPY utl_smtp.connection,
    data IN VARCHAR2,
    mime_type IN VARCHAR2 DEFAULT 'text/plain',
    inline IN BOOLEAN DEFAULT TRUE,
    filename IN VARCHAR2 DEFAULT NULL,
    last IN BOOLEAN DEFAULT FALSE) IS
    BEGIN
    begin_attachment(conn, mime_type, inline, filename);
    write_text(conn, data);
    end_attachment(conn, last);
    END;
    PROCEDURE attach_base64(conn IN OUT NOCOPY utl_smtp.connection,
    data IN RAW,
    mime_type IN VARCHAR2 DEFAULT 'application/octet',
    inline IN BOOLEAN DEFAULT TRUE,
    filename IN VARCHAR2 DEFAULT NULL,
    last IN BOOLEAN DEFAULT FALSE) IS
    i PLS_INTEGER;
    len PLS_INTEGER;
    BEGIN
    begin_attachment(conn, mime_type, inline, filename, 'base64');
    -- Split the Base64-encoded attachment into multiple lines
    i := 1;
    len := utl_raw.length(data);
    WHILE (i < len) LOOP
    IF (i + MAX_BASE64_LINE_WIDTH < len) THEN
    utl_smtp.write_raw_data(conn,
    utl_encode.base64_encode(utl_raw.substr(data, i,
    MAX_BASE64_LINE_WIDTH)));
    ELSE
    utl_smtp.write_raw_data(conn,
    utl_encode.base64_encode(utl_raw.substr(data, i)));
    END IF;
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    i := i + MAX_BASE64_LINE_WIDTH;
    END LOOP;
    end_attachment(conn, last);
    END;
    PROCEDURE begin_attachment(conn IN OUT NOCOPY utl_smtp.connection,
    mime_type IN VARCHAR2 DEFAULT 'text/plain',
    inline IN BOOLEAN DEFAULT TRUE,
    filename IN VARCHAR2 DEFAULT NULL,
    transfer_enc IN VARCHAR2 DEFAULT NULL) IS
    BEGIN
    write_boundary(conn);
    write_mime_header(conn, 'Content-Type', mime_type);
    IF (filename IS NOT NULL) THEN
    IF (inline) THEN
    write_mime_header(conn, 'Content-Disposition',
    'inline; filename="'||filename||'"');
    ELSE
    write_mime_header(conn, 'Content-Disposition',
    'attachment; filename="'||filename||'"');
    END IF;
    END IF;
    IF (transfer_enc IS NOT NULL) THEN
    write_mime_header(conn, 'Content-Transfer-Encoding', transfer_enc);
    END IF;
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    END;
    PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
    last IN BOOLEAN DEFAULT FALSE) IS
    BEGIN
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    IF (last) THEN
    write_boundary(conn, last);
    END IF;
    END;
    PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    end_mail_in_session(conn);
    end_session(conn);
    END;
    FUNCTION begin_session RETURN utl_smtp.connection IS
    conn utl_smtp.connection;
    BEGIN
    -- open SMTP connection
    conn := utl_smtp.open_connection(smtp_host, smtp_port);
    utl_smtp.helo(conn, smtp_domain);
    RETURN conn;
    END;
    -- Handling the Email Subject Line
    function mimeheader_encode(
    p_str varchar2
    , p_charset varchar2 := 'UTF-8') return varchar2 is
    l_str varchar2(2000);
    begin
    l_str:=utl_raw.cast_to_varchar2(utl_encode.quoted_printable_encode(utl_raw.cast_to_raw(p_str)));
    l_str:=replace(l_str,'='||chr(13)||chr(10),''); --unfold the data
    l_str:=replace(l_str,'?','=3f'); --quote question marks
    l_str:=replace(l_str,' ','=20'); --quote spaces
    l_str:='=?'||p_charset||'?Q?'||l_str||'?='; -- add prefix and suffix
    return l_str;
    end;
    PROCEDURE begin_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection,
    sender IN VARCHAR2,
    recipients IN VARCHAR2,
    subject IN VARCHAR2,
    mime_type IN VARCHAR2 DEFAULT 'text/plain',
    -- mime_type IN VARCHAR2 DEFAULT 'text/plain; charset=windows-1255',
    priority IN PLS_INTEGER DEFAULT NULL) IS
    my_recipients VARCHAR2(32767) := recipients;
    my_sender VARCHAR2(32767) := sender;
    BEGIN
    -- Specify sender's address (our server allows bogus address
    -- as long as it is a full email address ([email protected]).
    utl_smtp.mail(conn, get_address(my_sender));
    -- Specify recipient(s) of the email.
    WHILE (my_recipients IS NOT NULL) LOOP
    utl_smtp.rcpt(conn, get_address(my_recipients));
    END LOOP;
    -- Start body of email
    utl_smtp.open_data(conn);
    -- Set "From" MIME header
    write_mime_header(conn, 'From', sender);
    -- Set "To" MIME header
    write_mime_header(conn, 'To', recipients);
    -- Set "Content-Type" MIME header
    write_mime_header(conn, 'Content-Type', mime_type);
    -- write_mime_header(conn, 'Content-Type', 'text/html; charset=UTF-8');
    -- Set "Subject" MIME header
    -- write_mime_header(conn, 'Subject', subject);
    -- write_mime_header(conn, 'Subject', CONVERT(subject,'IW8ISO8859P8'));
    write_mime_header(conn, 'Subject',mimeheader_encode(p_str => subject,p_charset => 'UTF-8'));
    -- write_mime_header(conn, 'Subject',CONVERT(subject,'IW8MSWIN1255'));
    -- Set "X-Mailer" MIME header
    write_mime_header(conn, 'X-Mailer', MAILER_ID);
    -- Set priority:
    -- High Normal Low
    -- 1 2 3 4 5
    IF (priority IS NOT NULL) THEN
    write_mime_header(conn, 'X-Priority', priority);
    END IF;
    -- Send an empty line to denotes end of MIME headers and
    -- beginning of message body.
    utl_smtp.write_data(conn, utl_tcp.CRLF);
    IF (mime_type LIKE 'multipart/mixed%') THEN
    write_text(conn, 'This is a multi-part message in MIME format.' ||
    utl_tcp.crlf);
    END IF;
    END;
    PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    utl_smtp.close_data(conn);
    END;
    PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection) IS
    BEGIN
    utl_smtp.quit(conn);
    END;
    END;

  • Urgent help needed for XML Tags using XMLForest()

    Folks
    I need some urgent help regarding getting use defined tag in your
    XML output.
    For this I am using XMLElement and XMLForest which seems to work fine
    when used at the SQL prompt but when used in a procedure throws and error
    SQL> Select SYS_XMLAGG(XMLElement("SDI",
                                       XMLForest(sdi_num)))
         From sdi
         where sdi_num = 22261;- WORKS FINE
    But when used in a procedure,doesnt seem to work
    Declare
        queryCtx  DBMS_XMLQuery.ctxType;
        v_xml     VARCHAR2(32767);
        v_xmlClob CLOB;
        BEGIN
        v_xml:='Select SYS_XMLAGG(XMLElement("SDI",
                                             XMLFOREST(sdi_num)))
        From sdi
        where sdi_num = 22261';
        queryCtx :=DBMS_XMLQuery.newContext(v_xml);
        v_xmlClob :=DBMS_XMLQuery.getXML(queryCtx);
        display_xml(v_xmlClob);
    End;
    CREATE OR REPLACE PROCEDURE  display_xml(result IN OUT NOCOPY CLOB)
    AS
         xmlstr varchar2(32767);
         line varchar2(2000);
    BEGIN
         xmlstr:=dbms_lob.SUBSTR(result,32767);
         LOOP
         EXIT WHEN xmlstr is null;
         line :=substr(xmlstr,1,instr(xmlstr,chr(10))-1);
         dbms_output.put_line('.'||line);
         xmlstr := substr(xmlstr,instr(xmlstr,chr(10))+1);
         END LOOP;
    end;
    SQL> /
    .<?xml version = '1.0'?>
    .<ERROR>oracle.xml.sql.OracleXMLSQLException: Character ')' is not allowed in an
    XML tag name.</ERROR>
    PL/SQL procedure successfully completed.
    SQL>HELP is appreciated as to where I am going wrong?

    Hi,
    if you want to transform something to something else, you should declare, what is your source.
    I would prefer to use plain XSL-Transformations, because you have a lot more options to transform your source and you can even better determine, how your output should looks like.
    Kind regards,
    Hendrik

  • Sending email using UTL_SMTP

    Dear experts,
    I am trying to send an email using UTL_SMTP (i switched from UTL_MAIL to UTL_SMTP since i need to send mails with large attachments - BLOB). I am using the demo_mail package given here:
    http://www.oracle.com/technology/sample_code/tech/pl_sql/htdocs/Utl_Smtp_Sample.html
    While running the program I am getting an error message (from the error.log) saying:
    [Mon Aug 04 14:00:21 2008] [error] [client 192.168.0.7] mod_plsql: /ns/email_p.send HTTP-404 ORA-29279: SMTP permanent error: 530 5.7.0 Must issue a STARTTLS command first. 9sm12723808qbw.6\nORA-06512: at "SYS.UTL_SMTP", line 20\nORA-06512: at "SYS.UTL_SMTP", line 98\nORA-06512: at "SYS.UTL_SMTP", line 221\nORA-06512: at "NEXTSTEP.SEND_EMAIL_HELPER", line 258\nORA-06512: at "NEXTSTEP.SEND_EMAIL_HELPER", line 119\nORA-06512: at "NEXTSTEP.EMAIL_P", line 33\nORA-06512: at line 31\n, referer: file:///C:/Documents and Settings/Mayank/My Documents/Flex Builder 3/ns5/bin-debug/main.swf
    My code is as follows:
    PACKAGE DECLARATION. This is the DEMO_MAIL package posted under above link (I have renamed it).
    CREATE OR REPLACE PACKAGE NEXTSTEP.send_email_helper IS
      ----------------------- Customizable Section -----------------------
      -- Customize the SMTP host, port and your domain name below.
        smtp_host   VARCHAR2(256) := 'smtp.gmail.com';
        smtp_port   PLS_INTEGER   := 587;
        smtp_domain VARCHAR2(256) := null;
      -- Customize the signature that will appear in the email's MIME header.
      -- Useful for versioning.
      MAILER_ID   CONSTANT VARCHAR2(256) := 'Mailer by Oracle UTL_SMTP';
      --------------------- End Customizable Section ---------------------
      -- A unique string that demarcates boundaries of parts in a multi-part email
      -- The string should not appear inside the body of any part of the email.
      -- Customize this if needed or generate this randomly dynamically.
      BOUNDARY        CONSTANT VARCHAR2(256) := '-----7D81B75CCC90D2974F7A1CBD';
      FIRST_BOUNDARY  CONSTANT VARCHAR2(256) := '--' || BOUNDARY || utl_tcp.CRLF;
      LAST_BOUNDARY   CONSTANT VARCHAR2(256) := '--' || BOUNDARY || '--' ||
                                                  utl_tcp.CRLF;
      -- A MIME type that denotes multi-part email (MIME) messages.
      MULTIPART_MIME_TYPE CONSTANT VARCHAR2(256) := 'multipart/mixed; boundary="'||
                                                      BOUNDARY || '"';
      MAX_BASE64_LINE_WIDTH CONSTANT PLS_INTEGER   := 76 / 4 * 3;
      -- A simple email API for sending email in plain text in a single call.
      -- The format of an email address is one of these:
      --   someone@some-domain
      --   "Someone at some domain" <someone@some-domain>
      --   Someone at some domain <someone@some-domain>
      -- The recipients is a list of email addresses  separated by
      -- either a "," or a ";"
      PROCEDURE mail(sender     IN VARCHAR2,
             recipients IN VARCHAR2,
             subject    IN VARCHAR2,
             message    IN VARCHAR2);
      -- Extended email API to send email in HTML or plain text with no size limit.
      -- First, begin the email by begin_mail(). Then, call write_text() repeatedly
      -- to send email in ASCII piece-by-piece. Or, call write_mb_text() to send
      -- email in non-ASCII or multi-byte character set. End the email with
      -- end_mail().
      FUNCTION begin_mail(sender     IN VARCHAR2,
                  recipients IN VARCHAR2,
                  subject    IN VARCHAR2,
                  mime_type  IN VARCHAR2    DEFAULT 'text/plain',
                  priority   IN PLS_INTEGER DEFAULT NULL)
                  RETURN utl_smtp.connection;
      -- Write email body in ASCII
      PROCEDURE write_text(conn    IN OUT NOCOPY utl_smtp.connection,
                   message IN VARCHAR2);
      -- Write email body in non-ASCII (including multi-byte). The email body
      -- will be sent in the database character set.
      PROCEDURE write_mb_text(conn    IN OUT NOCOPY utl_smtp.connection,
                  message IN            VARCHAR2);
      -- Write email body in binary
      PROCEDURE write_raw(conn    IN OUT NOCOPY utl_smtp.connection,
                  message IN RAW);
      -- APIs to send email with attachments. Attachments are sent by sending
      -- emails in "multipart/mixed" MIME format. Specify that MIME format when
      -- beginning an email with begin_mail().
      -- Send a single text attachment.
      PROCEDURE attach_text(conn         IN OUT NOCOPY utl_smtp.connection,
                data         IN VARCHAR2,
                mime_type    IN VARCHAR2 DEFAULT 'text/plain',
                inline       IN BOOLEAN  DEFAULT TRUE,
                filename     IN VARCHAR2 DEFAULT NULL,
                    last         IN BOOLEAN  DEFAULT FALSE);
      -- Send a binary attachment. The attachment will be encoded in Base-64
      -- encoding format.
      PROCEDURE attach_base64(conn         IN OUT NOCOPY utl_smtp.connection,
                  data         IN RAW,
                  mime_type    IN VARCHAR2 DEFAULT 'application/octet',
                  inline       IN BOOLEAN  DEFAULT TRUE,
                  filename     IN VARCHAR2 DEFAULT NULL,
                  last         IN BOOLEAN  DEFAULT FALSE);
      -- Send an attachment with no size limit. First, begin the attachment
      -- with begin_attachment(). Then, call write_text repeatedly to send
      -- the attachment piece-by-piece. If the attachment is text-based but
      -- in non-ASCII or multi-byte character set, use write_mb_text() instead.
      -- To send binary attachment, the binary content should first be
      -- encoded in Base-64 encoding format using the demo package for 8i,
      -- or the native one in 9i. End the attachment with end_attachment.
      PROCEDURE begin_attachment(conn         IN OUT NOCOPY utl_smtp.connection,
                     mime_type    IN VARCHAR2 DEFAULT 'text/plain',
                     inline       IN BOOLEAN  DEFAULT TRUE,
                     filename     IN VARCHAR2 DEFAULT NULL,
                     transfer_enc IN VARCHAR2 DEFAULT NULL);
      -- End the attachment.
      PROCEDURE end_attachment(conn IN OUT NOCOPY utl_smtp.connection,
                   last IN BOOLEAN DEFAULT FALSE);
      -- End the email.
      PROCEDURE end_mail(conn IN OUT NOCOPY utl_smtp.connection);
      -- Extended email API to send multiple emails in a session for better
      -- performance. First, begin an email session with begin_session.
      -- Then, begin each email with a session by calling begin_mail_in_session
      -- instead of begin_mail. End the email with end_mail_in_session instead
      -- of end_mail. End the email session by end_session.
      FUNCTION begin_session RETURN utl_smtp.connection;
      -- Begin an email in a session.
      PROCEDURE begin_mail_in_session(conn       IN OUT NOCOPY utl_smtp.connection,
                      sender     IN VARCHAR2,
                      recipients IN VARCHAR2,
                      subject    IN VARCHAR2,
                      mime_type  IN VARCHAR2  DEFAULT 'text/plain',
                      priority   IN PLS_INTEGER DEFAULT NULL);
      -- End an email in a session.
      PROCEDURE end_mail_in_session(conn IN OUT NOCOPY utl_smtp.connection);
      -- End an email session.
      PROCEDURE end_session(conn IN OUT NOCOPY utl_smtp.connection);
    END;How should I solve the above error? Can anyone help me with my query please?
    If I add the code to start TLS it still gives me an error. If I add the code
    utl_smtp.command(conn,'STARTTLS');
    utl_smtp.helo(conn, smtp_domain);
    under email_sender_help package just before under begin_session function, it gives me an error saying:
    ORA-29279: SMTP permanent error: 503 5.5.1 EHLO/HELO first. s27sm2097329qbs.12
    So then if i enter the same code after:
    utl_smtp.command(conn,'STARTTLS');
    utl_smtp.helo(conn, smtp_domain);
    It gives me an error:
    ORA-29278: SMTP transient error: 421 Service not available
    Message was edited by:
    Monk
    Message was edited by:
    Monk

    look like rely turned off on the server..
    check this.. or ask your network guys..
    Go to Control Panel->Add or Remove Programs->Click on
    Add/Remove Wndows Components
    Check IIS check box.
    Select Internet Information Service (IIS) option and click on Details button
    Check whether SMTP Service is checked or not.
    If not selected then select SMTP check box.
    This process should be done on server.
    It will help out from ORA-29278: SMTP transient error: 421 Service not available problem.
    thanks

  • Create sales order using  IBE_Quote_W1_PVT.SUBMITQUOTEWRAPPER

    Hi,
    I am trying to create an sales order using following api. which creates cart from shopping cart.
    SET serveroutput ON
    DECLARE
    P_API_VERSION_NUMBER NUMBER;
    P_INIT_MSG_LIST VARCHAR2(200);
    P_COMMIT VARCHAR2(200);
    X_RETURN_STATUS VARCHAR2(200);
    X_MSG_COUNT NUMBER;
    X_MSG_DATA VARCHAR2(200);
    P_QUOTE_HEADERID NUMBER;
    P_LAST_UPDATE_DATE DATE;
    P_SHAREE_NUMBER NUMBER;
    P_SHAREE_PARTY_ID NUMBER;
    P_SHAREE_ACCOUNT_ID NUMBER;
    P_SC_BOOK_FLAG VARCHAR2(200);
    P_SC_RESERVE_FLAG VARCHAR2(200);
    P_SC_CALCULATE_PRICE VARCHAR2(200);
    P_SC_SERVER_ID NUMBER;
    P_SC_CC_BY_FAX VARCHAR2(200);
    P_CUSTOMER_COMMENTS VARCHAR2(200);
    P_REASON_CODE VARCHAR2(200);
    P_SALESREP_EMAIL_ID VARCHAR2(200);
    P_MINISITE_ID NUMBER;
    X_LAST_UPDATE_DATE DATE;
    X_ORDER_NUMBER NUMBER;
    X_ORDER_HEADER_ID NUMBER;
    X_ORDER_REQUEST_ID NUMBER;
    X_CONTRACT_ID NUMBER;
    X_STATUS VARCHAR2(200);
    X_HOLD_FLAG VARCHAR2(200);
    BEGIN
    P_API_VERSION_NUMBER := 1;
    P_INIT_MSG_LIST := FND_API.G_TRUE;
    P_COMMIT := FND_API.G_FALSE;
    P_QUOTE_HEADERID := 18534;
    P_LAST_UPDATE_DATE := to_date('2012-10-01 04:33:45','YYYY-MM-DD HH24:MI:SS');
    P_SHAREE_NUMBER := FND_API.G_MISS_NUM ;
    P_SHAREE_PARTY_ID := FND_API.G_MISS_NUM ;
    P_SHAREE_ACCOUNT_ID := FND_API.G_MISS_NUM ;
    P_SC_BOOK_FLAG := FND_API.G_MISS_CHAR;
    P_SC_RESERVE_FLAG := FND_API.G_FALSE;
    P_SC_CALCULATE_PRICE := FND_API.G_FALSE;
    P_SC_SERVER_ID := -1;
    P_SC_CC_BY_FAX := FND_API.G_FALSE;
    P_CUSTOMER_COMMENTS := FND_API.G_MISS_CHAR;
    P_REASON_CODE := FND_API.G_MISS_CHAR;
    P_SALESREP_EMAIL_ID := FND_API.G_MISS_CHAR;
    P_MINISITE_ID := 10660;
    IBE_Quote_W1_PVT.SUBMITQUOTEWRAPPER(
    P_API_VERSION_NUMBER => P_API_VERSION_NUMBER,
    P_INIT_MSG_LIST => P_INIT_MSG_LIST,
    P_COMMIT => P_COMMIT,
    X_RETURN_STATUS => X_RETURN_STATUS,
    X_MSG_COUNT => X_MSG_COUNT,
    X_MSG_DATA => X_MSG_DATA,
    P_QUOTE_HEADERID => P_QUOTE_HEADERID,
    P_LAST_UPDATE_DATE => P_LAST_UPDATE_DATE,
    P_SHAREE_NUMBER => P_SHAREE_NUMBER,
    P_SHAREE_PARTY_ID => P_SHAREE_PARTY_ID,
    P_SHAREE_ACCOUNT_ID => P_SHAREE_ACCOUNT_ID,
    P_SC_BOOK_FLAG => P_SC_BOOK_FLAG,
    P_SC_RESERVE_FLAG => P_SC_RESERVE_FLAG,
    P_SC_CALCULATE_PRICE => P_SC_CALCULATE_PRICE,
    P_SC_SERVER_ID => P_SC_SERVER_ID,
    P_SC_CC_BY_FAX => P_SC_CC_BY_FAX,
    P_CUSTOMER_COMMENTS => P_CUSTOMER_COMMENTS,
    P_REASON_CODE => P_REASON_CODE,
    P_SALESREP_EMAIL_ID => P_SALESREP_EMAIL_ID,
    P_MINISITE_ID => P_MINISITE_ID,
    X_LAST_UPDATE_DATE => X_LAST_UPDATE_DATE,
    X_ORDER_NUMBER => X_ORDER_NUMBER,
    X_ORDER_HEADER_ID => X_ORDER_HEADER_ID,
    X_ORDER_REQUEST_ID => X_ORDER_REQUEST_ID,
    X_CONTRACT_ID => X_CONTRACT_ID,
    X_STATUS => X_STATUS,
    X_HOLD_FLAG => X_HOLD_FLAG
    DBMS_OUTPUT.PUT_LINE('X_RETURN_STATUS = ' || X_RETURN_STATUS);
    DBMS_OUTPUT.PUT_LINE('X_MSG_COUNT = ' || X_MSG_COUNT);
    DBMS_OUTPUT.PUT_LINE('X_MSG_DATA = ' || X_MSG_DATA);
    DBMS_OUTPUT.PUT_LINE('X_LAST_UPDATE_DATE = ' || X_LAST_UPDATE_DATE);
    DBMS_OUTPUT.PUT_LINE('X_ORDER_NUMBER = ' || X_ORDER_NUMBER);
    DBMS_OUTPUT.PUT_LINE('X_ORDER_HEADER_ID = ' || X_ORDER_HEADER_ID);
    DBMS_OUTPUT.PUT_LINE('X_ORDER_REQUEST_ID = ' || X_ORDER_REQUEST_ID);
    DBMS_OUTPUT.PUT_LINE('X_CONTRACT_ID = ' || X_CONTRACT_ID);
    DBMS_OUTPUT.PUT_LINE('X_STATUS = ' || X_STATUS);
    DBMS_OUTPUT.PUT_LINE('X_HOLD_FLAG = ' || X_HOLD_FLAG);
    END;
    When i use this from a OA_HTML jsp the sales order is created . But when i use it from the sql developer
    i got following error
    X_RETURN_STATUS = E
    X_MSG_COUNT = 1
    X_MSG_DATA = You do not have access to this cart.
    X_LAST_UPDATE_DATE =
    X_ORDER_NUMBER = 9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125
    X_ORDER_HEADER_ID = 9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125
    X_ORDER_REQUEST_ID = 9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125
    X_CONTRACT_ID = 9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125
    X_STATUS =
    I checked logs for both .
    For working one log is ie. using jsp
    01-OCT-2012:01:24:46 IBE IBE_UTIL.enable_debug_new p_check_profile is N
    01-OCT-2012:01:24:46 IBE IBE_UTIL.enable_debug_new p_check_profile is N
    01-OCT-2012:01:24:46 IBE Begin validate_user_update10/01/2012:01:24:46
    01-OCT-2012:01:24:46 IBE Incoming party_id is 423832
    01-OCT-2012:01:24:46 IBE Incoming cust_account_id is 140757
    01-OCT-2012:01:24:46 IBE Incoming quote_header_id is 18529
    01-OCT-2012:01:24:46 IBE User id obtained from environment is: -1
    01-OCT-2012:01:24:46 IBE p_save_type is :6
    01-OCT-2012:01:24:46 IBE Entered Validation...T
    01-OCT-2012:01:24:46 IBE no sharee number
    01-OCT-2012:01:24:46 IBE quote_source_code of cart passed in=IStore Account
    01-OCT-2012:01:24:46 IBE In validating Owner flow: 423832,140757 10/01/2012:01:24:46
    01-OCT-2012:01:24:46 IBE Validate_user_update: Before Last update date validation,p_last_update_date= 01-10-12
    01-OCT-2012:01:24:46 IBE Validate_user_update: Last update date validation START
    01-OCT-2012:01:24:46 IBE Validate_user_update: l_last_update_date=
    01-OCT-2012:01:24:46 IBE Validate_user_update: p_last_update_date=10/01/2012:00:22:07
    01-OCT-2012:01:24:46 IBE Validate_user_update: Last update date validation END
    01-OCT-2012:01:24:46 IBE Before calling validate_quote10/01/2012:01:24:46
    01-OCT-2012:01:24:46 IBE Begin Validate_quote10/01/2012:01:24:46
    01-OCT-2012:01:24:46 IBE Validate_quote: Validation for one-click start
    01-OCT-2012:01:24:46 IBE End validate_quote10/01/2012:01:24:46
    01-OCT-2012:01:24:46 IBE End validate_user_update10/01/2012:01:24:46
    but for the failure it is.
    01-OCT-2012:01:20:53 IBE IBE_UTIL.enable_debug_new p_check_profile is N
    01-OCT-2012:01:20:53 IBE IBE_UTIL.enable_debug_new p_check_profile is N
    01-OCT-2012:01:20:53 IBE Begin validate_user_update10/01/2012:01:20:53
    01-OCT-2012:01:20:53 IBE Incoming party_id is 9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125
    01-OCT-2012:01:20:53 IBE Incoming cust_account_id is 9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125
    01-OCT-2012:01:20:53 IBE Incoming quote_header_id is 18529
    01-OCT-2012:01:20:53 IBE User id obtained from environment is: -1
    01-OCT-2012:01:20:53 IBE p_save_type is :6
    01-OCT-2012:01:20:53 IBE Entered Validation...T
    01-OCT-2012:01:20:53 IBE no sharee number
    01-OCT-2012:01:20:53 IBE quote_source_code of cart passed in=IStore Account
    01-OCT-2012:01:20:53 IBE Owner flow with env. userid: 10/01/2012:01:20:53
    01-OCT-2012:01:20:53 IBE partyId::quotehdrId(9.990000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000E+125,18529)
    01-OCT-2012:01:20:53 IBE End:Expected exception:IBE_Quote_Misc_pvt.validate_user_update
    From this u can see that party id and account is fetched when using jsp. but direct running of procedure not getting these values.
    is there sql api running when accessing through jsp . so that these values are got from session.
    Thanks
    Mark

    Hi,
    I have passed that too . still getting same error.
    IBE_Quote_W1_PVT.SUBMITQUOTEWRAPPER calls IBE_Quote_Checkout_Pvt.submitQuote
    which calls another package
    PROCEDURE Validate_User_Update(
    p_api_version_number IN NUMBER := 1.0
    ,p_init_msg_list IN VARCHAR2 := FND_API.G_FALSE
    ,p_quote_header_id IN NUMBER
    ,p_party_id IN NUMBER := FND_API.G_MISS_NUM
    ,p_cust_account_id IN NUMBER := FND_API.G_MISS_NUM
    ,p_quote_retrieval_number IN NUMBER := FND_API.G_MISS_NUM
    ,p_validate_user IN VARCHAR2 := FND_API.G_FALSE
    ,p_privilege_type_code IN VARCHAR2 := 'F'
    ,p_save_type IN NUMBER := FND_API.G_MISS_NUM
    ,p_last_update_date IN DATE := FND_API.G_MISS_DATE
    ,x_return_status OUT NOCOPY VARCHAR2
    ,x_msg_count OUT NOCOPY NUMBER
    ,x_msg_data OUT NOCOPY VARCHAR2)
    in it like this
    IBE_Quote_Misc_pvt.Validate_User_Update(
         p_init_msg_list => FND_API.G_TRUE
         ,p_quote_header_id => p_quote_Header_Id
         ,p_quote_retrieval_number => p_sharee_number
         ,p_validate_user     => FND_API.G_TRUE
         ,p_privilege_type_code => 'A'
    ,p_save_type => PLACE_ORDER
    ,p_last_update_date => p_last_update_date
    ,x_return_status => x_return_status
    ,x_msg_count => x_msg_count
    ,x_msg_data => x_msg_data
    from this u can see that there no value passed for party id and account id .
    Thanks
    Mark

  • EFT Payment Program. Writing to a flat file using UTL Package

    Hi guys
    I wonder if someone can help me. I'm battling with something in pl/sql. I have a procedure that writes to a flat file. Each procedure I call writes a single section of the file, e.g "create_hdr_rec_line_fn" writes the header on top of the file and "create_std_trx_rec_line_fn" writes the body below the header. Then lastly the procedure that writes the trailer at the bottom of the file.
    My problem comes here: I have a proc that calculates the hash total.
    This is done by " utl_file.put_line(g_file_id, g_seed_number)". I want to write the hash total next to the trailer section of the file and not below it. How can I do this? Here's the example of the flat file produced. The very last line is the hash total, but I my hash total to be on the same line as the (Trailer). I want it to be just next to the trailer. I hope my question is clear. Please see my procedure below the flat file.
    Thanking you in advance....
    My flat file
    FHSSVSDIM15000932008102810483220081028T (header)
    SD0009300100001D19874200019873402211ACSA JOHANNESBURG INTERNATIONA (Line1-Detail)SC00093001D14540500014540057261IS H/O MAIN ACCOUNT 0000000124959315207 (Line-Transaction)
    ST00093000000700000000070000000000020000001806378410000000000000000000001806378 (Trailer)
    58298239848772973764654319387982 (hash total)
    My procedure
    PROCEDURE eft(errbuf OUT NOCOPY VARCHAR2,
    retcode OUT NOCOPY NUMBER,
    p_payment_batch IN VARCHAR2) IS
    v_eft_date VARCHAR2(100);     
    BEGIN
    v_eft_date := TO_CHAR(SYSDATE, 'DD-MON-RRRR_HH24_MI_SS');
    g_payment_batch := p_payment_batch;
    g_file_name := 'EFT'||v_eft_date||'.txt';
    g_file_id := utl_file.fopen(g_dir_name,
    g_file_name,
    'W');
    utl_file.put_line(g_file_id,
    create_hdr_rec_line_fn);
    create_std_trx_rec_line_fn(g_file_id);
    create_std_contra_rec_line_fn(g_file_id);
    create_std_trailer_fn(g_file_id);
    utl_file.put_line(g_file_id,
    g_seed_number);
    utl_file.fclose_all;
    IF (update_tables != TRUE) THEN
    Fnd_File.put_line(Fnd_File.LOG, 'Failed to update payment batch tables. Cancel the batch');
    END IF;
    EXCEPTION
    WHEN OTHERS THEN
    Fnd_File.put_line(Fnd_File.LOG, 'Print Error - eft' || SUBSTR(SQLERRM, 1, 250));
    END eft;

    user643734 wrote:
    Hi cdkumar
    I'm not quite sure if I understand what you mean. Are you saying that I should use the "PUT" to write 'create_std_trailer_fn' and and then use the "PUT_LINE" to write 'g_seed_number'? Could you please show me what you mean by changing the proc I posted on my question with your suggestions.How about, rather than use code it for you, you try changing the code and giving it a go yourself.
    Essentially PUT_LINE will write out the data and put a "new line" character on the end so the next output will appear on the following line; PUT will just output the data without terminating the line, so any subsequent output will just append to the end.
    It's very simple. Give it a go.

  • Which HRMS API can be used to hire a Contact?

    In either 11i and/or R12.1.3, who knows which HRMS API(s) can be used to hire a contact? That is, a "person" that exists in the system but is not an ex-employee, e.g., someone's spouse, or child. This is a person that exists in PER_ALL_PEOPLE_F, with a SYSTEM_PERSON_TYPE of OTHER. We are not using iRec or any applicant functionality, so I cannot create an application for the Contact and then hire the Applicant. Instead, my requirement is to directly hire the Contact.
    I am using the following APIs for other scenarios, but haven't figured out the Contact hire yet:
    HR_EMPLOYEE_API.CREATE_US_EMPLOYEE - using this API for brand new hires that do not currently exist in the database
    HR_EMPLOYEE_API.RE_HIRE_EX_EMPLOYEE - using this API for rehiring ex-employees that already exist as a person in the database
    One more note, I am able to accomplish this task with no problems from the front-end, so I expect there must be a way to do the same from the back-end.
    e.g.,
    1) Navigate to Person Form
    2) Find Contact
    3) Change Action to "Create Employment"
    4) Choose Person Type "Employee"
    5) Save, which successfully hires the Contact and creates the employee record
    Please help!
    Thanks,
    Jason Genovese

    Ahhh! I just took another look Clives suggestion for using at HR_EMPLOYEE_API.HIRE_INTO_JOB. While the Oracle iRep only shows the 1 HIRE_INTO_JOB procedure, a look in the database at the package uncovers a second, overloaded, HIRE_INTO_JOB procedure that should address my requirement. I believe this will work, but I'll test this out and post back with my results. Here are excerpts from the 2 signatures. The second (new) overloaded procedure should work:
    -- |------------------------------< hire_into_job >---------------------------|
    -- {Start Of Comments}
    * This API hires an applicant as an employee.
    * This API converts a person of type Applicant to a person of type Employee
    * (EMP).
    * <p><b>Prerequisites</b><br>
    * The applicant must exist in the relevant business group and must have an
    * applicant assignment with the assignment status Accepted. If person_type_id
    * is supplied, it must have a corresponding system person type of EMP and must
    * be active in the same business group as the applicant being changed to
    * employee.
    * <p><b>Post Success</b><br>
    * The applicant has been successfully hired as an employee with a default
    * employee assignment.
    * <p><b>Post Failure</b><br>
    * The applicant is not hired as an employee and an error is raised.
    -- {End Of Comments}
    PROCEDURE hire_into_job
    (p_validate IN BOOLEAN DEFAULT FALSE
    ,p_effective_date IN DATE
    ,p_person_id IN NUMBER
    ,p_object_version_number IN OUT NOCOPY NUMBER
    ,p_employee_number IN OUT NOCOPY VARCHAR2
    ,p_datetrack_update_mode IN VARCHAR2 DEFAULT NULL
    ,p_person_type_id IN NUMBER DEFAULT NULL
    ,p_national_identifier IN VARCHAR2 DEFAULT NULL
    ,p_per_information7 IN VARCHAR2 DEFAULT NULL --3414274
    ,p_effective_start_date OUT NOCOPY DATE
    ,p_effective_end_date OUT NOCOPY DATE
    ,p_assign_payroll_warning OUT NOCOPY BOOLEAN
    ,p_orig_hire_warning OUT NOCOPY BOOLEAN
    -- |----------------------------< hire_into_job - new >------------------------|
    -- {Start Of Comments}
    -- Description:
    -- This business process converts a person of type EX_APL, EX_EMP or OTHER to a type of EMP.
    -- This is achieved by:
    -- o Setting the person type to EMP
    -- o Creating a period of service
    -- o Creating a default employee assignment
    -- o Repopulating the security lists
    -- Post Success:
    -- The API updates the person and application and set the following out
    -- parameters:
    -- Name Type Description
    -- p_per_object_version_number number If p_validate is false, set to
    -- the new version number of the
    -- person record. If p_validate is
    -- true, set to the value passed in.
    -- p_employee_number number If p_validate is false, set to the
    -- employee number of the person. If
    -- p_validate is true, set to the
    -- value passed in.
    -- p_assignment_id number If p_validate is false, set to the
    -- assignment_id for the person.
    -- p_effective_start_date date If p_validate is false, set to
    -- the effective start date of the
    -- updated person record. If
    -- p_validate is true, set to null.
    -- p_effective_end_date date If p_validate is false, set to
    -- the effective end date of the
    -- updated person record. If
    -- p_validate is true, set to null.
    -- p_assign_payroll_warning boolean Set to true if the person's date of
    -- birth has not been set. Set to
    -- false if the date of birth has been
    -- entered. Indicates if it will be
    -- possible to set the payroll
    -- component on any of this person's
    -- assignments.
    -- p_orig_hire_warning boolean Set to true if the original date of
    -- hire is not null and the person
    -- type is not EMP, EMP_APL, EX_EMP or
    -- EX_EMP_APL.
    -- Post Failure:
    -- The API does not update the person and period of service and raises an error.
    -- Access Status:
    -- Public.
    -- {End Of Comments}
    PROCEDURE hire_into_job
    (p_validate IN BOOLEAN DEFAULT FALSE
    ,p_effective_date IN DATE
    ,p_person_id IN NUMBER
    ,p_object_version_number IN OUT NOCOPY NUMBER
    ,p_employee_number IN OUT NOCOPY VARCHAR2
    ,p_datetrack_update_mode IN VARCHAR2 DEFAULT NULL
    ,p_person_type_id IN NUMBER DEFAULT NULL
    ,p_national_identifier IN VARCHAR2 DEFAULT NULL
    ,p_per_information7 IN VARCHAR2 DEFAULT NULL --3414274
    ,p_assignment_id OUT NOCOPY NUMBER -- Bug#3919096
    ,p_effective_start_date OUT NOCOPY DATE
    ,p_effective_end_date OUT NOCOPY DATE
    ,p_assign_payroll_warning OUT NOCOPY BOOLEAN
    ,p_orig_hire_warning OUT NOCOPY BOOLEAN
    );

Maybe you are looking for