DB procedure validation versus JAVA method validation

Hi ,
We have an application that is developed with Oracle Forms as well as Java (ADF )
Now since ADF is the newer application, it was told to reduce the development time but provide efficient code. Now with Forms each field validation called a procedure and returned an error.
For example if Name is validated, They have a procedure VALIDATE_NAME proc. Why they have separated this is cause based on different customers and different products, the name validation differs. So the in parameters are Field val, Product, customertype... etc. Like this, there are 20 VALIDATE_FIELD procedures for respective fields.
Now to reduce duplication, I can call each procedure on each field. but that would means 20 DB additional calls for each procedure. If I write this logic in java it means I increase development time and probably increase probability of error.
Which is the best practice for VALIDATION.

Hi,
you already mentioned the pros and cons of the approaches. I don't think that it is good practice to directly call the PLSQL validation from Java as it means you wont be able to change it easily in the future. I would look for an abstraction layer that initially (for the time being) accesses the database for validation (maybe caching some validation policies upon application instance start) and later then can be changed to use pure Java validation rules. One thing coming to my mind would be something like a rules engine that reads the validation conditions from the database and that is accessed from Java. If your manager says you should reduce development time then my impression is that the choice is not yours and you will have to use the database (though it feels wrong).
Frank

Similar Messages

  • Calling Java Methods from Stored Procedures

    Can I call Java Methods from Oracle Stored Procedures? I have a Java framework that logs events and would like to reuse it for logging events that occur in stored procedures.
    null

    You need to publish java class methods to plsql.
    Attached below is some information.
    Although both PL/SQL modules and Java classes are stored in the database
    and are managed by many of the same mechanisms, each of them resides in
    its own namespace. Therefore, Java methods are not accessible from SQL
    and PL/SQL by default. In order to expose Java methods to the SQL and
    PL/SQL engines, first publish that Java method to the SQL namespace using
    a 'Call Spec'.
    Note: A 'Call Spec' does not create an additional layer of
    execution so there is no performance penalty incurred.
    A 'Call Spec' is simply a syntactical mechanism used to
    make a method known in the SQL namespace.
    The SQL name established by the 'Call Spec' can be top-level or packaged.
    The syntax differs only slightly and is consistent with that used for
    PL/SQL procedures and packages. For more information on the exact
    syntax, see the references listed in 'Related Topics'.
    In general, a top-level procedure 'Call Spec' takes the form:
    CREATE OR REPLACE PROCEDURE procname ( pname mode ptype, ... )
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... )';
    Where: procname is the SQL name you wish to publish
    pname is the name for a parameter to procname
    mode is the parameter mode (i.e. IN, OUT, IN OUT)
    ptype is a valid SQL type (e.g. NUMBER, CHAR, etc.)
    javaname is the fully qualified name of the Java method
    javatype is a Java type for the corresponding parameter
    Likewise, a top-level function 'Call Spec' takes the form:
    CREATE OR REPLACE FUNCTION fname ( pname mode ptype, ... ) RETURN rtype
    AS LANGUAGE JAVA NAME 'javaname ( javatype, ... ) return javatype';
    Where: fname is the SQL name you wish to publish
    rtype is the SQL return type of the function
    Note: Within the NAME clause, everything within quotes is case
    sensitive. For example, if the keyword 'return' is in all
    CAPS, this Call Spec will not compile.
    Other optional parts of this syntax have been omitted here for simplicity.
    Additional examples in subsequent sections illustrate some of these options.
    eg
    CREATE PROCEDURE MyProc (rowcnt IN NUMBER, numrows OUT NUMBER)
    AS LANGUAGE JAVA NAME 'MyClass.MyMethod(int, int[])';
    There are several important things to note here:
    1.) The 'Call Spec' for a JSP must be created in the same schema as the
    corresponding Java class that implements that method.
    2.) IN parameters are passed by value. This is the only parameter mode
    available in Java. OUT parameters, therefore, must be passed as single
    element arrays in order to emulate pass by reference.
    3.) Parameter names do not need to match, but the number and types of
    the parameters must match (with just one exception - see item 5 below).
    Oracle 8i supports conversions between an assortment of SQL and Java.
    See the references listed in 'Related Topics' for additional information.
    4.) Primitive types (e.g. int, float, etc.) are not required to be fully
    qualified with any package name. However, standard Java object types
    (e.g. String, Integer, etc.) as well as any user defined object types
    (e.g. like those generated by JPublisher) must be prefixed with a
    corresponding package name (e.g. java.lang) if applicable.
    5.) The 'main' method which takes a single String[] parameter can be
    mapped to any PL/SQL procedure or function which takes some number
    of VARCHAR2 or CHAR type IN parameters. For example, the java method:
    public static void main ( String[] args ) { ... }
    can be mapped to each of the following:
    PROCEDURE MyProc2 ( arg1 IN CHAR ) ...
    PROCEDURE MyProc3 ( arg1 IN CHAR, arg2 IN VARCHAR2 ) ...
    PROCEDURE MyProc4 ( arg1 IN VARCHAR2, arg2 IN VARCHAR2 ) ...
    and so forth. Parameters map to the corresponding element of the String
    array (e.g. arg1 -> args[0], arg2 -> args[1], etc.).
    null

  • Java Mapping (Validation)

    Hi Guys
    Validations using Java for those not having PI7.1
    I followed this blog for validation of XML.
    I have coded the JAVA Program in NWDS as per the blog, all fine but am not sure about the schema step.
    What i did was:
    1) Exported the .xsd of the Message type.
    2) Then Schema.xml file creation i am not sure of it
    Do any one know how to do that , and what is the purpouse of the Schema method in the Java Mapping.
    Is this blog does a input initerface format check and write in to a log.
    But cannot we do this with the help of Alert by triggering mails ??
    Can we achieve element level vaslidation (to all element of the XML) using this method.
    Kindly share u r views
    Srini

    Hi Santosh,
    Thx for u r reply.
    I understood what u r saying .
    One more question :
    See u r Doc is validating particular element , date and time using api.All good, what if i need to validate entire XML Elements , should i repeat the same for entire element.
    i was so curious with his blog because , it was generic and moreover i thought i can validate entire XML , by not sticking to particular element.
    What is IA ?? U Memtioned ??
    Could above requirment can be achieverd r else i should get each element and validate , no other go
    based upon on the outbound interface
    regards
    srini

  • Method Validator based on two columns

    Hi,
    I have a table called FndCities with attributes city_id (pk), country_id (fk) and city_name.
    I want to check if a city name is unique for a certain country. For example England can have a city name called "London", but USA might have a city called "London". However neither England not USA can have two "London" cities.
    I have implemented a custom method validator and here is the logic:
    In the FndCitiesImpl.java i created the following method:
    public boolean validateCityName(String data) {
    FndCitiesDefImpl entityDef = (FndCitiesDefImpl)getDefinitionObject();
    String originalValue = (String)getPostedAttribute(CITYNAME);
    Number originalValuePk = (Number)getPostedAttribute(COUNTRYPKFK);
    if (data != null && !data.equalsIgnoreCase(originalValue)) {
    return !(entityDef.existsByCityName(getDBTransaction(),data, originalValuePk));
    return true;
    and in the FndCitiesDefImpl.java i have implemented the method existsByCityName(DBTransaction, city_name, country_id).
    In the creation method my custom validation works fine, however when i edit a record, becuase the if statement watches for changes in the city name, when changing the Country the validation is not performed. I cannot the country id in the validateCityName method because validation is performed on one column.
    How can i achieve this?
    Thanks
    Antonis

    Hi Antonis,
    Not sure what you mean again by "JDeveloper does not handle the constraints properly." I have exactly this situation in my application (JDev 10.1.3.1), and I am using a database constraint to enforce uniqueness across 2 columns. I've customized the error messages (see Re: Unique key existence check and ER: ADF BC - allow custom error msgs for common exceptions (e.g. DML) ). Works just dandy.
    John

  • Calling method validator from EO to another EO

    Hi, I am usning JDEV 11.1.16.0
    I have two EOs Person and PersonJob
    there is an association created PersonEOTOPersonJob
    In my PersonJobEO I have a method validator which calls a method in my PersonJobEOImpl.java where i am doing some validation.
    Now the problem is that when I am trying to modify one attribute in my PersonEO and not modifying anything in PersonJobEO, I need the call the same method validator from PersonJObEO.
    I don't want to make my PersonJobEO row dirty just to call the method validator in PersonJobEO.
    Is there a way to call the PersonJobEo method validator whenever my PersonEo becomes dirty or a particular attribute, say person status is update
    I have tried below code which did not help me
    public void validatePersonJobEntity(){
    RowIterator relationsRows = getPersonJobEO();
    EntityImpl relEntityRow;
    while(relationsRows.hasNext()){
    relEntityRow = (EntityImpl)relationsRows.next();
    relEntityRow.validateEntity();
    }

    Hi ,
    Let me try to explain more clearly with an example
    In PersonEO I have an attribute called status, which is an LOV and accepts values "active" and "inactive"
    In PersonJObEO I have a method validator named ValidateDuplicateRowbyDate(), which checks for duplicate jobs based on start, end date for "active" persons.
    I have given the definition for ValidateDuplicateRowbyDate in my PersonJobEOImpl.java
    eg
    class PersonJobEOImpl{
    //other code
    public void ValidateDuplicateRowbyDate(Arraylist ctx){
    //Logic to check for duplicate jobs based on start and end date for active Person
    As per the above logic duplicates are allowed for inactive user.
    Now when someone updates the inactive status to active for a person without touching the PersonJob data. I need to fire same validation.
    The PersonJobEo validation is not fired as it is not dirty. I need to call the PersonJobEO validation whenever personStatus is updated
    eg.
    Scenario 1
    PersonEO
    Person_id person_name status
    1001 John active
    PersonJobEO
    JobId person_id Job_name start_date end_date
    2001 1001 Sales 5/4/2010 5/10/2011
    2002 1002 Service 5/4/2010 5/10/2011(This is invalid two rows with same start and end date is not allowed)
    Scenario 2
    PersonEO
    Person_id person_name status
    1002 SAM inactive
    PersonJobEO
    JobId person_id Job_name start_date end_date
    2003 1001 Sales 5/4/2010 5/10/2011
    2004 1002 Service 5/4/2010 5/10/2011(allowed as person status is in active)
    Scenario 3
    When status for person_id 1002(SAM) is updated to active from inactive i need to perform the validation on PersonJobEO and i should not allow the status to be updated
    here i want to trigger validation ValidateDuplicateRowbyDate in PersonJobEO

  • Problem with XSD validation in Java 5

    Hi everyone,
    my application creates in memory schema using JDOM. In Java 6 validation runs fine, but in Java 5 (which is the target platform currently) it fails.
    I tried a second test with just parsing an existing XSD document (not created using JDOM) and that works.
    The textual representation of both (file and JDOM generated) are identical. If I replace the XSD file with the JDOM output, the "file test" runs fine, too.
    Here's the test code:
        protected void assertXsdValid(Source xsdSource, InputSource xmlInputSource) throws SAXException, ParserConfigurationException, IOException {
            isValid = true;
            SchemaFactory sf = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI);
            sf.setErrorHandler(myErrorHandler);
            Schema schema = sf.newSchema(xsdSource); // <<--------- THIS LINE FAILS IN JAVA 5
            DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
            dbf.setNamespaceAware(true);
            dbf.setSchema(schema);
            DocumentBuilder db = dbf.newDocumentBuilder();
            db.setErrorHandler(myErrorHandler);
            db.parse(xmlInputSource);
            assertTrue(isValid);
        }This is the XSD:
    <?xml version="1.0" encoding="UTF-8"?>
    <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" targetNamespace="http://some.org/metamodel" elementFormDefault="qualified">
      <xs:element name="system">
        <xs:complexType>
          <xs:sequence>
            <xs:element name="name" type="xs:string" />
            <xs:element name="vendor" type="xs:string" />
            <xs:element name="version" type="xs:decimal" />
          </xs:sequence>
        </xs:complexType>
      </xs:element>
    </xs:schema>This is the error message I get:
    ERROR: org.xml.sax.SAXParseException: s4s-att-invalid-value: Invalid attribute value for 'type' in element 'element'. Recorded reason: UndeclaredPrefix: Cannot resolve 'xs:string' as a QName: the prefix 'xs' is not declared.
    This is how I call the test code in the JDOM test:
            assertXsdValid(new JDOMSource(xsdDoc), new JDOMSource(xmlDoc).getInputSource());If I change the code to parsing not the JDOMSource, but a StreamSource reading the textual representation of the XSD, it works fine!
            assertXsdValid(new StreamSource(new ByteArrayInputStream(new XMLOutputter().outputString(xsdDoc).getBytes())), new JDOMSource(xmlDoc).getInputSource());But this is not what I want (I expect suboptimal performance with large XSD documents). So, if it works with Java 6, then why doesn't it work with Java 5?
    How can I use the Java 6 JAXP in Java 5?
    Thank you.

    A new user name?
    I can think of ways round your problem but can you first provide a reference that indicates that byte 0x80 is the MS936 encoding for the Euro?
    P.S. This is a forum and the vast majority of participants, including me, have no direct relationship with Oracle so getting definitive answers from Oracle via this forum is unlikely. If you think you have found a bug in 1.5 and/or 1.6, and I am not convinced you have, you need to report it via the bug database. If it is a bug then the response time for a fix is likely to be months rather than days.
    P.P.S No I can't explain why it works in 1.7!

  • How to call a java method in a Stored procedure

    Hi.,
    I was trying to call a method in a stored procedure
    This was my procedure
    CREATE OR REPLACE PROCEDURE proc_copy_file(sr_file VARCHAR2,dt_file VARCHAR2)
    AS LANGUAGE JAVA
    NAME 'FileCopy.copyfile(String,String)'; // calling a java method
    /   this was my java method
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "FileCopy" as
    import java.io.File;
      import java.io.IOException;
      import java.io.FileReader;
      import java.io.FileWriter;
      import javax.imageio.stream.FileImageInputStream;
      import javax.imageio.stream.FileImageOutputStream;
      import java.security.AccessControlException;
      public class FileCopy {
          // Define variable(s).
              private static int c;
              private static File file1,file2;
              private static FileReader inTextFile;
              private static FileWriter outTextFile;
              private static FileImageInputStream inImageFile;
              private static FileImageOutputStream outImageFile;
              // Define copyText() method.
              public static void copyfile(String fromFile,String toFile) throws AccessControlException
                // Create files from canonical file names.
                file1 = new File(fromFile);
                file2 = new File(toFile);
                // Copy file(s).
                try
                  // Define and initialize FileReader(s).
                  inTextFile  = new FileReader(file1);
                  outTextFile = new FileWriter(file2);
                  // Read character-by-character.
                  while ((c = inTextFile.read()) != -1) {
                    outTextFile.write(c); }
                  // Close Stream(s).
                  inTextFile.close();
                  outTextFile.close(); }
                catch (IOException e) {
                  System.out.println ("-------"); }
             // return 1;
          public static void main(String[] args){
                          switch(args.length){
                                  case 0: System.out.println("File has not mentioned.");
                                                  System.exit(0);
                                  case 1: System.out.println("Destination file has not mentioned.");
                                                  System.exit(0);
                                  case 2: copyfile(args[0],args[1]);
                                                  System.exit(0);
                                  default : System.out.println("Multiple files are not allow.");
                                                    System.exit(0);
    };while i am executing this method i m getting error as
    ORA-29531: NO METHOD COPYFILE IN CLASS FILECOPY
    ORA-06512: AT "RMVER721.PROC_COPY_FILE", LINE 1could anyone help me

    Looks like it is a matter of not quite the same namespace for String object.
    I can get it to work by the java source containing:
              public static void copyfile(java.lang.String fromFile,java.lang.String toFile) throws AccessControlExceptionAnd the PL/SQL source:
    NAME 'FileCopy.copyfile(java.lang.String,java.lang.String)'; // calling a java methodSeems like when you just use "String", then the namespace resolving in the java source is not the same as the namespace resolving in the PL/SQL?
    Addendum:
    You do not need to put java.lang.String in the java source, String will do (java.lang is by default "imported"?)
    But in the PL/SQL source java.lang namespace prefix is needed - java.lang is not "imported" here.
    Edited by: Kim Berg Hansen on Nov 23, 2011 1:07 PM

  • How to write validation in java sript item should not allow more than 20 ch

    HI,
    I need to write validation in java script for a item it should not allow more than 20 characters.
    Thanks
    Nr

    If this answers your question, please mark your question as answered (so everyone knows it is answered) and assign points where you see fit..
    Thank you,
    Tony Miller
    Webster, TX

  • DOM validation using Java is extremely slow

    I have a large XML file ~8MB. When I do validation on it using java api, takes ~5 hours to process it.
    I have narrowed down the problem to xs:unique rules in the schema file. When I remove these rules, validation takes ~1 min.
    I have tried using MSXML parser with unique rules and it take about 30 min.
    My question is how could I speed up the validation in Java with these unique rules in the schema.
    Any help will be greatly appreciated.
    Thanks.

    Basically, you are saying removing the unique elements
    from schema and do the checking myself. This means
    everytime the schema is updated with new unique rules,
    I will have to modify the code to check for unique
    elements.
    Is there any other way to tackle this problem?You can choose what processing is done with the XML parser, and what is done within java, if you control the schema. Uniqueness is one that I have preferred to perform in java, since I often perform other validations in java anyway, and it works well. Just my opinion.
    If you post some XML/XSD code and list the parser you are using, someone that uses xs:unique may find something they can help you with.
    -Scott

  • ItemDetails WD Java - External Validation

    Hi,
    Has anyone used WD JAVA External Validation with Taxonomy table?
    Everything is ok with plain tables, but when I assign WdCompsUserExits to ItemDetails Component connected with taxonomy table, I have an error: "Illegal field [Parent] found in XSD document. ."
    As I understand, WD component is trying to convert data record to xml which has to be passed into UserExit class but cannot process field [Parent].
    So, is it possible to use "External Validation" with taxonomy tables?

    Timur Semenchuk wrote:
    > We are trying to reproduce the issue creating a new components based on custom validation, but we are still without any success.
    > Have you reproduced the issue with a new DC?
    Do you mean that this issue has only appered in one DC, while with newaly created everything is ok?
    I hasn't checked this with other DCs... We have some serious system landscape changes going on, so there is no chance to test anything right now.

  • Range Validation in Java

    Hi,
    I am having a doubt in Range Validation
    I having the following as input, i will maintain a Default Values,
    StartId, EndId as Constant in my program
    Example :
    StartID= "0000000" Format will be "XXXXXXX"
    EndID = "0000100" Format will be "XXXXXXX"
    From the UI, i will have the option to enter a text. If the User has to enter the same Format "XXXXXXX", the format validation I performed using reg Expression,
    I need to perform the Range validation here, if the user Enters value say
    "0000700" < it is not within the StartId & EndId Range, then i need to say Error.
    How can i perform Range Validation in java.?
    Any Ideas please..

    It can be done with regexp but it's probably easier to parse the start and end ids and the entered value into integers and perform the validation using a normal if statement.

  • Specify multiple error messages in a Method Validator

    Is there a way I can specify multiple error messages in a Method validator?

    I am not sure if you want something like highlighting the components which have errors -
    If yes , then try this code bit
    public void addMessage(UIComponent component, FacesMessage.Severity type,
    String message) {
    FacesContext fctx = FacesContext.getCurrentInstance();
    FacesMessage fm = new FacesMessage(type, message, null);
    fctx.addMessage(component.getClientId(fctx), fm);
    You can call the method like this addMessage(this.componentName,FacesMessage.SEVERITY_ERROR,ErroMessage)
    -Sudipto

  • Programatically change the error message thrown by ADF Method validator

    Can I change an error message being displayed by an ADF Method Validator?
    The message of the method validator can be specified declaratively using the Wizard. But is there anyway I can programatically change it inside the body of the method validator?
    Inside a method validator i will check for about 5 conditions and each condition will have a separate error message to reflect the error correctly. I can't use a single message declared by the wizard.
    regards,
    Anton

    Hi,
    I think you should look at the follow links, hope they can
    help you
    http://blogs.technet.com/b/nexthop/archive/2013/02/19/using-iis-arr-as-a-reverse-proxy-for-lync-server-2013.aspx
    #Troubleshooting a 404.13 issue using IIS and Failed Request Tracing logs
    http://blogs.msdn.com/b/amb/archive/2012/10/10/troubleshooting-a-404-13-issue-using-iis-and-failed-request-tracing-logs.aspx

  • Error in TextField Validation Widget reset() method

    There appears to be an error in the Textfield Validation
    Widget's reset() method. When I set the widget to "real" or
    "custom" validation, the reset() method is throwing an error when
    it reaches the line "this.oldValue = this.input.defaultValue;"
    I seached the code and it appears that
    "this.input.defaultValue" is not set anywhere else. Is there a
    missing option, or is this line incorrect and copied over from
    another widget that uses "defaultValue"?

    It looks as though you're trying to use main-content as a CSS selector. If it's a class, it should begin with a dot (period) like this:
    .main-content
    If it's an ID selector, it should begin with a hash:
    #main-content

  • Method Validator is not displaying Error Messages

    Hi!
    I'm using JDeveloper 10.1.3.1.0. I have to validate the value of a particular field in a form, and I've done this via method validator on my Entity Object. If the validation succeeds, I return true; otherwise, I return false as specified in the documentation. The issue is that the error message I added via the wizard is not appearing when my code returns false. I debugged my application and verified that my test case did indeed fail validation and return a false value, but no error message appeared. Furthermore, I tried raising a JboException in this validation code, and it too didn't appear.
    However, when I placed my validation code in the setXXX method of the attribute I was validating, the JboException message was displayed.
    Given that the ADF manual is encouraging developers to place validation code in method validators, I found it strange that any excpetions thrown by method validators colud not displayed.
    Can anyone help clarify this behavior?
    Thanks!
    Rey

    Rey,
    What view technology are you using (JSF, Swing, etc)? If you are using ADF Faces, do you have an af:messages component on the page?
    Regards,
    John

Maybe you are looking for

  • Error on HSU_OUTPUT dir when using Headstart Utilities

    Hi all, Does anyone have experience with the following problem: when I try to run the Headstart Utilities - Quality checks (elements) - Functions check, I get the following error: "Could not create file, possibly because output-directory does not exi

  • Re: keychain:What does this mean and how do I fix it if I've made mistakes?

    I've reinstalled some programs and gotten this message box. Changes get made to things like .mac email and I get this message box. The wording in the box is a yes or no question - Do you want to have this program use the same settings (or whatever th

  • How to unblock item in contract - ME32K

    Hello, I don't know how to unblock item in contract using ME32K. I block contract item using menu appered after pressing right button of mouse. Could anybody help me ? Kind Regards, Zbigniew Debowski

  • Exception connecting to MS Access Database.

    I'm having problems using the jdbc-odbc bridge with an MS Access database and a file DSN. If I use a system DSN, it works fine but it does not seem to find the file DSN for some reason (And I HAVE to use a file DSN in this instance, for reasons I won

  • Merge/Concat Multiple Columns in a Flat-File wthin ODI

    Hi, I was wondering if there is a quick way to merge/concat multiple columns in a Flat-File from within ODI, a functionality kinda similar to Essbase load rule files for join/split columns etc. Please let me know. Thanks