APEX_MAIL.SEND from a pl/sql function

I have created a pl/sql function, in the database, in which I would like to use APEX_MAIL.SEND to send out emails.
When I try to compile I get the following errors:
Compilation failed,line 10 (08:44:32)
PLS-00307: too many declarations of 'SEND' match this callCompilation failed,line 10 (08:44:32)
PL/SQL: Statement ignored
Here is the relavent code. Line 10 is the line where I have APEX_MAIL.SEND
LOOP
APEX_MAIL.SEND (
P_TO => email_rec.TO_EMAIL,
P_FROM => email_rec.FROM_EMAIL,
P_BODY => email_rec.BODY,
P_BODY_HTML => email_rec.BODY,
P_SUBJ => email_rec.SUBJECT );
I am in APEX version 3.0.0.00.20
I can send mail from a APEX application procedure. The function I am having trouble with is one that can be accessed under the SQL Workshop --> Object Browser --> Functions.
Other functions work fine.
Thanks.

Have a look at the following thread Re: HTMLDB_MAIL.SEND Cursor for loop
It might be a problem of your data types you have defined in email_rec. Eg. do you have a CLOB for SUBJECT?
Patrick
My APEX Blog: http://inside-apex.blogspot.com
The ApexLib Framework: http://apexlib.sourceforge.net
The APEX Builder Plugin: http://sourceforge.net/projects/apexplugin/

