[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Conditional selects
- Subject: Re: Conditional selects
- From: Pragya Chandra <pchandra@FASTENAL.COM>
- Date: Fri, 2 Jun 2000 16:37:21 -0500
Try this:
let $completeEqualStr = 'tableX where fieldY = ' ||''''|| $value||''''
You need these four quotes around any character field.
> -----Original Message-----
> From: Andrew Rivers [SMTP:andrew.rivers@CWCOM.NET]
> Sent: Friday, June 02, 2000 4:32 PM
> To: SQR-USERS@list.iex.net
> Subject: Re: Conditional selects
>
> Chris
> Many thanks to you and others for the info on the use of [ ] to pass in
> strings to a where clause - including the where and from.
> I find that your suggestion woks fine for string formats using null and
> not
> null operators:
> let $thisWhere = 'where fieldName is null'
> let $competeNullStr='tableX where fieldY is null'
> let $competeNotNullStr='tableX where fieldY is not null'
>
> or a set of composites strings with at least on trailing space:
> let $tableName = 'tableX '
> let $theWhere = 'where '
> let $FieldName = 'fieldY '
> let $operatorIs = 'is '
> let $condition = 'null'
> ...
> so in the select statement these strings and compost string would be::
> from tableNameX [$thisWhere]
> from [$completeNullStr]
> from [completeNotNullStr]
> from [$tableName][$theWhere ][$fieldName][$operator][$condition]
>
> ****************************************************************
> However, so far I have been unable to do the same using the operator =
> Substituting:
> let $value = 'whatever'
> let $operatorEqual = '= '
> let $equalWhere = 'where fieldName = '
> $completeEqualStr = 'tableX where fieldY = ' | | $value
>
> so in the select statement these strings and composite strings would be:
> from tableName [$equalWhere] [$value]
> from [$tablename] [$theWhere] [$operatorEqual] [$value]
> from [$completeEqualStr]
>
> I have tried all sort of combination but seem to be unable to do the same
> for the equal operator.
> Am I missing something?
>
> Although there is no problem passing variables to and equal operator that
> is not what I need...
> I need to pass in both equal and null operators to the same where
> clause.
>
> Is the facility to pass in the equal operator as a string dependent on the
> version of SQL?
> The version given by About:
> v4.1.1 for Windows 95/NT
> Version given using: $sqr-ver
> SQR/4.0.3/PC/Windows NT 4.0/ODBC Level1/Jun 11 1997
> Currently, I using Window 95.
> Which is all very odd - Any comments?
>
> Any further suggestions would be most welcome...
>
> Thanks.
>
> Andrew
> *******
>
>
>
> ----- Original Message -----
> From: Wanko, Christopher G, CFCTR < apollo@ATT.COM
> <mailto:apollo@ATT.COM>>
> To: < SQR-USERS@list.iex.net <mailto:SQR-USERS@list.iex.net>>
> Sent: Wednesday, May 31, 2000 1:47 PM
> Subject: Re: Conditional selects
>
>
> > I hate Outlook.
> >
> > > let $selectedValue = 'valueSelected'
> > > begin-select
> > > field1
> > > field2
> > > field3
> > > from tablename
> > > where field2 is null
> > > field2 = $selectedValue
> > > end-select
> >
> > Try:
> > if isnull($selectedValue)
> > let $thiswhere = 'and field2 is NULL'
> > else
> > let $thiswhere = 'and field2 = ' || $selectedValue
> > end-if
> >
> > Then:
> > begin-select
> > field1
> > field2
> > field3
> > from tablethingie
> > where something equals someThing
> > [$thiswhere]
> > and something else equals anotherThing
> > order by 1,3,2
> >
> > -Chris
>