Straw poll: use of triggers to enforce data format rules.

For a while now I have used before insert triggers to enforce data formatting rules, such as applying UPPER to certain fields. This is a habit I picked up in the mists of time, and never really thought about before...
...until just now, when a colleague questioned the wisdom of this practice, in language too colourful for a family forum like this. So the question is: is this good practice or not?
In the particularly case in point, I could have used (and may yet implement) a foreign key to a reference code table, which would enforce uppercaseness as a side effect. Alternatively I could have used a CHECK CONSTRAINT, but the potential values are too fluid for that.
I am interested in your opinion on the general principle: is it right for the database to enforce formatting without the user being aware of the change?
Thanks in advance.
Cheers, APC

Andrew:
In principle, I would not disagree with enforcing formatting in the database, as long as that formatting is required to satisfy a business requirement (e.g. one of our departments has a business rule that all medications must be stored in upper case, dosage information and frequency must be all lower case).
In your case in point, I would absolutely enforce upper case in the database if you are going to enforce a foreign key. If the code value is stored upper case in the code table, then a trigger to UPPER(code) in the child table is appropriate since an end-user would likely be confused by a constraint violation between 'ABC' and 'abc'. Even if you are not going to enforce the FK, I would assume that you will join to the parent with some frequency, so having both in the same format makes the joins a lot easier.
My argument against a check constraint to enforce upper case would be based on the (hypothetical, but realistic) user thought process of:
"Damm application keeps making me re-type everything, so I'm just going to put the caps lock key on AND SHOUT AT THE DATABASE".
Having said that, if you are just enforcing upper case to get case insensitive searches, then function based indexes get around that problem without forcing formatting.
My $0.02 CDN (about a ha'penny)
John
P.S. You may want to get a better class of colleague.

Similar Messages

  • Acrobat 9.3.4 doesn't enforce Date Formating

    After we upgraded to Acrobat 9.3.4 from a previous version of 9.3 acrobat doesn't enforce date formating..before in a Text field formated as Date mm/dd/yyyy it would autocompelete if we typed in 9/21 to 9/21/2010.. now it doesn't, we can type any random text in the field and it isn't validated.
    Ideas?

    Just checked, its enabled.. when I say validate I'm referring to Acrobat's internal date format validation, not JavaScript.
    For example if you create a text box, goto properties, format tab, format category = date, date options mm/dd/yyyy
    now if you type:
    "abcdef" in that text box it should say, "Invalid Date/time: please ensure that the date/time exists.
    if you type 9/21 it will automatically turn it into 9/21/2010.
    After Appling the 9.3.4 update no such validation takes place, any value entered is accepted..

  • BC4J Query by example for dates uses wrong date format

    When querying by example on date fields, I get the following nested exceptions:
    oracle.jbo.SQLStmtException: JBO-27121: SQL error during statement execution.
    JBO-26044: Error while getting estimated row count for view object
    and
    java.sql.SQLException: ORA-01830: date format picture ends before converting entire input string.
    It would seem to be caused by the following clause added to the end of the entity object's query:
    "QRSLT WHERE ( ( (DATE_FIELD = TO_DATE('23/12/2003', 'yyyy-mm-dd')) ) )"
    which causes problems as our entity objects use a 'dd/MM/yyyy' date format.
    Is there a way we can make the query by example use the same date format as the rest of our app?

    I‘m not an expert on this but I see nobody is replying so this might help you. I've been having problems with dates as well and I‘m pretty sure that the attached formatter isn't used in find mode. That is because the java date class (can't remember which one) used by the BC4J has the format yyyy-mm-dd. I don't now if it is possible to change it but I got around the problem by writing my own domain. You can take a look at Toystore demo, by Steve Muench, that uses a custom date domain, ExpirationDate (see the code below). It is mapped to a VARCHAR column in the database but it is possible to map it to a DATE column.
    I have been watching the postings with questions about dates and I have noticed that a lot of people have problems with this but I haven’t seen an answer yet.
    package toystore.model.datatypes.common;
    import java.io.Serializable;
    import java.text.SimpleDateFormat;
    import java.util.Calendar;
    import java.util.Date;
    import oracle.jbo.Transaction;
    import oracle.jbo.domain.DataCreationException;
    import oracle.jbo.domain.DomainInterface;
    import oracle.jbo.domain.DomainOwnerInterface;
    // --- File generated by Oracle Business Components for Java.
    * This custom datatype implements an immutable domain class that
    * maps to a VARCHAR column containing values like '10/2004' representing
    * expiration dates of credit cards. We could have chosen to implement
    * this as a domain that stores itself in a DATE column instead of a
    * VARCHAR column, but since the Java Pet Store demo schema stored the
    * information in a VARCHAR column, we decided to illustrate how to
    * accommodate that case using domains.
    public class ExpirationDate implements DomainInterface, Serializable {
    private Date mDate;
    private String mDateAsString;
    protected ExpirationDate() {
    mDate = new Date();
    convertDateToStringFormat();
    * Return the value of the expiration date as a java.util.Date
    public Date getDateValue() {
    return mDate;
    * Allow expiration date to be constructed from two
    * strings representing month and year
    public ExpirationDate(String monthVal, String yearVal) {
    this(monthVal+'/'+yearVal);
    public ExpirationDate(String val) {
    validate(val);
    convertDateToStringFormat();
    * The getData() method must return the type of object that JDBC will
    * see for storage in the database. Since we want this ExpirationDate
    * datatype to map to a VARCHAR column in the database, we return the
    * string format of the date
    public Object getData() {
    return mDateAsString;
    * <b>Internal:</b> <em>Applications should not use this method.</em>
    public void setContext(DomainOwnerInterface owner, Transaction trans, Object obj) {
    * Performs basic validation on strings that represent expiration dates
    * in the format of MM/YYYY. Note that in the process of testing whether
    * the string represents a valid month and year, we end up setting
    * the private member variable mDate with the date value, so if the
    * validate() method does not throw an exception, the mDate will be setup.
    protected void validate(String val) {
    if (val != null) {
    if (val.length() != 7 ||
    val.charAt(2) != '/' ||
    !isAllDigitsExceptSlashAtPositionTwo(val) ||
    !isValidMonthAndYear(val)) {
    throw new DataCreationException(ErrorMessages.class,
    ErrorMessages.INVALID_EXPRDATE,
    null,null);
    * Returns true if all digits except position 2 (zero-based) are digits
    private boolean isAllDigitsExceptSlashAtPositionTwo(String val) {
    for (int z=0, max = val.length(); z < max; z++) {
    if (z != 2 && !Character.isDigit(val.charAt(z))) {
    return false;
    return true;
    * Returns true if the val string, assumed to be in "MM/YYYY" format
    * is a valid month and year value, setting the mDate member variable
    * if they are valid.
    private boolean isValidMonthAndYear(String val) {
    try {
    int month = Integer.parseInt(val.substring(0,2));
    int year = Integer.parseInt(val.substring(3));
    Calendar c = Calendar.getInstance();
    c.setLenient(false);
    c.set(year,month-1,1); // Month is zero-based !
    mDate = c.getTime();
    catch (IllegalArgumentException i) {
    return false;
    return true;
    public String toString() {
    return mDateAsString;
    * Convert mDate to String format
    private void convertDateToStringFormat() {
    if (mDate != null) {
    SimpleDateFormat sdf = new SimpleDateFormat("MM/yyyy");
    mDateAsString = sdf.format(mDate);
    * Return true if the expiration date is in the future
    public boolean isFutureDate() {
    return mDate.compareTo(new Date())> 0;
    * Compare the Expiration Dates by comparing their respective
    * getData() values
    public boolean equals(Object obj) {
    if (obj instanceof DomainInterface) {
    Object thisData = getData();
    if (thisData != null) {
    return thisData.equals(((DomainInterface)obj).getData());
    return ((DomainInterface)obj).getData() == null;
    return false;

  • How to change the date format from default to mm-dd-yyyy?

    Hi,
    There is a requirement to show the current date in an error message at the attribute level. That is, if the user input a date in a text field that is earlier than today's date, then an error message must immediately pop up with today's date in the message. To achieve this we are using a token expression in the EO ( Under Validation rules) . The token expression uses adf.currentDate to get today's date.
    The problem is that the expression extracts the date in the form of yyyy-mm-dd. What expression should I use to get the current date format in mm/dd/yyyy ? Can I modify the adf.currentDate expression in some way to get the desired format?
    Thanks,
    Anand

    You could write a custom EO method to return today's date in the specific format. Then access it via the Groovy adf.object expression.

  • Date Format in Forms 4.5

    For all the date fields in my Oracle Forms application i have set
    a date format of dd/mm/yyyy. When entering data if the user does
    not put the date in the above format, forms raises an error. I
    want to be able to let the user enter the date in any format
    and then convert it to the above format.
    Have you seen any reusable scripts that do this? Has anyone
    done this?
    null

    Hi Mala,
    I wasn't sure as to what you meant by any format. Is it like
    being able to enter a 2 digit year instead of a 4 digit year? Or
    is it like being able to enter the day, month, and year in any
    sequence? Try using the DD/MM/RRRR date format in the item
    properties if the problem is just with the four digit year. This
    allows you to enter a 2 digit year and depending on the value it
    decides whether the 4 digit year begins with 19 or 20.
    Hope this helps.
    CV
    Metro Infomation Services.
    Mala (guest) wrote:
    : For all the date fields in my Oracle Forms application i have
    set
    : a date format of dd/mm/yyyy. When entering data if the user
    does
    : not put the date in the above format, forms raises an error. I
    : want to be able to let the user enter the date in any format
    : and then convert it to the above format.
    : Have you seen any reusable scripts that do this? Has anyone
    : done this?
    null

  • Date format in BEx Analyser / PreCalc Server

    Hi All,
    First off, i have read many threads in this forum but none seem to solve our issue. So hopefully somebody will have a fresh view on this.
    When i broadcast a workbook from BEx Broadcaster using a Precalc server, the date format displays as mm/dd/yyyy. We want it in dd/mm/yyyy.
    1. The BI profile (SU01) has the correct date format.
    - When the user runs the query in the portal or through BEx Analyser, the date format is correct.
    2. There isn't any issue with the query / workbook as we can broadcast it through a test pre-calc server and it displays in the correct format.
    3. Many threads have suggested changing the date format in the control panal of the precalc server. Not only have i done this for the logged in user, i've updated all users on the server through the registry. The precalc service is being run under the Local system user and this was one of the entries which i updated as it was still in US format. We tried restarting the service and also rebooting the server. But no change to the date format display. It is still in US format.
    Has anybody any other suggestions for this issue. We want to apply it to all users for all queries if possible.  Should be an easy one but nothing has worked.
    Any suggestions would be appreciated.
    Thanks,
    Georgina

    Hi Ravikanth,
    Thanks for your reply.
    The first option won't work as i'd need it to be in the correct format when broadcast out by email to users in excel format.
    I was hoping that this could be resolved without a custom solution, however the second option sounds like it could work but i have not worked with macros before and i'd imagine you'd need to know what you are doing to modify any of the modules behind the workbooks as it could mess them up.
    If you have any suggestions or resources that you can point me to, that would be great.
    Thanks,
    Georgina

  • How to convert date format in VC 7.0 to DD.MM.YYYY

    Hi
      I am on VC 7.0.
      My requirment is to show Current date as a default value for a input field.
      I am using date function now() as default value...and it is displaying the current date
    08.07.2009 as  Jul 08,2009
    But my requirment is to display it as 08.07.2009
    Please update me how to convert the data format to be displayed as DD.MM.YYYY format
    Thanks

    Hi,
    Use DSTR method to change date format. Check the below link for details.
    http://help.sap.com/saphelp_nw70/helpdata/en/49/032e66f4a4105ee10000000a42189d/frameset.htm
    Regards
    Basheer

  • Date format for MSSQL2000

    Hi,
    I use database MSSQL2000 and UIX application.
    File dateformat_ru.properties :
    dateclass=java.sql.Date
    datetimeclass=java.sql.Timestamp
    datepattern=dd-MM-yyyy or datepattern=dd.MM.yyyy
    datetimepattern=dd-MM-yyyy HH:mm:ss.SSS
    I read record from database = OK. (date = valid)
    After change field date I have error :
    Timestamp format must be yyyy-mm-dd hh:mm:ss.fffffffff
    Help me, please.
    Sorry ... :(
    Nikolay
    New Urengoj, Russia

    Hi, Peter !
    Unfortunately, I hurted some days and could not worked.
    I shall try to state a problem more full.
    1. Version : JDeveloper 10.1.2.0.0 (Build 1811), JHeadStart 10.1.2.0 (Build 19)
    2. I could not create log file for find error and find message "Timestamp format must be " This message is not present in files of the project. In the previous example, I have incorrectly specified a format of date and, therefore, I have received a error "Timestamp format...", sorry :(
    3. I use database MsSql 2000 and date format in this database is "dmy" (day mounth year) as default for russian users. For an example, I used the scheme HR (human resources) and I have created all objects in database MsSql.
    4. Further, I created Business Components from tables. In Employees and EmployeesViews, for field HireDate :
    Entity Attribute -> Type = Date
    Attribute Properties -> Value = dateField
    Control Hints -> Control Type = Date
    Variant 1. In file dateformat_ru.properties
    dateclass=java.sql.Date
    datepattern=dd.MM.yyyy
    After run application I see valid current value HireDate 17.12.1984. (Steven King)
    I changed to 18.12.1984 and ... error :
    java.lang.IllegalArgumentException at java.sql.Date.valueOf(Date.java:103)
    JBO-25009: Cannot create an object of type:java.sql.Date with value:18.12.1984
    Variant 2. In file dateformat_ru.properties
    dateclass=java.sql.Date
    datepattern=dd-MM-yyyy
    Redeploy ... I see valid current value HireDate 17-12-1984
    Change to 18-12-1984, save.
    And after save - > new errors :
    I see HireDate 06-05-0024 and
    [Microsoft][SQLServer 2000 Driver for JDBC]The year, 24, is outside the range allowed by the SQL Server.
    I correctly understand, that it is impossible to use dateclass=java.sql.Date
    for date format "dd-MM-yyyy" or "dd.MM.yyyy" ?
    Class java.sql.Date does not support this format ?
    Prompt, please, a way of the decision of this problem.
    Thanks.
    I wish good luck.
    Nikolay

  • Different Date Formats in the same "From"

    Hello
    We used different date formats depending on the users language.
    In a report this is simple to implement ... read the date field twice (in different formats dd/mm/yyyy and mm/dd/yyyy) and display only one based on the language.
    I want to be able to do the same in a "form" which updates a date. In this case the about is not allowed.
    Has anyone have solution for this using "APEX" forms or do a need to write a process to achieve this?
    Thanks
    Pete

    Pete,
    You don't specify what version of Application Express you're using, so I'll assume APEX 3.1 or later.
    Are you setting the date format yourself, based upon the user's language?
    1) You could have the application's language derived from Browser, and then APEX would automatically set the NLS_LANGUAGE and NLS_TERRITORY settings accordingly. Then, I would simply use 'DS' as the Application Date Format. For Date Pickers on a form, I would use item type 'Date Picker (use Application Date Format)'.
    2) If you're already determining the date format yourself and you don't want APEX to do it for you, ensure that you are setting this value in an application item (e.g., PETE_DATE_FORMAT). Then, you could still use Application Date Format with a value of &PETE_DATE_FORMAT. (inclusive of the trailing period).
    When you use Application Date Format, the conversion should happen automatically for you so that you don't have to code this yourself on the Form.
    I hope this helps.
    Joel

  • Change Date Format in Calendar prompt

    Hi All,
    I am on 11.1.1.5 and the calendar prompt on selection of date/typing of date defaults to MM/dd/yyyy but, the requirement is to make it to default to MM/dd/yy. I have made 3 changes to the localedefinitions.xml file (dateSeparator,dateShortFormat,dateOrder) and they look like below
    <property name="dateSeparator">/</property> // separator to use between fields in short date formats
    <property name="dateShortFormat">MM/dd/yy</property> // default short date format for locale
    <property name="dateOrder">mdy</property> // preferred order of date fields for input
    But I still dont see a change in the format of the Calendar prompt. Do I need to change something else too?

    I checked under the My Account the locale is set to English and I have the following in the file but still when I select in the prompt the date format is MM/dd/yyyy instead of MM/dd/yy
    <localeDefinition name="en"> <!-- english base -->
    <property name="localeDisplayMessage">kmsgLanguageName_en</property>
    <property name="defaultLanguage">en</property>
    <property name="characterSetList">locale:en</property>
    <property name="listSeparator">,</property>
    <property name="decimalSeparator">.</property>
    <property name="thousandsSeparator">,</property>
    <property name="dateSeparator">/</property>
    <property name="timeSeparator">:</property>
    <property name="am">AM</property>
    <property name="pm">PM</property>
    <property name="timeFormat">h:mm:ss tt</property>
    <property name="dateShortFormat">MM/dd/yy</property>
    <property name="dateLongFormat">dddd, MMMM dd, yyyy</property>
    <property name="negativeNumberTemplate">-#</property>
    <property name="collationImplementation">win:0409</property>
    <property name="dateOrder">mdy</property>

  • Changes in date format while creating/downloading the file

    Hi All,
    Can any one let me know how does the system determines which date format should it apply while creating/downloading the file.
    Issue :
    When I create/download the file generated by report RTXWCF02 using unix level acess the Date format of a field in file is DD.MM.YYYY where as in user profile i can see its in MM/DD/YYYY.
    I dont understand how system determines the date format and How we can change it. Please suggest.
    Regards,
    Ravi Kasnale

    I would suggest you to use ALV_XXL_CALL if your want to keep your data formats intact.
    like this -   CALL FUNCTION 'ALV_XXL_CALL'
           EXPORTING
                i_tabname           = 'T_GRID'   " Name of your internal table
                it_fieldcat         = t_fcatk[]      "Your LAV grids catalog.
           TABLES
                it_outtab           = t_grid         "Internal table itself
           EXCEPTIONS
                fatal_error         = 1
                no_display_possible = 2
                OTHERS              = 3.
      IF sy-subrc <> 0.
        MESSAGE e806(bk).
      ENDIF.
    hope it helps.

  • Date format conversation in OBIEE

    Hello guys
    I am a quick question about how to stop OBIEE from using to_date conversation? The date format in the db is dd/month/yy, and when I run any report in OBIEE answer using Date columns, it will always convert the format to "dd/mm/YYYY". The sql generated will always have a to_date() in where clause..
    Is there a way to not have OBIEE does that and just show the date with format as it is and drop the to_date conversion in SQL?
    Thanks

    I think you are getting confused here. Oracle's default date format is dd-mon-yyyy. So when you run a query like this:
    DATE_COLUMN = '01-Nov-2009'
    Oracle applies an IMPLICIT data type conversion to your date string and converts it to a date data type. Whether you allow Oracle to do the implicit conversion or do it explicitly like this DATE_COLUMN = To_date('01-Nov-2009', 'dd-mon-yyyy') should always result in the same query performance. When to TO_DATE functions affect query performance? When you apply the function over the DATE_COLUMN like this:
    TO_DATE(DATE_COLUMN, 'dd-mon-yyyy') = '01-Nov-2009'
    Why? Because indexes on DATE_COLUMN WILL NOT be used unless you have defined a function level index with a index column using the function: TO_DATE(DATE_COLUMN, 'dd-mon-yyyy'). My guess is that your DATE_COLUMN is not a date but a varchar2, therefore when you pass in To_date('01-Nov-2009', 'dd-mon-yyyy') Oracle does an IMPLICIT conversion of your DATE_COLUMN to DATE data type to match the data type of your where condition hence it is taking long to execute as no indexes are used. Can you confirm what is the exact data type of the DATE_COLUMN you are using to filter on? Do you have an index defined in that column? Can you confirm exactly how is the index is defined? Have you ran statistics on the table AND the indexes as well?

  • How can i convert this data(00000000) into date format(yyyy-MM-dd)

    Hi,
    i am using this method to convert date format from string.
    public static string FormatDate(string inputDate, string inputFormat)
                System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
                string datepresent = DateTime.Now.Date.ToString("yyyy-MM-dd");
                return datepresent;
    its working properly,
    but when input data is like 00000000 i am getting error this is not valid.
    how can i convert this into date format any help..!

    Have you tried the above code:
    I can see it is working with both Date and DateTime destination nodes.
    Map:
    Functoid Parameters:
    Functoid Script:
    public static string FormatDate(string inputDate, string inputFormat)
    string datepresent;
    if (inputDate == "00000000")
    datepresent = "0000-00-00";
    else
    System.DateTime date = DateTime.ParseExact(inputDate, inputFormat, null);
    datepresent = date.ToString("yyyy-MM-dd");
    return datepresent;
    Input:
    <ns0:InputDateString xmlns:ns0="http://DateFormat.SourceSchema">
    <DateString>00000000</DateString>
    </ns0:InputDateString>
    Output:
    <ns0:OutputDate xmlns:ns0="http://DateFormat.DestinationSchema">
    <Date>0000-00-00</Date>
    </ns0:OutputDate>
    If this answers your question please mark as answer. If this post is helpful, please vote as helpful.

  • Bermuda Short (Date Format)

    I live in Bermuda.  We use a D/M/Y date format as in the UK, but  we use (123) 456-7890 for telephone numbers as in North America.  I used to use Canada as my region setting to satisfy this combination.  In iOS 5, selecting Canada now gives me YYYY-MM-DD dates.  I was happy to then find that Bermuda is actually now an option in the Region Format list (take that, Bahamas and Barbuda!), but selecting Bermuda erroneously gives me  the U.S. M/D/Y format.  It seems the only way way to get my desired D/M/Y is to choose a European, African, or Asian country, but then my Address Book phone numbers are nearly unrecognizable.
    Is there a d/m/y, (123) 456-7890 option in the Region Format list (I haven't tried them all)?
    or
    is there a way to customize these settings?
    or
    how do I let Apple know they are using the wrong date format for Bermuda?

    well you could do something like this.
    String year = "02";// you said you are parsing this out...
    year = "20"+year;
    int yearAsInt = Integer.parseInt(year);but most likely the better way is to use date from string formatting tool already available http://java.sun.com/j2se/1.4/docs/api/java/text/SimpleDateFormat.html

  • XI: Date format

    hello all,
    I have developed business scenario that is oracle system to R/3 system. data is sending successfully but the only problem with the data format..
    we are getting data from source this format DD/MM/YYYY and we are transferring data to r/3 YYYY/MM/DD..... some times source data is coming different format like MM/DD/YYYY,
    yyyy/dd/mm at this time i am facing a problem....
    my requirement is source data is comes any format but it transfer data to target this format only YYYY/MM/DD....plz could anybody help me on this....

    hi
    use these thread for change date format
    change in UDF according to your requirement
    udf for changing date faormat yyyy/mm/dd to yyyymmdd
    Re: UDF for Date Funtions
    UDF for Date format
    Re: UDF Function
    UDF for Date format

Maybe you are looking for

  • Two Important Tips if you want

    I'm seeing a lot of questions about from kind folk that are about to purchase their MBP or their tower etc... So, not many people know about this and I've been doing this for years..... Either on the Apple / Store site (Lower Right hand Corner, in Re

  • Camera doesn't funktion since the last update

    Since the last IOS-Update, the front camera doesn't function. I can't even start the app. With other camera Apps I can only take pictures and make videos but the not can make any video calls like Tango. I tried to do the recovry from the I-Cloud but

  • Accessing JMS UDD deployed on OSB cluster from a composite JMS adapter deployed on soa cluster

    Our environment setup Single domain with three clusters osb_cluster.soa_cluster and   bam_cluster osb_cluster: osb_server1 and osb_server2 wlsbJMSServer_auto_1: targetted to osb_server1 wlsbJMSServer_auto_2: targetted to osb_server2 osb_subdeployment

  • [6120c]Startup: wrong code was entered 5 times, i'...

    Hello all, I've put my phone in a pocket on my handbag, phone was locked via security code. Due to occasional pushes on a keyboard, as far as I can gather, there were dials of random digits to input field of security code. After I took my phone and t

  • IMovie lags when editing video and audio

    I just bought iMovie yesterday from the Mac App Store. I recorded a DJ set and wanted to edit my Video with better quality audio that i recorded seperately. I find that when editing my video and audio (Matching up audio), there is alot of lag. Especi