RE: [?]Date validation ...
Posted in 1997
Max (pyz@panix.com) wrote:
> Greetings,
>
> I'm working on a Unix shell script which calls an isql $DBNAME routine.
> The script prompts the user for several input variables, among those a
> date.
>
> Would anyone have recommendations on how to do date validation (as in
> possibly any day from now (t) going back ten days (t-10) in the script
> before the date is passed to the Informix SQL routine?
>
> Thanks in advance!
>
> Max Pyziur
> pyz@panix.com
Here's a suggestion:
Run an isql or dbaccess early in the script to generate the valid date =
values, eg
#!/bin/ksh
DBDATE=3DY4MD0; export DBDATE #set to however your user is to be =prompted
dbaccess $DBNAME << EOSQL 2>dev/null
OUTPUT TO date_values.$$ WITHOUT HEADINGS
SELECT TODAY, TODAY-1, TODAY-2, TODAY-3, TODAY-4, TODAY-5, TODAY-6,
TODAY-7, TODAY-8, TODAY-9, TODAY-10
FROM systables
WHERE tabid =3D 1;EOSQL
read st_date?"Please enter a start date"
if [ ! $(grep "$st_date" date_values.$$ > /dev/null) ]
then
echo "Please enter a date in the range....."
fi
#.. you get the idea...
This method allows you to write some code around the first SQL to exit =
gracefully if the database is down when the user wants to run the report. =
Of course, this never happens..... ;-)
RET
+------------------------------------------+
| Richard Thomas |
| DBA - Marketing Information Systems |
| Optus Communications |
| email: richard_thomas@yes.optus.com.au |
| Ph: +61 2 9342 7188 |
| "My opinions are my opinions" |
+------------------------------------------+