Similar Messages

  • Pass a value from a PL/SQL function to a javascript (html header) ? ?

    Hey Guys,
    Have a question regarding how to pass a value from a PL/SQL function to a javascript in the HTML Header.
    I have created a PL/SQL function in my database, which does looping.
    The reason for this is:  On my apex page when the user selects a code, it should display(or highlight buttons) the different project id's present for that particular code.
    example= code 1
    has project id's = 5, 6, 7
    code 2
    has project id's = 7,8
    Thank you for your Help or Suggestions
    Jesh
    The PL/SQL function :
    CREATE OR REPLACE FUNCTION contact_details(ACT_CODE1 IN NUMBER) RETURN VARCHAR2 IS
    Project_codes varchar2(10);
    CURSOR contact_cur IS
    SELECT ACT_CODE,PROJECT_ID
    FROM ACTASQ.ASQ_CONTACT where ACT_CODE = ACT_CODE1;
    currec contact_cur%rowtype;
    NAME: contact_details
    PURPOSE:
    REVISIONS:
    Ver Date Author Description
    1.0 6/25/2009 1. Created this function.
    BEGIN
    FOR currec in contact_cur LOOP
         dbms_output.put_line(currec.PROJECT_ID || '|');
         Project_codes := currec.PROJECT_ID|| '|' ||Project_codes;
    END LOOP;
    RETURN Project_codes;
    EXCEPTION
    WHEN NO_DATA_FOUND THEN
    NULL;
    WHEN OTHERS THEN
    -- Consider logging the error and then re-raise
    RAISE;
    END contact_details;
    /

    Jesh:
    I have made the following modifications to your app to get it to work as I thing you need it to.
    1) Changed the source for the HTML Buttons Region(note use of id vs name for the Buttons)
    <script>
    function hilitebtn(val) {
    //gray buttons
    $x('graduate').style.backgroundColor='gray'
    $x('distance').style.backgroundColor='gray'
    $x('career').style.backgroundColor='gray'
    $x('photo').style.backgroundColor='gray'
    //AJAX call to get project-ids
    var get = new htmldb_Get(null,$x('pFlowId').value,'APPLICATION_PROCESS=GETPROJECTS',0);
    get.addParam('x01',val)
    gReturn = get.get();
    var arr=gReturn.split(':');  //dump into array
    get = null;
    for (i=0;i<arr.length;i++) {
    // alert('val=' + arr);
    if ( arr[i]==5)
    $x('graduate').style.backgroundColor='red';
    if ( arr[i]==6)
    $x('distance').style.backgroundColor='red';
    if ( arr[i]==7)
    $x('career').style.backgroundColor='red';
    if ( arr[i]==8)
    $x('photo').style.backgroundColor='red';
    </script>
    <table cellpadding='0' cellspacing='0' border='0'>
    <tr><td>
    <input type='button' id='graduate' value='Graduate'>
    </td>
    <td>
    <input type='button' id='distance' value='Distance'>
    </td>
    <td>
    <input type='button' id='career' value='Career/Tech'>
    </td>
    <td>
    <input type='button' id='photo' value='Photos'>
    </td>
    </tr></table>
    2) Defined the application process  GETPROJECTS as DECLARE
    IDS varchar2(1000);
    l_act_code varchar2(100) :=4;
    begin
    IDS:='';
    l_act_code := wwv_flow.g_x01;
    for x in(
    SELECT ACT_CODE,PROJECT_ID
    FROM ASQ_CONTACT
    where ACT_CODE = l_act_code)
    LOOP
    IDS := IDS || X.PROJECT_ID|| ':' ;
    END LOOP;
    HTP.PRN(IDS);
    END;
    3) Changed the 'onchange' event-handler on p1_act_code to be 'onchange=hilitebtn(this.value)'
    4) Added the JS to the HTML Page Footer <script>
    hilitebtn($v('P1_ACT_CODE'));
    </SCRIPT>

  • Catch a value from a pl*sql function in a shell script

    Hi all,
    I have a shell script that simply calls the following pl*sql function.
    echo "execute scott.my_pkg.test('FDLmaster');\n exit;" >./pippo.sql
    sqlplus scott/tiger @/fidcap_ftp/FDL/SCRIPTS/pippo.sql
    What I have to do to catch the value returned from the function test?
    Thanks in advance
    best regards
    Mario

    SQL> create or replace function do_something return varchar2 is
      2  begin
      3      return ('Something');
      4* end;
    SQL> /
    Function created.
    SQL> select do_something from dual;
    DO_SOMETHING
    Something
    SQL> save pippo
    Created file pippo.sql
    SQL> exit
    Disconnected from Oracle Database 10g Enterprise Edition Release 10.1.0.3.0 - Production
    With the Partitioning, OLAP and Data Mining options
    [linuxas tmp test10]$ echo exit >>pippo.sql
    [linuxas tmp test10]$ VAR=`sqlplus -s scott/tiger @pippo`
    [linuxas tmp test10]$ echo $VAR | cut -f3 -d" "
    Something
    [linuxas tmp test10]$

  • Setting Oracle Permissions for file access from a pl/sql function

    I have a pl/sql function that calls a java method which moves a
    file from a directory to another.
    Since we are using Linux, Oracle wants some permissions.
    Those permissions are set using:
    call dbms_java.grant_permission(USER, 'java.io.FilePermission',
    FILE, permission)
    OK, i want to use this in my pl/sql function, but it doesn't
    work.
    My function looks like something like this:
    -- some pl/sql code
    dbms_java.grant_permission(someUSER, 'java.io.FilePermission',
    sourceFILE, 'write');
    dbms_java.grant_permission(someUSER, 'java.io.FilePermission',
    destFILE, 'write');
    flag := move(sourceFILE, destFILE);
    -- flag is for 1 -> done and 0 -> error
    -- some more code ...
    The problem is the lines of
    dbms_java.grant_permission(someUSER, 'java.io.FilePermission',
    sourceFILE, 'write');
    do not work!
    When i grant permissions manually in sql plus it works great,
    but when i do it from the function it does not work!
    Any ideas anyone?
    Any help would be appreciated.

    The command :
    dbms_java.grant_permission
    (someUSER, 'java.io.FilePermission',sourceFILE, 'write');
    is right.
    Open sqlplus
    Connect as sys or system
    type :
    execute dbms_java.grant_permission
    (someUSER, 'java.io.FilePermission',sourceFILE, 'write');
    commit;
    try to compile again your procedure...does it work now ?
    bye
    Giovanni Regola

  • Building the varchar string to return from a pl sql function

    i'm new with pl/sql and i'm having trouble trying to build the string that i want to return from a function that is inside a package. it seems my problem stems from the fact that i'm trying to incorporate a variable (varchar2) into the string to be returned. below are two attempts that i've made which do not work:
    function test_policy (p_schema_name IN varchar2, p_object_name IN varchar2) return varchar2 as
    predicate_value varchar2(2000);
    user_name varchar2(100);
    begin
    select first_name
    into user_name
    from employees
    where first_name = SYS_CONTEXT('hr_app_context', 'username');
    predicate_value := 'first_name = ' || user_name;
    predicate_value := 'first_name = ' || '' || user_name || '';
    return predicate_value;
    end test_policy;
    Can someone help me with the proper syntax to build my string for the return value? Thanks.

    this function implements the code for a policy i've created. basically, the policy says that when i do a select on the employees table, i should only see a record whose first_name = sys_context('hr_app_context', 'username'). so, when i perform a simple select * from employees, i get an error which says policy predicate has error. i'm pretty sure the error is caused by how i'm building the return value for that function. if i hard code some return value like:
    predicate_value := 'first_name = ''HR''' ;
    the select statement above works fine, and i only see the record from employees where first_name = 'HR'

  • Use Apex_Mail.Send From A Background Job

    I am trying to use the Mail API to send Mail generated from a DBMS_Job entry. I am getting an error stating I must run this from an application to use this feature. Am I missing something or have done something wrong ? Or is this not possible from background jobs.
    Any help appreciated,
    Thanks,
    Tom

    Take a look at this thread from 2009.. I believe it will help you.. Re: How Can I Run APEX_MAIL Outside of ApEx?
    Thank you,
    Tony Miller
    Webster, TX

  • Q: NULL return REF CURSOR from a PL/SQL function

    I was told that PL/SQL does not handle properly NULL REF CURSORS.
    Here's my implementation in a PL/SQL package
    PACKAGE SPEC:
    TYPE z_rec IS RECORD (
    TYPE z_cur IS REF CUR RETURN z_rec;
    FUNCTION some_function(
    p_msg OUT VARCHAR2)
    RETURN z_cur;
    PACKAGE BODY:
    FUNCTION some_function(
    p_msg OUT VARCHAR2)
    RETURN z_cur
    IS
    retval z_cur;
    OPEN retval FOR
    SELECT ...
    -- Successfull data retrieval
    p_msg := NULL;
    RETURN retval;
    EXCEPTION
    WHEN OTHERS THEN
    p_msg := SUBSTR( SQLERRM, 1, 255 );
    RETURN NULL;
    END some_function;
    I am expecting that a user of this function would call it and test p_msg (output parameter)
    1. IS NULL p_msg it means there were no errors encounetered. The returned cursor can be NULL though (i.e. no records retrieved)
    2. IS NOT NULL p_msg, it means that there were errors and the returned cursor is not usable.
    My question is:
    what are the pitfalls of this approach?
    Thanks a lot.

    user10817976 wrote:
    I asked and still waiting for the answer.
    retval z_cur;
    What I am afraid for is that
    OPEN retval FOR
    SELECT ...
    EXCEPTION
    retval := NULL;
    tries to open the cursor. What happens in case of error? Well, I imagine retval is still NULL. Do I need to (try) to close the cursor in the EXCEPTION section (in order not to misuse the number of cursors in the pool?) That's my worry.No.
    If there is an error opening the cursor the cursor will not be open and will not need closing.
    The code should simply be
    function some_function
        return z_cur
    is
        retval z_cur;
    begin
        open retval for
            select ...
        return retval;
    end some_function;        It is bad practice for a function to have output parameters.
    It is bad practice to turn exceptions into return codes.
    http://tkyte.blogspot.com/2008/06/when-others-then-null-redux.html
    Remember everyone, everyone remember, keep in mind:
    When others not followed by RAISE or RAISE_APPLICATION_ERROR is almost certainly, with 99.999999999% degree of accuracy, a bug in your developed code. Just say "no" to when others not followed by raise or raise_application_error!Read the links, it leads to problems over and over again.

  • SQLJ : sending refcursors via out parameters of PL/SQL functions possible ?

    Hello,
    in SQLJ it's possible to get a refcursor back from a PL/SQL
    function via
    the return value(the usual case in the online examples).
    Is it also possible to give a refcursor back via an out
    parameter
    so that the return value could be used for others ways ?
    SQLJ generation in JDeveloper handles the first way, but we
    didn't
    get it to work with the out parameter.
    Thank you for your help.

    It's certainly possible to have a stored procedure with an OUT parameter that is a REF CURSOR and use that to return data to JDBC. That's actually the most common way that JDBC programmers get ResultSets from stored procedures. I would have to assume that SQLJ would facilitate that?
    Is there a reason that you're looking to use a stored function rather than a stored procedure? The latter seems like a much more logical construct when you have OUT parameters. I've never seen a stored function that was defined with any OUT parameters.
    Justin
    Distributed Database Consulting, Inc.
    www.ddbcinc.com

  • GROUP DATA PL/SQL FUNCTIONS CALLABLE FROM SQL

    MAKE GROUP DATA PL/SQL FUNCTIONS (IE. TABLE TYPE PARAM) CALLABLE FROM SQL
    Is it possible to create new group function like AVG or to overload them ?
    null

    Application Developer's Guide (A76939, page 9-60) list a few requirements from user-defined SQL function, and one of them is:
    * It must be a row function, not a column (group) function; in other words, it
    cannot take an entire column of data as its argument.
    But if anyone find a way to do it, please let me know.

  • Calling Web Service From Oracle PL/SQL do not invoke the webservice in SOA Server

    Hi ,
    Trying to call the webservice from oralce pl/sql Function
    created a Function
    Not able to invoke the web service of SOA Server .
    CREATE OR REPLACE FUNCTION HelloWorld_WebServices(S_STRING Varchar2) RETURN VARCHAR2 AS 
        service_ sys.utl_dbws.SERVICE; 
        call_ sys.utl_dbws.CALL; 
        service_qname sys.utl_dbws.QNAME; 
        port_qname sys.utl_dbws.QNAME; 
        response sys.XMLTYPE; 
        request sys.XMLTYPE; 
        BEGIN 
         sys.utl_dbws.set_http_proxy('Host name : Port'); 
          service_qname := sys.utl_dbws.to_qname('ns1', 'process'); 
           service_      := sys.utl_dbws.create_service(service_qname); 
           call_         := sys.utl_dbws.create_call(service_); 
            sys.utl_dbws.set_target_endpoint_address(call_, 'http:/host name : port/soa-infra/services/OFS/HelloWorld/helloworld_client_ep'); 
            sys.utl_dbws.set_property( call_, 'OPERATION_STYLE', 'process'); 
            request       := sys.XMLTYPE('<ns1:process xmlns:ns1="http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld"><ns1:input></ns1:input></ns1:process>'); 
         response      := sys.utl_dbws.invoke(call_, request); 
         return response.extract('//HelloWorld/child::text()', 'http://xmlns.oracle.com/OFSOrderServices/HelloWorld/HelloWorld').getstringval(); 
         DBMS_OUTPUT.PUT_LINE ('Values of OutputsVariables8');
    --  Return 'S';
       END;
    Execute----the below code:
      Select HelloWorld_WebServices('Hi') from dual;
    Error:
    ORA-29532: Java call terminated by uncaught Java exception: java.lang.NoClassDefFoundError
    ORA-06512: at "SYS.UTL_DBWS", line 403
    ORA-06512: at "SYS.UTL_DBWS", line 400
    ORA-06512: at "APPS.HELLOWORLD_WEBSERVICES", line 74
    29532. 00000 -  "Java call terminated by uncaught Java exception: %s"
    *Cause:    A Java exception or error was signaled and could not be
               resolved by the Java code.
    *Action:   Modify Java code, if this behavior is not intended.

    Well, you should first test if your webservice is reachable with a simple WS - Client or a Browser - Plugin, then verify the respones of the web service and after that you can take further investigations on your problem domain. The error - message refers to a line in your function, obviously, but I can't see which line and because there is more than one call to sys.utl_dbws I don't see at what point the script fails. NULL - Pointer - Execptions usually indicate that a method was invoked on a variable which should contain an object reference but is NULL.

  • Is it possible to retrieve RAD's extended variables with a pl/sql function?

    Good morning everyone,
    We have our forms and reports(10g) application, SSO enabled and we are using OID on 10g app server. some of our users use smart card to log in to the system and some who do not have smart cards provide their database userid, password and SID.
    In the case of users who login with smart card, as a one time effort, they have to register their smart card. At that point OID presents a form prompting for their username, password, sid and then a RAD record is created for that particular user.
    And from then on when the user enters the system using his smart card(12345@mil), forms servlet, does the look up of dbusername,dbpswd,sid which belong to the 12345@mil and user's database credentials are passed to the application. The entire application logic is based on that userid which is also an internal userid in the application. Everything is working fine.
    I have read the documentation and found that 12345@mil is stored in the "cn" parameter and the orclownerguid and orclusernameattribute are stored under "cn"=extended properties in the oid. I am able to see this from the oid console.
    But now I need some help. If I only know the id of the user as "12345@mil" , is it possible to manually query the RAD and retrieve the orclusername from a pl/sql function?
    Any help is greatly appreciated.
    Regards,
    Suma.

    Please can anyone help me????
    Regards,
    Suma.

  • Use Gmail to send from your other email addresses

    hello,
    i have setup gmail account on my Q10, but i can not use it's "send from other email addresses" functionality.
    description of the situation:
    i have my own domain with configured email forwarding to gmail account. i publically use only domain email address so in fact no body knows that this really goes to google. on the other side i have configured google to send from different account, so i use SMTP of my domain. in general it looks like gmail is just my mail application and mail storage - my domain has really thin limits. it has the advantage that i really send form my domain address, receiver sees only my domain address but the mail goes through google, so i use gmail's interface which i like and also message is stored in "Sent" folder of gmail.
    the only idea which comes to me to configure similar setup on Q10 is to configure same account twice, but with different "from" address on the other account, but won't it be than i get double notification per one email?
    regards,
    mark

    Hi all,
    This can be also a general question without any connection to the Gmail service, and I formulate itt following way:
    Is the email client of the bbq10 capable for sending emails with different from email adresses?
    All the most popular email clients are capable for that, on a special way the former blackberry bold was also capable for that function!! I know, i used this function.
    I have ca 10 email adresses, which are only aliases and all email will forwarded to one mailbox. That means only once downloaded, and when i reply to or forward an email i can always choose the from adress, as i would write from a different email account.
    So whatsup dear blackberry service provider, are you one step back as also with the disappearing of the good old BIS service?
    Despite of this i like bbq10 very much
    Thanks for all kind of help

  • APEX_MAIL.SEND() not seen executing MY procedure from TOAD

    Hi,
    I have a procedure that calls APEX_MAIL.SEND and works fine when executed from within the app or in the APEX Workshop window.
    Trying to execute MY procedure from an Oracle job we get an error unknown procedure APEX_MAIL.SEND
    anyone have this problem?

    Hello,
    Why don't you use utl_smtp package if you are wanting to send email from pl/sql?
    If you look at the help for APEX_MAIL its says:
    APEX_MAIL
    You can use the APEX_MAIL package to send an email from an Oracle Application Express application. This package is built on top of the Oracle supplied UTL_SMTP package. Because of this dependence, the UTL_SMTP package must be installed and functioning in order to use APEX_MAIL.
    So APEX_MAIL will only work within a valid apex session and it won't be available to a toad session .
    Cheers,
    Paul.

  • Calling a PL/SQL function from java

    I would like to call a pl/sql function from java. My pl/sql function is taking arrays of records as parameters. How do i proceed? Which specific oracle packages do I have to import?
    Please send an example.
    TIA,
    Darko Guberina

    Documentation here: http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref185
    says JPublisher can publish records too.
    But when I change the example given at http://download-uk.oracle.com/docs/cd/B14117_01/java.101/b10983/datamap.htm#sthref190 as following:
    PACKAGE "COMPANY" AS
    type emp_rec is record (empno number, ename varchar2(10));
    type emp_list is varray(5) of emp_rec;
    type factory is record (
    name varchar(10),
    emps emp_list
    function get_factory(p_name varchar) return factory;
    END;
    then I see <unknown type or type not found> at sql or java files generated. Any ideas?

  • Calling PL/SQL function from OCI?

    Hi,
    How do I execute a PL/SQL function from OCI?
    My test function:
    CREATE OR REPLACE FUNCTION GetNodeQuery(TypeId IN INTEGER) RETURN VARCHAR2 IS
    Query VARCHAR2(500);
    BEGIN
    Query := 'Select * from Logical_Name';
    RETURN Query;
    END GetNodeQuery;
    char SQL[16];
    strcpy(SQL, "GetNodeQuery(1)");
    char ColumnVariable[500];
    int VariableSize = 500;
    OCIStmtPrepare(qHandle, hError, SQL, (ub4)strlen(SQL),
    (ub4)OCI_NTV_SYNTAX, (ub4)OCI_DEFAULT);
    OCIDefineByPos(qHandle, &pDefine, hError, 1,
    (dvoid*)ColumnVariable, (sb4)VariableSize,
    1,(dvoid*)0, (ub2*)0, (ub2*)0,
    OCI_DEFAULT);
    OCIStmtExecute(svchp, qHandle, hError, (ub4)1, (ub4)0,
    (CONST OCISnapshot *)NULL, (OCISnapshot*)NULL,
    OCI_DEFAULT);
    On the Execute I get an error saying that ORA-00900: invalid SQL statement
    Any Help would be appreciated.
    Thank You,
    Scott Metzger
    null

    Ok, I made a mistake the
    select GetNodeQuery(1) from dual
    only works with a simple function. My real life function has a cursor via DBMS_SQL.
    I presume I would need to pass the following in my OCIStmtPrepare call:
    Define
    tmp Varchar2[256];
    begin
    tmp := GetNodeQuery(1);
    end;
    Now how do I get the value of tmp out?
    I couldn't find any examples for calling functions from OCI. If you know of some could you post the url or send them to me?
    Thanks,
    *:> Scott
    [email protected]
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Tiago Nodari ([email protected]):
    you need to modify the sqlstatement to look something like this...
    begin
    GetNodeQuery(1)
    end;
    look into the OCI documentation, there are various examples of how to do it, including, binding and defining variables...
    <HR></BLOCKQUOTE>
    null

Maybe you are looking for

  • Multiple Service Products in Service Order ?

    Hi, I have the follg business process: A customer sends, say, 1000 Pieces of a Product A for repair. Problem in each Piece may be different - some may require just cleaning, some may require Parts replacement etc., which is known only after carrying

  • Texts send as iMessage to iPad instead of SMS to iPhone iOS7

    My BF has iMessage OFF on his iPhone 4 (running iOS6) but ON on his iPad Air (iOS7). I want to leave iMessage ON on my iPhone 4 (running iOS7) because other people who text me need to use it. But when I send my BF a text now my messages default to hi

  • Wetransfer js error causes my computer to slow down

    Every time I send a file via WeTransfer I end up with a js error and then my MacBook Pro slows down to a grinding halt...literally. You can hear the hard drive grinding away. Every time I try to move the mouse or select a file or drop down I get the

  • MIR7 - Transport RSEG fields (Append Structure) to BSEG

    Dear enhancers I would like to ask you haw could I approach such a requirement: The RSEG table is appended 2 more ZZ_ fields. Let's say it's ZZ_A and ZZ_B fields. Those fields are populated by the MIR7 transaction. I've got a Z-tab added in line item

  • Download assesment

    Hi, I just reinstalled Tiger on my ibookG4. After installing I ran Software Update and so I think I am up to date on everything. I'm running Safari 2.0.4(419.3). I started downloading some programs off the internet to get my computer back to how I ha