Re: (2) Bourne & sql & I must be doing something wrong
Posted in 2000
Topics: General Discussion
From: "Obnoxio The Clown" <obnoxio@hotmail.com> > >From: Tony! <NoSpam@Thank.You.com> >> >>How i'd like to have it, is for the user to enter either capital or >>lower case... (i.e- c or C for (c)losed) stat="status matches '[cC]'" or stat="UPPER(status) = 'C'" depending on your version ______________________________________________________ Get Your Private, Free Email at http://www.hotmail.com
Obnoxio The Clown wrote:
> From: "Obnoxio The Clown" <obnoxio@hotmail.com>
> >
> >From: Tony! <NoSpam@Thank.You.com>
> >>
> >>How i'd like to have it, is for the user to enter either capital or
> >>lower case... (i.e- c or C for (c)losed)
>
> stat="status matches '[cC]'"
>
> or
>
> stat="UPPER(status) = 'C'"
>
> depending on your version
But why not just map the ''o', c', or 'a' to upper case in the shell script:
ora=`echo $oca | tr "[a-z]" "[A-Z]"`
if [$oca = "C"] ....
Or more simply:
if [ $oca = "c" -o $oca = "C" ] ... (or however you do an 'OR' operation in
Bourne)
Art S. Kagel
"Tony!" wrote:
> When running a script I made up, I get an error ...
>
> Database selected.
>
> 217: Column (o) not found in any table in the query (or SLV is
> undefined).
> Error in line 15> Near character position 1
>
> ___________________________________________________________________________
> Below is the pertinent part of the script in question
> ___________________________________________________________________________
>
> :
> clear
> echo " Prototype of PMS Reporting System"
> echo " Beta "
> echo "\\n\\n"
> echo "please enter the start date (mmddyyyy):\\c"
> read date1
> echo "Please enter the end date (mmddyyyy):\\c"
> read date2
> echo "Please enter the Priority ("1", "2", "3"):\\c"
> read num
> echo "(O)pen or (C)losed or (A)ll ("O","C","A"):\\c"
> read oca
> if [ $oca = "O" ]
> then
> stat="and status = O"
> fi
>
> if [ $oca = "C" ]
> then
> stat="and status = C"
> fi
>
> if [ $oca = "A" ]
> then
> stat=" "
> fi
>
> echo "\\n\\n "
> cat << __ending > tonycool.sql
> database help_desk@iota;
> unload to kooky.txt
> select report_dt, report_tm, resolv_dt, resolv_tm, ticket_no,
> facility,
> operator, status, assn_to, priority,>
> INTERVAL(0) MINUTE(9) TO MINUTE + (
> (EXTEND(EXTEND(resolv_dt, YEAR TO DAY), YEAR TO MINUTE) +
> (resolv_tm - DATETIME(00:00) HOUR TO MINUTE) -
> (EXTEND(EXTEND(report_dt, YEAR TO DAY), YEAR TO MINUTE) +
> (report_tm - DATETIME(00:00) HOUR TO MINUTE)))) elapsed_mins
>
> from help where report_dt between "$date1" and "$date2" and priority =
> "$num"
> ${stat}
>
> group by report_dt, report_tm, resolv_dt, resolv_tm, ticket_no,
> facility,
> operator, priority, status, assn_to;
>
> __ending
>
> chmod 777 tonycool.sql
>
> isql < tonycool.sql
>
> cat kooky.txt | tr -d ' \\t' > kooky
> rm kooky.txt
> echo "To Printer? or To Screen? \\c"
> read ans
> case $ans in
> <Snip>
>
> _________________________
> The script was working fine until I added the if statements for the
> Open/closed/all question it prompts the user for, then places as a
> variable in the sql portion.
> How can I get this to work?
>
> How i'd like to have it, is for the user to enter either capital or
> lower case... (i.e- c or C for (c)losed)
> Helllllllllp?
>
> -Tony!-
Art S. Kagel