Forum Stats

  • 3,836,988 Users
  • 2,262,215 Discussions
  • 7,900,171 Comments

Discussions

Validate Stored Procedure Input

ChristianM0147
ChristianM0147 Member Posts: 35 Red Ribbon
edited Jun 2, 2022 6:28AM in JDeveloper and ADF

Hello fellow ADF Programmers

I´m currently working with JDeveloper Version 12.2.1.4.0.

My Scenario: I created a Methode in my AppModuleImpl.java that calls a procedure in my Database. I exposed this Method to the Client so i can use the DataControl on my page. The procedure/Method takes a *ID as an Input Parameter. My procedure does this: INSERT INTO X Select * FROM Y WHERE Y.ID = *ID.

I now want to implement a validation of the input field (*ID). I want to check if the data of *ID is already inserted in table X and if so... show some validation error the button on my .jsf page. Whats the best way to do this?

Should i just extend the method in my AppModule with: Select 1 from X where id = *ID and then throw a ValidatorException if the select returns something?

Tagged:

Best Answer

  • Karl Karanjia-Oracle
    Karl Karanjia-Oracle Member Posts: 1 Employee
    Answer ✓

    Hi ChristianM0147,

    Since it is a procedure you could execute the check in the procedure itself and only if the record exists , execute the insert statement. Have the procedure return a value to the AppModuleImpl through OUT Parameter indicating what action was performed.

    you could also execute the insert directly and handle the exception in the AppModuleImpl.

Answers

  • Karl Karanjia-Oracle
    Karl Karanjia-Oracle Member Posts: 1 Employee
    Answer ✓

    Hi ChristianM0147,

    Since it is a procedure you could execute the check in the procedure itself and only if the record exists , execute the insert statement. Have the procedure return a value to the AppModuleImpl through OUT Parameter indicating what action was performed.

    you could also execute the insert directly and handle the exception in the AppModuleImpl.