Display an Alert message in PL/SQL block in APEX

Hi,
we are getting an oracle exception while inserting a new row. As it is having the unique constaint on a coulumn.
Now the problem iis we need to Display an "Alert message" based on the input field validation. That java script code for alert has to be embeded nside a PL/SQL block in Oracle APEX Application.
we tried doing this with below code:
Begin
INSERT INTO <<table name>>(ID,NAME) VALUES (s1,:TXT_s2);
exception when others then
htp.p('<script language="javascript">');
htp.p('alert("Exception");');
htp.p('</script>');
end;
If anybody knows .... please reply.
Thanks,
Subarna
Edited by: user9955252 on Apr 21, 2010 1:47 AM

Hello,
APEX Forum is here : Oracle Application Express (APEX)
Regards

Similar Messages

  • Display an Alert message from PL/SQL block in APEX

    Hi,
    we are getting an oracle exception while inserting a new row. As it is having the unique constaint on a coulumn.
    Now the problem iis we need to Display an "Alert message" based on the input field validation. That java script code for alert has to be embeded nside a PL/SQL block in Oracle APEX Application.
    we tried doing this with below code:
    Begin
    INSERT INTO <<table name>>(ID,NAME) VALUES (s1,:TXT_s2);
    exception when others then
    htp.p('<script language="javascript">');
    htp.p('alert("Exception");');
    htp.p('</script>');
    end;
    If anybody knows .... please reply.
    Thanks,
    Subarna

    If your end goal is showing a pretty error message instead of the message that the tables unique constraint raises try the following. This logic will show a nice message and not try to insert non-unique data.
    (1) Create a validation of type "Function Returning Error Text".
    (2) Place similar code like the following in your validation. Notice that if the unique name does not exist the no_data_found returns null allowing the validation to pass.
    DECLARE
      v_error varchar2(100);
    BEGIN
      SELECT 'A person by this name already exists.'
      INTO v_error
      FROM your_table
      WHERE your_name = :P1_YOUR_NAME;
      RETURN v_error;
    EXCEPTION
      WHEN no_data_found THEN
        RETURN NULL;
    END;

  • Not able to display javascript alert message from within a pl/sql block

    Hello,
    Can anyone please help me out with this issue. I wanted to display an javascript alert message from within a pl/sql block for an update button. Below is sample code which i am using. P1_ITEM is my hidden item on the report.
    begin
    if :P1_ITEM IS NOT NULL then
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Please complete the item which is already assigned to you!'');');
    HTP.p ('</script>');
    end if;
    end;
    and I have made this code to be executed conditionally when request = Expression1
    Expression1: SUBMIT
    The thing is I am not able to display an alert message when the update button is clicked.
    Can anyone please help me with this one.
    Thanks,
    Orton

    varad but I also have an update statement within that block for the update button something like this i want to achieve.
    begin
    if :P1_ITEM IS NULL THEN
    update sample_tbl
    set col1 =:APP_USER,
    col2 = 'Y'
    where pk_col = ---;
    commit;
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Successfully assigned an item!'');');
    HTP.p ('</script>');
    end if;
    if :P1_ITEM IS NOT NULL then
    HTP.p ('<script type="text/javascript">');
    HTP.p ('alert(''Please complete the item which is already assigned to you!'');');
    HTP.p ('</script>');
    end if;
    end;
    thanks,
    Orton

  • Display an alert message through javascript when report column item is null

    Hello,
    I have a report column item which is an select list item and now i want to display an alert message when value is null, I mean no value is selected, this alert message should be fired when update button is clicked.
    Can anyone please help me with this issue.
    Thanks,
    Orton

    You could try something like this:
    declare
      x        INTEGER;
      err_ct  INTEGER   := 0;
    begin
      x  := 5;  -- number of rows displayed
      for i in 1 ... x (
        IF wwv_flow.g_f08(i)) IS NULL THEN err_ct  := err_ct + 1;
        END IF;
      end loop;
      IF err_ct = 0 THEN
         RETURN NULL;
      ELSE
        RETURN 'Nice error message: you must supply a value.';
      END IF;This would be used with a PL/SQL validation: Function Returning Error Text.

  • How displaying an alert message called from a database procedure

    Hi,
    How can I display an alert message that is called from a database procedure.
    I've tried the following code:
    l_al_button NUMBER;
    l_al_message VARCHAR2(80);
    l_al_id ALERT;
    Set_Alert_Property(l_al_id, alert_message_text,l_al_message);
    l_al_Button := show_alert(l_al_id);
    When trying I receive an error that says that the word ALERT need to be declared.
    Any suggestions?
    Thanks

    Hi,
    leave the procedure without error handling.
    This is what you can do:
    1.Inside the database procedure-
    BEGIN
    RAISE_APPLICATION_ERROR (-20001, 'The chosen length of the Public Key Exponent ....');
    END;
    2.Into your Form -
    BEGIN
    EXCEPTION
    WHEN OTHERS THEN
    IF sqlcode = '-20001' THEN
    Display Your Messages.
    END IF;
    Monica
    END;

  • How to display an alert message on click of link in tableview

    Hi,
    Following is the code for a tableview in layout section of a BSP( i have specified only one tableview column here). The requirement is to display an alert message on click of link in the first column that is "evbeg". Can anyone please help me how to achieve this? Appreciate quick response on this.
    CREATE OBJECT lr_dateiterator TYPE cl_lso_bsp_it_trdates
                EXPORTING im_application = application
                im_tform = trainingform.
            <htmlb:tableView id            = "dates"
                                 table         = "<%= dates %>"
                                 iterator      = "<%= lr_dateiterator %>"
                                 width         = "100%"
                                 rowCount      = "<%= lp_len %>"
                                 footerVisible = "FALSE"
                                 sort          = "SERVER" >
                  <htmlb:tableViewColumn columnName    = "evbeg"
                                         type          = "user"
                                         title         = "<%= otr(LSO_FRONTEND/schedule) %>"
                                         tooltipHeader = "<%= otr(LSO_FRONTEND/schedule) %>"
                                         sort          = "TRUE" >
                  </htmlb:tableViewColum>
    Thanks and Regards,
    Archana.

    you have to code in the iterator for this.
    in the render_cellstart method of the iterator you need to code.
    this is for a column.
    when 'MATNR'.
    data: text type string.
    text = 'disp_alert()'.   "this java script i placed in the page
    data: lo_link type ref to cl_htmlb_link.
      create object lo_link.
         lo_link->id = p_cell_id.
         lo_link->onclientclick = text.
         lo_link->text = <fs>-matnr.
         p_replacement_bee = lo_link.
    below is the java script i added in my page..
    <  sc ri   pt type="text/javasc ript"   >
    f u n  ction disp_alert()
    a  l e  rt("helloworld");
    < /s  c ript >

  • Displaying a Message from PL/SQL block to Java Application

    Hi
    How can One display or populate a message in Java Application, that is generated from a PL/SQL block?

    Well, the easiest option would be to have a "message" parameter that gets passed back from the PL/SQL block to the calling Java application.
    I'm guessing, though, that you wouldn't be asking the question if the easy solution was a viable option... If that's the case, you're going to have to describe the problem in a bit more detail...
    Justin

  • My ipad was is displaying an alert message " A wi-fi connection is required to download your apps and media". So it has been connected to the internet over night and this morning but is still displaying the alert message and it won't go away. what to do?

    Hi,
    My name is Norbert. I am having some difficulties restoring my icloud back up. My ipad was doing an icloud back up and the alert message displayed on the ipad after my internet was interrupted "A wi-fi connection is required to download your apps and media".
    I got the internet working, my ipad is receiving internet network but the alert message is still displayed on the ipad and won't go away, to make matters worse the ipad is frozen and i can't do anything.
    Please can anyone with a similar experience tell me what to do in this situation?
    Thank you

    Welcome to the Apple Community.
    Have you tried a hard restart. Press the on/off button and homescreen buttons together until the device shuts down.

  • Alert message in pl/sql code

    I have a form based on procedure and i want when the procedure executed to appear an alert message. The form is as a portlet to a page. This is the code in the procedure
    htp.p('<SCRIPT>alert("my message");</SCRIPT>');
    The problem is that after the allert message, appears a page with a green icon and a 'back to form' link.
    I want to click on the OK button and returns to the same page. Can anybody tell me what have to do?
    Thanks

    I add the go procedure to the "On successful submission" but when the form is executed returns to the page without appears the alert message i want.
    In fact i want to execute the form and to appear a message in a form like as the message which appears in a form when an optional field is null. That missage is "item_name cannot be null".You click the OK button and continue to the same page. I want that functionality when the form is executed. For example when the form is executed i want to appear the message "The procedure was successful" and the user have to press only the OK button and continue explore the same page.
    Remember that my form is on store procedure and the allert code is in the procedure's body
    Thanks

  • How to send a mail from a PL/SQL-block in Apex

    Hi, I am using Apex 3.0. On a page in my application users are fill out some fields, and clicking a button Apex inserts a new record in an table processing a PL/SQL-block.
    I would like to add "something" in this block so that Apex every time when it adds a new reord, also sends a mail to some people to inform them....
    A short e-mail: sender:...... receiver..... subject: New record, Text: New record was added
    Is that possible??Thx

    Hey Robert2,
    Apex has an API for sending emails: APEX_MAIL, you will need to have an SMTP server for this.
    Have a look in the user_guid, you will find what you need there.
    OLI

  • I have updated to latest version of Firefox but my start screen continues to display the "alert" message stating I am no longer protected and need to upgrade to latest version. Please advise

    As stated above

    Your UserAgent string in Firefox is messed up by something that you installed, and it looks like you are using Firefox 3.0.11. <br />
    [http://en.wikipedia.org/wiki/User_Agent]
    type '''about:config''' in the URL bar and hit Enter <br />
    ''If you see the warning, you can confirm that you want to access that page.'' <br />
    Filter = '''general.useragent.''' <br />
    Right-click the preferences that are '''bold''', one line at a time, and select '''''Reset'''''. <br />
    Then restart Firefox

  • How to display warning message in PL/SQL?

    Hi,
    I would like to know how to display a warning message in PL/SQL?
    Thanks and Regards,
    SC

    PL/SQL is not an interactive programming language, so there is generally no place to print any sort of message, no place to prompt the user for input, etc.
    A SQL*Plus script can use the SQL*Plus client as a very basic way of interacting with users using the PROMPT command to accept input and using DBMS_OUTPUT to print messages to the console (assuming the script does a SET SERVEROUTPUT ON to enable printing the results). Other applications may have similar sorts of scripting possibilities, generally based on a subset of the commands SQL*Plus supports.
    Justin

  • Check  File Existence and display  alert message

    Hi,
    I have a servlet which uploads file to server. Below is my code and is working file. Now, I want to check if the file uploading by the user is already exists. If so , I have to display a message to user "The file you are trying to upload already exists. Do you want to overwrite" with YES or NO actions.
    How can I display this alert message from user.
    //item.write(tosave);
              FileItemFactory factory = new DiskFileItemFactory();
              boolean isMultipart = FileUpload.isMultipartContent(request);
              System.out.println(isMultipart);
              Map fileDetails = new HashMap();
              ServletFileUpload upload = new ServletFileUpload(factory);
              List items = upload.parseRequest(request);
              Iterator iter = items.iterator();
              while (iter.hasNext()) {
                   item = (FileItem) iter.next();
                        if (item.isFormField()) {
                                       String fieldName = item.getFieldName();     
                                       String fieldValue = item.getString();
                                       fileDetails.put("fileName",item.getString());
                        else {
                                  fileDetails.put("path",item.getName());
                                  cfile=new File(item.getName());
                                  onlyFileName = cfile.getName();
                   if (! folder.exists()) folder.mkdirs();
                   if(cfile.exists()){  //THIS CHECK THE FILE EXISTENCE.  HOW CAN I DISPLAY ALERT MESSAGE TO USER HERE.
                        System.out.println("File Already Exists Path is ");     
    Can anyone suggest me on this.

    It won't work like that because JavaScript will run either before the form is submitted or after the page has been generated. In either case, you can't really communicate between the server side code and client side code.
    What you can do is use Ajax to communicate with a servlet that checks for the duplicate file and responds accordingly. You can then perform the appropriate action on the page. This should be very simple to setup, take a look at this basic tutorial [1].
    [1] http://www.w3schools.com/ajax/default.asp
    People on the forum help others voluntarily, it's not their job.
    Help them help you.
    Learn how to ask questions first: http://www.catb.org/~esr/faqs/smart-questions.html
    ----------------------------------------------------------------

  • Display alert message On successful submission of a form

    I am trying display an alert message on a portal form when a user has saved their changes. I put the following code in the "On successful submission of a form" section.
    It does the go URL correctly but it does not display the alert message.
    url2 := 'PORTAL.wwa_app_module.link?' ||
    'p_arg_names=_moduleid&p_arg_values=' || l_module_id ||
    '&p_arg_names=_show_header&p_arg_values=YES' ||
    '&p_arg_names=_school_cond&p_arg_values=%3D' ||
    '&p_arg_names=_teacher_id_cond&p_arg_values=%3D';
    go(url2);
    htp.p('<SCRIPT LANGUAGE="JavaScript1.1">');
    htp.p('alert("Transaction complete... Class/Period Attendance has been posted to database.")');
    htp.p('</SCRIPT>');
    END;

    In Forms, you have "call" and "go" interfaces. You can provide the calling page URL in "go" interface.

  • How to fire a Alert Message in a table format

    Hi friends,
    Currently im performing an Alert. My requirement is i need to display the alert message to the user in the mail in a table format.
    But i couldnt perform that, as the alert is not displaying in a properly aligned table format.
    Can you friends propose me a right way to bring the alert in a table format with two columns.
    Thanks in Advance..
    Regards,
    Saro

    I agree w 936671, do this in PL/SQL. Much, much easier.
    However, I will recommend a different approach using PL/SQL.
    1) Create a package to send the emails. Sample code:
    create or replace package cust_fnd_utilities as
    procedure send_email(     p_sender     in     varchar2,
                   p_recipient      in      varchar2,
                   p_subject     in     varchar2,
                   p_message     in     varchar2);
    end cust_fnd_utilities;
    create or replace package body cust_fnd_utilities as
    procedure send_email(     p_sender     in     varchar2,
                   p_recipient      in      varchar2,
                   p_subject     in     varchar2,
                   p_message     in     varchar2)
    is
    v_mail_host     varchar2(30);
    v_crlf      constant varchar2(2):= chr(13)||chr(10);
    v_message     varchar2(10000);
    v_mail_conn     utl_smtp.connection;
    begin
    v_mail_host := 'localhost';
    v_mail_conn := utl_smtp.open_connection(v_mail_host, 25);
    v_message :=      'Date: ' ||
         to_char(sysdate, 'dd Mon yy hh24:mi:ss') || v_crlf ||
         'From: <'|| p_sender ||'>' || v_crlf ||
         'Subject: '|| p_subject || v_crlf ||
         'To: '||p_recipient || v_crlf || '' || v_crlf || p_message;
    utl_smtp.ehlo(v_mail_conn, v_mail_host);
    utl_smtp.mail(v_mail_conn, p_sender);
    utl_smtp.rcpt(v_mail_conn, p_recipient);
    utl_smtp.data(v_mail_conn, v_message);
    utl_smtp.quit(v_mail_conn);
    exception
    when others then
         utl_smtp.close_connection(v_mail_conn);
    end send_email;
    end cust_fnd_utilities;
    2) Build the email, then call the package from step #1. Sample code:
    create or replace package cust_fnd_monitoring as
    procedure profile_options_build_email (     p_errbuf     out     varchar2,
                             p_retcode     out     varchar2,
                             p_sender     in     varchar2,
                             p_recipient     in     varchar2);                         
    end cust_fnd_monitoring;
    create or replace package body cust_fnd_monitoring as
    procedure profile_options_build_email (     p_errbuf     out     varchar2,
                             p_retcode     out     varchar2,
                             p_sender     in     varchar2,
                             p_recipient     in     varchar2)
    is
    v_subject          varchar2(100) := 'erpgamd1 - Recent Profile Option Changes';
    v_mime_type          varchar2(100) := 'Content-Type: text/html';
    v_body               varchar2(10000);
    v_line_feed          varchar2(1):=chr(10);
    cursor profile_cur is
    select     p.user_profile_option_name,
         u.user_name,
         u.description,
         r.responsibility_name,
         v.last_update_date
    from     fnd_profile_option_values v,
         fnd_profile_options_vl p,
         fnd_user u,
         fnd_responsibility_vl r
    where     p.application_id = v.application_id
    and     p.profile_option_id = v.profile_option_id
    and     v.last_updated_by = u.user_id
    and     v.level_id = 10003
    and     v.level_value = r.responsibility_id
    and      v.level_value_application_id = r.application_id
    and     r.creation_date <= '01-NOV-2010'
    and     v.last_update_date >= sysdate-7
    and     u.user_name != '204020779'
    union all
    select     p.user_profile_option_name,
         u.user_name,
         u.description,
         'Site' responsibility_name,
         v.last_update_date
    from     fnd_profile_option_values v,
         fnd_profile_options_vl p,
         fnd_user u
    where     p.application_id = v.application_id
    and     p.profile_option_id = v.profile_option_id
    and     v.last_updated_by = u.user_id
    and     v.level_id = 10001
    and     v.last_update_date >= sysdate-7
    and     u.user_name != '204020779'
    order by 5 desc,4;
    profile_rec     profile_cur%rowtype;
    begin
    open profile_cur;
    <<profile_loop>>
    loop
         fetch profile_cur into profile_rec;
         exit when profile_cur%notfound;
         if profile_cur%rowcount = 1 then
         -- We need to confirm that we fetch at least one row. Once we have confirmed, we want to generate
         -- the email body heading only during the first pass through the loop.
              v_body := '<html>' || v_line_feed;
              v_body := v_body || '<body style="font-family:arial;font-size:10pt">' || v_line_feed || v_line_feed;
              v_body := v_body || '<table cellspacing="5">' || v_line_feed;
              -- table heading
              v_body := v_body || '<tr>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>profile option name</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>responsibility name</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>last update date</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>SSO #</u></td>' || v_line_feed;
              v_body := v_body || '<td align="left"><u>user name</u></td>' || v_line_feed;
              v_body := v_body || '</tr>' || v_line_feed;
         end if;
         -- table detail
         v_body := v_body || '<tr>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.user_profile_option_name      || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.responsibility_name          || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.last_update_date          || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.user_name                || '</td>' || v_line_feed;
         v_body := v_body || '<td>' || profile_rec.description               || '</td>' || v_line_feed;
         v_body := v_body || '</tr>'|| v_line_feed;
    end loop profile_loop;
    if profile_cur%rowcount =0 then
         -- The cursor fetched no rows.
         -- send email using utl_smtp
         cust_fnd_utilities.send_email(p_sender,p_recipient,v_subject || '. No exceptions found.','No exceptions found.');
    else
         -- Generate the end of the email body if we fetched at least one row.
         v_body := v_body || '<table>' || v_line_feed || v_line_feed;
         v_body := v_body || v_line_feed || '</body>' || v_line_feed;
         v_body := v_body || '</html>' || v_line_feed;
         -- send email using utl_smtp
         cust_fnd_utilities.send_email(p_sender,p_recipient,v_subject || v_line_feed || v_mime_type,v_body);
    end if;
    close profile_cur;
    end profile_options_build_email;
    end cust_fnd_monitoring;
    3) In your alert, do not use an email action. Rather, your action should be a SQL*Plus script that calls the package from step #2.

Maybe you are looking for

  • I have deleted my hard drive and know i can't plug my ipod

    As the title says, i have lost all my data in my extarnal hard drive and all my music, pics and video were in it! so now i can't plug my ipod cuz i'm affraid that i will lose all my music! 14 Giga is not easy. is there anyway to copy all my music fro

  • I need to get an i7 late2011 logic board

    My macbook pro 13" is having a fault with the logic board so I need to replace it and I wanna know where I can get a cheap and durable one. it's a 2.8GHz. Thanks.

  • SaxParser error  parsing xml encoded string

    I'm trying to parse an XML string with Java's SaxParser. The program fails at the end of an element or at the beginning of a new element. Is my XML string okay? <?xml version="1.0" encoding="utf-8" ?><DTYPE>OVL</DTYPE><DTYPE>IMG</DTYPE>. . . If fails

  • Help!!! Photos not backed up and just all got deleted!!! iPhone 5s, what do I do???

    Help! Just lost my boyfriend and all my photos of us were on the phone! Also I've never plugged it into a laptop so they weren't backed up ANYWHERE

  • Reconnected sequence clips just repeat ove

    Good evening all After losing the original media for a multi layered sequence due to a firewire drive crash I am recapturing and reconnecting the media to the sequence clips. I was experiencing some success although I am now experiencing a quirky pro