[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index] [Date Index] [Thread Index]
[SQR-USERS Info] [SQRUG Home Page]

Re: conditional logic in the From and where clauses



Paul -
    The piece of functionality I think that you are looking for is
dynamic SQL.  here is a code sample from a program I just wrote to
detect duplicate records in a group of columns that should be a key.
Which table and which columns are read from a config file.  Notice the
square brackets.  These tell sqr that you are changing the syntax of the
select and not just inserting a value.  SQR doesn't check dynamic
selects at compile time for correctness.

begin-selct

[$g_column1]  &column1=CHAR

from
    fyiadm.fyi_[$g_table_name]
[$g_where_clause]
order by
    [$g_column_list], [$g_rkey_column] desc
end-select

Hope this helps,
Eric

------------------------------------------------------------------------
Eric Eastman    | Ray Ontko & Co. | Adverbs are endangered, act quickly.
erice@ontko.com | Richmond, IN    | http://www.ontko.com/, ftp.ontko.com

On Mon, 10 Feb 1997, Paul Baker wrote:

> Recently I came across some code that used enviroment variables in a If
> statement
> to determine which table a from clause used.
>
> Does anyone know if a If statement can be used in the and statements in the
> where clause.
>
> Thanks
>
> Paul Baker
> BSC,
> Tulsa, Okla
>