Subject Re: Options after Where statement
Author emb_blaster
you´ve tried this?
begin
for select supp_code,supp_name
from supplier
/* next line is the only difference */
where (supp_code=:loccode and :name_or_code=0) or
(supp_name=:locname and :name_or_code=1)
into :code,:name
do
suspend;
end

this may solve, but I don´t know if it will be fastest than your code.
more comments? anyone?

--- In firebird-support@yahoogroups.com, Alan.Davies@... wrote:
>
> Hi - I'm using FB 2.1 on various systems, e.g. W2003 server, and am
> looking to improve readability and reduce the possibility of errors
> within stored procedures.
> A very simple example would be:
> 3 parameters passed to sp - name_or_code, locname and loccode
> begin
> if (:name_or_code=0) then /* code */
> begin
> for select supp_code,supp_name
> from supplier
> /* next line is the only difference */
> where supp_code=:loccode
> into :code,:name
> do
> suspend;
> end
> else if (:name_or_code=1) then /* name */
> begin
> for select supp_code,supp_name
> from supplier
> /* next line is the only difference */
> where supp_name=:locname
> into :code,:name
> do
> suspend;
> end
> end
>
> Is it possible to combine these into one statement with e.g. a case
> statement surrounding the "where .." or by setting a variable with
> the relevant condition?
> Not possible to alter the way the parameters are passed, they come
> from Delphi apps written by others.
>
> --
> Alan J Davies
> Aldis
>