Re: Date Validation? - Mailing list pgsql-sql
From | Christopher Sawtell |
---|---|
Subject | Re: Date Validation? |
Date | |
Msg-id | 20010715034251.RZSF3874492.mta6-rme.xtra.co.nz@there Whole thread Raw |
In response to | Re: Date Validation? ("Josh Berkus" <josh@agliodbs.com>) |
List | pgsql-sql |
On Sun, 15 Jul 2001 06:40, Josh Berkus wrote: > Richard, > > > Poked around and had a think and can't come up with anything better > > than > > Stephan Szabo's suggestion of hacking PG's built-in function. You'll > > want > > to_timestamp() which is called from to_date and it's in > > src/backend/utils/adt/formatting.c - AFAICT you'll just need to > > comment out > > the elog(...) calls and return a null value (or whatever). > > Not too likely from me ... I don't do C at all! 'Tis a shame. I could teach you C if you want. Get the lessons from the URL in the .signature box below. > I'm one of those > horrible people who came to SQL & PHP from VB and MS Access rather than > from a C.S. degree. Not 'horrible', nobody who has 'seen the light' in any way can be described as "horrible". That description is reserved for those folks who revel in their intimacy with darkness. ( How you define "darkness" is over to you ) > Heck, my college degree is in sculpture. No wonder the aesthetic is so important to you. > > Failing that, what about writing is_valid_date() in pl-tcl/perl? > > Don't know > > anything about tcl, but should be easy enough in perl (cut & paste > > from a > > suitable module) > > Sounds good. Anybody on the list I can beg (or pay $50) to write it and > post it to the list? I don't know from perl or tcl either (I do SQL, > PHP, Java and VB). Well here is how I deal with the problem. First you have to turn off the error reporting flag in the php.ini configuration file. That stops most of the geek-speak rubbish getting out to the client. Now, please find attached the .php files I am using in a project. I feel that the level of geek-speak in the solution is accepable, but if it isn't to you or your clients, then you could always replace the error message goming out of PostgreSQL to something more understandable to the "Common Man / Lay Person" by editing the PostgreSQL source and re-compiling it. ( not difficult ) Note that I have the database here configured to the European representation of dates and the wording of the error messages in the php file reflects this. Also note that I have forgotton to test for dates being in the past, and that it would be better if the error message was delivered in a pop-up html page or a JavaScript alert. Off the top of my head another untested idea for a solution to the problem is to do the data verification in JavaScript on the client machine. There is a JavaScript date.parse() function. Qualify for the $50 ? -- Sincerely etc., NAME Christopher SawtellCELL PHONE 021 257 4451ICQ UIN 45863470EMAIL csawtell @ xtra . co . nzCNOTES ftp://ftp.funet.fi/pub/languages/C/tutorials/sawtell_C.tar.gz -> Please refrain from using HTML or WORD attachments in e-mails to me <-