Sign Up

ā‡ļø OrclQA.Com is a question and answer forum for programmers.
ā‡ļø Here anyone can ask questions and anyone can answer to help others.
ā‡ļø It hardly takes a minute to sign up and it is 100% FREE.

Have an account? Sign In


Have an account? Sign In Now

Sign In


Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.


Have an account? Sign In Now

Sorry, you do not have a permission to ask a question, You must login to ask question.


Forgot Password?

Need An Account, Sign Up Here
Sign InSign Up

Oracle APEX Tutorials & Forum

Oracle APEX Tutorials & Forum Logo Oracle APEX Tutorials & Forum Logo

Oracle APEX Tutorials & Forum Navigation

  • Home
  • Oracle Apex
  • PL/SQL
  • SQL
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Ask Question
  • Write a Tutorial
  • Tools
    • Oracle Table Script Generator
    • PL/SQL Package Generator
  • Users
  • Tags
  • FAQs
  • Badges
  • Home
  • Oracle Apex
  • PL/SQL
  • SQL
Greg
Greg

Greg

  • 8 Questions
  • 9 Answers
  • 0 Best Answers
  • 69 Points
View Profile
  • 1
GregProfessional
Asked: November 29, 20202020-11-29T12:14:02+05:30 2020-11-29T12:14:02+05:30

Multiple validations in dynamic action

  • 1

I have a button in my 20.2 apex application and I want it to only run PL/SQL code if two page items both have a value. If I was only checking one page item, I could create a dynamic action with true and false actions based on an ITEM IS NOT NULL condition. How do I extend this to validating 2 items, each with a separate error message.

apex
  • 5
  • 1k
  • 0
  • 0
  • Share
    • Share on Facebook
    • Share on Twitter
    • Share on LinkedIn
Answer

5 Answers

  1. afzal

    afzal

    • India
    • 1 Question
    • 50 Answers
    • 3 Best Answers
    • 319 Points
    View Profile
    afzal Guru
    2020-11-30T11:47:16+05:30Added an answer on November 30, 2020 at 11:47 am

    suppose your item is p1_item1, p1_item2
    validation-- PL/SQL Function Body Returning Error Text

    begin
    if :p1_item1 is null and :p1_item2 is null then
    return 'both item should not empty';
    elsif :p1_item1 is null and :p1_item2 is not null then
    return 'p1_item1 should not empty';
    elsif :p1_item2 is null and :p1_item1 is not null then
    return 'p1_item2 should not empty';
    end if;
    end;
    ---replace error message as your requirement
    Always Execute===> yes

    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • Greg

      Greg

      • 8 Questions
      • 9 Answers
      • 0 Best Answers
      • 69 Points
      View Profile
      Greg Professional
      2020-12-01T10:05:17+05:30Replied to answer on December 1, 2020 at 10:05 am
      This answer was edited.

      Looking around, I see that you mean to add a page-level validation which validates 2 items.

      I have 2 buttons. One button requires only one field to be filled. The other requires both fields. Would it not be better for each field to validate itself, with the validation code dependant on the button pressed? If so, how do I know which button was pressed?

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
  2. afzal

    afzal

    • India
    • 1 Question
    • 50 Answers
    • 3 Best Answers
    • 319 Points
    View Profile
    afzal Guru
    2020-12-01T10:19:43+05:30Added an answer on December 1, 2020 at 10:19 am

    create validationĀ  as show in below

    • 0
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
    • Greg

      Greg

      • 8 Questions
      • 9 Answers
      • 0 Best Answers
      • 69 Points
      View Profile
      Greg Professional
      2020-12-01T16:51:07+05:30Replied to answer on December 1, 2020 at 4:51 pm
      This answer was edited.

      The image is too low-resolution to read properly, but I think I have worked out what you are saying. In the Processes tab, I can create a validation routine which is only applied when a specific button is pressed. I can therefore create a validation routine for each button.

      Thanks.

      • 0
      • Share
        Share
        • Share on Facebook
        • Share on Twitter
      • Greg

        Greg

        • 8 Questions
        • 9 Answers
        • 0 Best Answers
        • 69 Points
        View Profile
        Greg Professional
        2020-12-04T05:40:21+05:30Replied to answer on December 4, 2020 at 5:40 am
        This answer was edited.

        I finally got around to trying this but it still did not work. I think the problem is I am not submitting the page, but issuing explicit PL/SQL code to update the database. I have now tried 2 other options posted by Vinnish (Oracle Apex Validation Without Submit Using JavaScript and Ajax Callback) but they did not provide joy either.

        The current situation (using Vinnish's AJAX method) is that the buttons return an error message saying that it cannot insert the record with a null value for such and such column (standard ORACLE error message), THENĀ  it displays the user-friendly error message, even though the actions generate the user-friendly message before it tries to insert the record.

        The first action reads as follows:
        apex.server.process('validate_comment',
        {
        pageItems : '#P11_NEW_POST, #P11_SELECTED_NODE'
        }
        ,
        {
        dataType : 'text', success : function(data)
        {
        if(data != 'SUCCESS') apex.message.alert(data);
        }
        }
        )

        The second action performs the insert.

        How do I get the first action to abort on error?

        Postscript: I have made this work by changing the INSERT code so it only attempts an INSERT if the 2 items are not null. That way, I only get to see the user-friendly error message.

        Is there a neater way of doing this?

        • 1
        • Share
          Share
          • Share on Facebook
          • Share on Twitter

You must login to can add an answer.


Forgot Password?

Sidebar

Explore

  • Ask Question
  • Write a Tutorial
  • Tools
    • Oracle Table Script Generator
    • PL/SQL Package Generator
  • Users
  • Tags
  • FAQs
  • Badges

Creative Commons License
This work is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
© 2022 OrclQA.Com. All Rights Reserved.
Privacy Policy - About Us